imports-loader
Advanced tools
Comparing version 0.6.5 to 0.7.0
14
index.js
@@ -28,2 +28,16 @@ /* | ||
postfixes.unshift("}.call(" + value + "));"); | ||
} else if(name.indexOf(".") !== -1) { | ||
name.split(".").reduce(function(previous, current, index, names) { | ||
var expr = previous + current; | ||
if(previous.length === 0) { | ||
imports.push("var " + expr + " = (" + current + " || {});"); | ||
} else if(index < names.length-1) { | ||
imports.push(expr + " = {};"); | ||
} else { | ||
imports.push(expr + " = " + value + ";"); | ||
} | ||
return previous + current + "."; | ||
}, ""); | ||
} else { | ||
@@ -30,0 +44,0 @@ imports.push("var " + name + " = " + value + ";"); |
{ | ||
"name": "imports-loader", | ||
"version": "0.6.5", | ||
"version": "0.7.0", | ||
"author": "Tobias Koppers @sokra", | ||
"description": "imports loader module for webpack", | ||
"scripts": { | ||
"test": "mocha", | ||
"travis": "npm run -s test" | ||
}, | ||
"dependencies": { | ||
"loader-utils": "0.2.x", | ||
"source-map": "0.1.x" | ||
"loader-utils": "^0.2.16", | ||
"source-map": "^0.5.6" | ||
}, | ||
"devDependencies": { | ||
"mocha": "^3.1.2", | ||
"should": "^11.1.1" | ||
}, | ||
"files": [ | ||
"index.js" | ||
], | ||
"license": "MIT", | ||
@@ -11,0 +22,0 @@ "repository": { |
# imports loader for webpack | ||
Can be used to inject variables into the scope of a module. This is especially useful if third-party modules are relying on global variables like `$` or `this` being the `window` object. | ||
The imports loader allows you to use modules that depend on specific global variables. | ||
This is useful for third-party modules that rely on global variables like `$` or `this` being the `window` object. The imports loader can add the necessary `require('whatever')` calls, so those modules work with webpack. | ||
## Installation | ||
@@ -22,3 +24,3 @@ | ||
``` javascript | ||
require("imports?$=jquery!./example.js"); | ||
require("imports-loader?$=jquery!./example.js"); | ||
``` | ||
@@ -43,3 +45,3 @@ | ||
```javascript | ||
require("imports?$=jquery,angular,config=>{size:50}!./file.js"); | ||
require("imports-loader?$=jquery,angular,config=>{size:50}!./file.js"); | ||
``` | ||
@@ -60,5 +62,6 @@ | ||
test: require.resolve("some-module"), | ||
loader: "imports?this=>window" | ||
loader: "imports-loader?this=>window" | ||
} | ||
] | ||
} | ||
}; | ||
@@ -73,7 +76,7 @@ ``` | ||
`imports?$=jquery` | ||
`imports-loader?$=jquery` | ||
### Custom Angular modules | ||
`imports?angular` | ||
`imports-loader?angular` | ||
@@ -87,3 +90,3 @@ ### Disable AMD | ||
```javascript | ||
imports?define=>false | ||
imports-loader?define=>false | ||
``` | ||
@@ -90,0 +93,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
5805
58
94
2
1
+ Addedsource-map@0.5.7(transitive)
- Removedamdefine@1.0.1(transitive)
- Removedsource-map@0.1.43(transitive)
Updatedloader-utils@^0.2.16
Updatedsource-map@^0.5.6