tsconfig:
{
"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";错误:
./~/typedi/index.js 528字节{0}生成1个错误。/~/ES6-shim/ES6-shim.js 533字节{0}生成1个错误。/~/Reflect.js 540字节{0}生成1个错误。 错误在./~/Reflect.js模块构建失败:错误:找不到文件:'/home/sesmanovich/www/JQueryPlugins/node_modules/reflect-metadata/Reflect.js'.(/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-注入/应用程序4:0-27
发布于 2017-03-22 20:52:22
webpack配置:
loaders: [
{loader: "ts-loader"}
]是错的。您应该只对ts-loader文件使用ts/tsx。
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' }
]更多
https://stackoverflow.com/questions/42957796
复制相似问题