Reputation: 7852
I try import AngularJS 1.6.5
to my app.
I use webpack 3.7.1
as module bundler.
Also, I use typescript
for transpile my code.
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);
After all chrome console print angular is -> undefined
Also I tried import angular from './node_modules/angular/angular';
Upvotes: 0
Views: 839
Reputation: 1978
Install Typings
to do Step1: execute command to install tsd
npm install -g tsd
Step3: execute command to install typings
tsd install angular
tsd install angular-route
then in app.ts
import angular from 'angular';
Upvotes: 1
Reputation: 7852
I tried to include all dependencies.
import * as angular from 'angular';
Upvotes: 0