試圖遷移功能angular2打字稿應用的WebPack我得到以下運行時錯誤Angular2 +的WebPack UncaughtReferenceError __decorate沒有定義
app.js:38016Uncaught ReferenceError: __decorate is not defined
在該行的代碼,它打擊了這個樣子的
後NpnPortalService = __decorate([
core_1.Injectable(),
__metadata('design:paramtypes', [http_1.Http])
], NpnPortalService);
Webpack不抱怨當我做一個構建,我沒有看到任何打字稿編譯錯誤。這裏是我的webpack.config.js
module.exports = {
entry: {
app: "./app/boot",
polyfills: ['./node_modules/es6-shim/es6-shim.min.js', './node_modules/zone.js/dist/zone.min.js']
},
output: {
path: __dirname + '/dist',
filename: "[name].js"
},
resolve: {
extensions: ['', '.js', '.ts']
},
module: {
loaders: [{
test: /\.ts/, loader: 'ts-loader', exclude: /node_modules/
}],
noParse: [ './node_modules/es6-shim/es6-shim.min.js' ]
}
};
這裏是我的tsconfig.js
{
"compilerOptions": {
"target": "es5",
"module": "commonjs",
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"sourceMap": true,
"noEmitHelpers": true
},
"files": [
"app.component.ts",
"../node_modules/angular2/typings/browser.d.ts"
],
"compileOnSave": false,
"buildOnSave": false
}
這裏是我的index.html
<!DOCTYPE html>
<html>
<head>
<script src="https://code.angularjs.org/2.0.0-beta.0/angular2-polyfills.js"></script>
<!-- Set the base href -->
<script>document.write('<base href="' + document.location + '" />');</script>
<title>NPN Data Download Tool</title>
<script src="dist/polyfills.js"></script>
<!-- Google Maps Initialization -->
<script>
function initMap() {
var mapDiv = document.getElementById('map_canvas');
console.log(mapDiv.getAttribute("intialized"));
if (!mapDiv.getAttribute("intialized")) {
console.log("intializing google map");
var map = new google.maps.Map(mapDiv, {
center: {lat: 40.750289, lng: -89.583163},
zoom: 5
});
map.enableKeyDragZoom();
var dz = map.getDragZoomObject();
google.maps.event.addListener(dz, "dragend", function(bnds) {
document.getElementById("ObservationBottomLeftX1").value = bnds.getSouthWest().lat();
document.getElementById("ObservationBottomLeftY1").value = bnds.getSouthWest().lng();
document.getElementById("ObservationUpperRightX2").value = bnds.getNorthEast().lat();
document.getElementById("ObservationUpperRightY2").value = bnds.getNorthEast().lng();
document.getElementById("necoords").innerHTML = "<span style='font-weight:bold'>North East Corner</span>: " + bnds.getNorthEast().lat() + ", " + bnds.getNorthEast().lng();
document.getElementById("swcoords").innerHTML = "<span style='font-weight:bold'>South West Corner</span>: " + bnds.getSouthWest().lat() + ", " + bnds.getSouthWest().lng();
});
google.maps.event.addListener(map, 'zoom_changed',
function() {
if (map.getZoom() < 3) {
map.setZoom(3);
};
});
document.getElementById('map_canvas').setAttribute("intialized", true);
}
}
</script>
<script src="https://maps.googleapis.com/maps/api/js"></script>
<script src="./keydragzoom.js" type="text/javascript"></script>
</head>
<body>
<my-app>loading...</my-app>
</body>
<script src="dist/app.js"></script>
<!-- Bootstrap -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.0/jquery.min.js"></script>
<script src="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>
<link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css">
<!-- Override Bootstrap css here -->
<link rel="stylesheet" href="styles.css">
</html>
可能的重複http://stackoverflow.com/questions/36808303/webpackangular2-error-uncaught-referenceerror-decorate-is-not-defined – yurzui