Skip to content
This repository has been archived by the owner on Dec 3, 2023. It is now read-only.

Fix ngRoute and others angular modules including #17

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion demo/bower.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
"tests"
],
"dependencies": {
"angular": "~1.2.24"
"angular": "~1.2.24",
"angular-route": "~1.2.24"
}
}
2 changes: 1 addition & 1 deletion demo/myApp.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
var myApp = angular.module('myApp', ['dependency']);
var myApp = angular.module('myApp', ['dependency', 'ngRoute']);

myApp.run(function($document){
$document[0].write('Hello from myApp. ');
Expand Down
10 changes: 9 additions & 1 deletion demo/webpack.config.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,21 @@
var AngularPlugin = require('angular-webpack-plugin');
var path = require('path');

module.exports = {
entry: "myApp",
output: {
path: __dirname,
filename: "generated_bundle.js"
},
resolve: {
root: [ process.cwd(), path.resolve('bower_components') ]
root: [ process.cwd(), path.resolve('bower_components') ],
alias:{
// This is needed because the module name doesn't match the file name
// but we don't need to locate the file because it is a bower component
// with a file name the same as the directory (component) name:
// bower_components/angular-route/angular-route
ngRoute: 'angular-route'
}
},
plugins: [new AngularPlugin()]

Expand Down
5 changes: 5 additions & 0 deletions lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,11 @@ AngularPlugin.prototype = {

// This injects the angular module wherever it's used.
addAngularVariable: function(parser) {
//support window.angular usage too
parser.plugin("expression window.angular", function(expr) {
return ModuleParserHelpers.addParsedVariable(this, 'angular', "require('exports?window.angular!angular')");
});

return ModuleParserHelpers.addParsedVariable(parser, 'angular', "require('exports?window.angular!angular')");
},

Expand Down