imports-loader
Advanced tools
Comparing version 1.2.0 to 2.0.0
@@ -5,2 +5,9 @@ # Changelog | ||
## [2.0.0](https://github.com/webpack-contrib/imports-loader/compare/v1.2.0...v2.0.0) (2021-02-01) | ||
### ⚠ BREAKING CHANGES | ||
* minimum supported `webpack` version is `5` | ||
* inline syntax was changed: `[]` is no longer supported (i.e. `imports-loader?imports[]=default|jquery|$&imports[]=angular!./example.js`), please use `,` comma separator (i.e. `imports-loader?imports=default|jquery|$,angular!./example.js`) | ||
## [1.2.0](https://github.com/webpack-contrib/imports-loader/compare/v1.1.0...v1.2.0) (2020-10-07) | ||
@@ -7,0 +14,0 @@ |
@@ -10,6 +10,2 @@ "use strict"; | ||
var _loaderUtils = require("loader-utils"); | ||
var _schemaUtils = require("schema-utils"); | ||
var _options = _interopRequireDefault(require("./options.json")); | ||
@@ -28,7 +24,3 @@ | ||
function loader(content, sourceMap) { | ||
const options = (0, _loaderUtils.getOptions)(this); | ||
(0, _schemaUtils.validate)(_options.default, options, { | ||
name: 'Imports Loader', | ||
baseDataPath: 'options' | ||
}); | ||
const options = this.getOptions(_options.default); | ||
const type = options.type || 'module'; | ||
@@ -35,0 +27,0 @@ const callback = this.async(); |
{ | ||
"title": "Imports Loader options", | ||
"definitions": { | ||
@@ -56,2 +57,6 @@ "ImportItemString": { | ||
{ | ||
"type": "string", | ||
"minLength": 1 | ||
}, | ||
{ | ||
"$ref": "#/definitions/ImportItem" | ||
@@ -58,0 +63,0 @@ }, |
@@ -132,7 +132,8 @@ "use strict"; | ||
let result; | ||
const importItems = typeof imports === 'string' && imports.includes(',') ? imports.split(',') : imports; | ||
if (typeof imports === 'string') { | ||
result = [resolveImports(type, imports)]; | ||
if (typeof importItems === 'string') { | ||
result = [resolveImports(type, importItems)]; | ||
} else { | ||
result = [].concat(imports).map(item => resolveImports(type, item)); | ||
result = [].concat(importItems).map(item => resolveImports(type, item)); | ||
} | ||
@@ -144,3 +145,3 @@ | ||
if (duplicates.length > 0) { | ||
throw new Error(`Duplicate ${duplicates.map(identifier => `"${identifier.value}" (as "${identifier.type}")`).join(', ')} identifiers found in "\n${JSON.stringify(imports, null, ' ')}\n" value`); | ||
throw new Error(`Duplicate ${duplicates.map(identifier => `"${identifier.value}" (as "${identifier.type}")`).join(', ')} identifiers found in "\n${JSON.stringify(importItems, null, ' ')}\n" value`); | ||
} | ||
@@ -147,0 +148,0 @@ |
{ | ||
"name": "imports-loader", | ||
"version": "1.2.0", | ||
"version": "2.0.0", | ||
"description": "imports loader module for webpack", | ||
@@ -41,7 +41,6 @@ "license": "MIT", | ||
"peerDependencies": { | ||
"webpack": "^4.0.0 || ^5.0.0" | ||
"webpack": "^5.0.0" | ||
}, | ||
"dependencies": { | ||
"loader-utils": "^2.0.0", | ||
"schema-utils": "^3.0.0", | ||
"source-map": "^0.6.1", | ||
@@ -51,5 +50,5 @@ "strip-comments": "^2.0.1" | ||
"devDependencies": { | ||
"@babel/cli": "^7.11.6", | ||
"@babel/core": "^7.11.6", | ||
"@babel/preset-env": "^7.11.5", | ||
"@babel/cli": "^7.12.10", | ||
"@babel/core": "^7.12.10", | ||
"@babel/preset-env": "^7.12.11", | ||
"@commitlint/cli": "^11.0.0", | ||
@@ -59,18 +58,18 @@ "@commitlint/config-conventional": "^11.0.0", | ||
"@webpack-contrib/eslint-config-webpack": "^3.0.0", | ||
"babel-jest": "^26.5.2", | ||
"babel-loader": "^8.1.0", | ||
"cross-env": "^7.0.2", | ||
"babel-jest": "^26.6.3", | ||
"babel-loader": "^8.2.2", | ||
"cross-env": "^7.0.3", | ||
"del": "^6.0.0", | ||
"del-cli": "^3.0.1", | ||
"eslint": "^7.10.0", | ||
"eslint-config-prettier": "^6.12.0", | ||
"eslint": "^7.17.0", | ||
"eslint-config-prettier": "^7.2.0", | ||
"eslint-plugin-import": "^2.22.1", | ||
"husky": "^4.3.0", | ||
"jest": "^26.5.2", | ||
"lint-staged": "^10.4.0", | ||
"husky": "^4.3.7", | ||
"jest": "^26.6.3", | ||
"lint-staged": "^10.5.3", | ||
"memfs": "^3.2.0", | ||
"npm-run-all": "^4.1.5", | ||
"prettier": "^2.1.2", | ||
"standard-version": "^9.0.0", | ||
"webpack": "^4.44.2" | ||
"prettier": "^2.2.1", | ||
"standard-version": "^9.1.0", | ||
"webpack": "^5.13.0" | ||
}, | ||
@@ -77,0 +76,0 @@ "keywords": [ |
@@ -71,3 +71,3 @@ <div align="center"> | ||
```js | ||
import myLib from 'imports-loader?imports[]=default|jquery|$&imports[]=angular!./example.js'; | ||
import myLib from 'imports-loader?imports=default|jquery|$,angular!./example.js'; | ||
// `|` is separator in a query string, equivalently `default|jquery|$` and `angular` | ||
@@ -85,3 +85,3 @@ // Adds the following code to the beginning of example.js: | ||
```js | ||
import myLib from 'imports-loader?imports[]=named|library|myMethod&imports[]=angular!./example.js'; | ||
import myLib from 'imports-loader?imports=named|library|myMethod,angular!./example.js'; | ||
// `|` is separator in a query string, equivalently `named|library|myMethod` and `angular` | ||
@@ -99,3 +99,3 @@ // Adds the following code to the beginning of example.js: | ||
```js | ||
const myLib = require(`imports-loader?type=commonjs&imports[]=single|jquery|$&imports[]=angular!./example.js`); | ||
const myLib = require(`imports-loader?type=commonjs&imports=single|jquery|$,angular!./example.js`); | ||
// `|` is separator in a query string, equivalently `single|jquery|$` and `angular` | ||
@@ -113,3 +113,3 @@ // Adds the following code to the beginning of example.js: | ||
```js | ||
const myLib = require(`imports-loader?type=commonjs&imports=single|myLib|myMethod&&wrapper=window&!./example.js`); | ||
const myLib = require(`imports-loader?type=commonjs&imports=single|myLib|myMethod&wrapper=window&!./example.js`); | ||
// `|` is separator in a query string, equivalently `single|myLib|myMethod` and `angular` | ||
@@ -365,3 +365,3 @@ // Adds the following code to the example.js: | ||
type: 'commonjs', | ||
exports: 'single lib myName', | ||
imports: 'single lib myName', | ||
}, | ||
@@ -368,0 +368,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
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
36924
4
- Removedschema-utils@^3.0.0