gpt4 book ai didi

typescript - Angular2 + webpack Uncaught ReferenceError : System is not defined

转载 作者:太空狗 更新时间:2023-10-29 19:31:14 35 4
gpt4 key购买 nike

我也遇到了同样的问题: Why webpack bundled as 'System.register'

我用 webpack 构建了 bundle.js,但出现错误:

Uncaught ReferenceError: System is not defined

我的 bundle.js 包括:

   System.register(['angular2/platform/browser', './app.component', 'rxjs/Rx'], function(exports_1, context_1) {
"use strict";
var __moduleName = context_1 && context_1.id;
var browser_1, app_component_1;
return {
setters:[
function (browser_1_1) {
browser_1 = browser_1_1;
},
function (app_component_1_1) {
app_component_1 = app_component_1_1;
},
function (_1) {}],
execute: function() {
//enableProdMode();
browser_1.bootstrap(app_component_1.AppComponent)
.then(function (success) { return console.log("Bootstrap success"); })
.catch(function (error) { return console.log(error); });
}
}
});

我已经在 tsconfig.json 中将模块更改为 commonjs,所以这可能是某个地方的一些愚蠢错误。这是我的 tsconfig.json

{
"compilerOptions": {
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"target": "es5",
"module": "commonjs",
"removeComments": true,
"sourceMap": false
},
"exclude": [
"node_modules"
]
}

和 webpack.config.js

module.exports = {
entry: "./app/main",
output: {
filename: "bundle.js"
},
resolve: {
extensions: ['', '.js', '.ts']
},
module: {
loaders: [{
test: /\.ts/, loaders: ['ts-loader'], exclude: /node_modules/
}]
}
};

感谢您的帮助

最佳答案

在 tsconfig.json 的 compilerOptions 中将 module 更改为 commonjs

关于typescript - Angular2 + webpack Uncaught ReferenceError : System is not defined,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36793744/

35 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com