我嘗試導入AngularJS 1.6.5
到我的應用程序。 我使用webpack 3.7.1
作爲模塊打包器。 此外,我使用typescript
爲我的代碼transpile。嘗試導入到webpack軟件包時未定義Angularjs
的package.json:
{
"name": "webpack_test_app",
"version": "1.0.0",
"description": "",
"main": "app.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "ISC",
"devDependencies": {
"ts-loader": "^2.3.7",
"webpack": "^3.7.1"
},
"dependencies": {
"angular-ui-bootstrap": "^2.5.0",
"angular": "1.6.5"
}
}
webpack.config.js:
module.exports = {
entry: './app.js',
output: {
filename: './views/resources/js/bundle.js'
},
resolve: {
extensions: ['.ts', '.tsx', '.js']
}
};
app.ts
import angular from './node_modules/angular/angular.js';
console.log('angular is -> ', angular);
所有Chrome控制檯打印後angular is -> undefined
而且我試過import angular from './node_modules/angular/angular';
如果您需要更多信息 https://github.com/toddmotto/angularjs-styleguide/tree/master/typescript –