2017-03-22 3 views
0

TSconfig:webpack sieht keine Dateien

{ 
    "compilerOptions": { 
     "module": "commonjs", 
     "target": "es5", 
     "sourceMap": true, 
     "emitDecoratorMetadata": true, 
     "experimentalDecorators": true, 
     "noImplicitAny": true, 
     "declaration": true 
    }, 
    "files": [ 
     "sample2-inject/app.ts" 
    ], 
    "exclude": [ 
    ] 
} 

webpack.config.js:

var path = require('path'); 
module.exports = { 
    entry: path.resolve("./sample2-inject/app.ts"), 
    output: { 
     path: path.resolve("./dist"), 
     filename: "bundle.js", 
     library: "home" 
    }, 
    resolve: { 
     extensions: [".webpack.js", ".web.js", ".ts", ".js"] 
    }, 
    module: { 
     loaders: [ 
      {loader: "ts-loader"} 
     ] 
    }, 
    watch: true, 
    devtool: "eval" 
}; 

app.ts:

import "es6-shim"; 
import "reflect-metadata"; 
import {Container} from "typedi"; 

Fehler:

[0] ./~/typedi/index.js 528 bytes {0} [built] [failed] [1 error] [1] ./~/es6-shim/es6-shim.js 533 bytes {0} [built] [failed] [1 error] [2] ./~/reflect-metadata/Reflect.js 540 bytes {0} [built] [failed] [1 error]

ERROR in ./~/reflect-metadata/Reflect.js Module build failed: Error: Could not find file: '/home/sesmanovich/www/JQueryPlugins/node_modules/reflect-metadata/Reflect.js'. at getValidSourceFile (/usr/local/lib/node_modules/typescript/lib/typescript.js:81080:23) at Object.getEmitOutput (/usr/local/lib/node_modules/typescript/lib/typescript.js:81446:30) at getEmit (/home/sesmanovich/www/JQueryPlugins/node_modules/ts-loader/dist/index.js:99:43) at Object.loader (/home/sesmanovich/www/JQueryPlugins/node_modules/ts-loader/dist/index.js:27:11) @ ./sample2-inject/app.ts 4:0-27

+0

'npm i widerspiegeln-metadata'? – G0dsquad

+0

installiert alle subl ist Datei nach Fehlerpfad geöffnet –

Antwort

1

Von Ihrem webpack config:

loaders: [ 
     {loader: "ts-loader"} 
    ] 

ist falsch. Sie sollten nur ts-loader für ts/tsx Dateien verwenden.

loaders: [ // loaders will work with webpack 1 or 2; but will be renamed "rules" in future 
    // all files with a `.ts` or `.tsx` extension will be handled by `ts-loader` 
    { test: /\.tsx?$/, loader: 'ts-loader' } 
] 

Mehr

Siehe Info: https://github.com/TypeStrong/ts-loader#configuration