magic-comments-loader 1.4.2 → 1.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +432 -194
- package/package.json +35 -20
- package/dist/booleanComment.js +0 -107
- package/dist/comment.js +0 -36
- package/dist/index.js +0 -13
- package/dist/loader.js +0 -33
- package/dist/package.json +0 -55
- package/dist/regexComment.js +0 -109
- package/dist/schema.js +0 -44
- package/dist/strategy.js +0 -34
- package/dist/util.js +0 -73
- package/dist/webpackChunkName.js +0 -70
- package/dist/webpackExclude.js +0 -15
- package/dist/webpackExports.js +0 -83
- package/dist/webpackIgnore.js +0 -24
- package/dist/webpackInclude.js +0 -15
- package/dist/webpackMode.js +0 -113
- package/dist/webpackPrefetch.js +0 -24
- package/dist/webpackPreload.js +0 -24
package/package.json
CHANGED
|
@@ -1,11 +1,19 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "magic-comments-loader",
|
|
3
|
-
"version": "1.
|
|
4
|
-
"description": "Add webpack magic comments to your dynamic imports
|
|
3
|
+
"version": "1.5.0",
|
|
4
|
+
"description": "Add webpack magic comments to your dynamic imports at build time",
|
|
5
5
|
"main": "dist",
|
|
6
6
|
"type": "module",
|
|
7
|
+
"exports": {
|
|
8
|
+
".": {
|
|
9
|
+
"import": "./dist/index.js",
|
|
10
|
+
"require": "./dist/cjs/index.cjs",
|
|
11
|
+
"default": "./dist/index.js"
|
|
12
|
+
},
|
|
13
|
+
"./package.json": "./package.json"
|
|
14
|
+
},
|
|
7
15
|
"engines": {
|
|
8
|
-
"node": ">=
|
|
16
|
+
"node": ">=12.17.0"
|
|
9
17
|
},
|
|
10
18
|
"repository": {
|
|
11
19
|
"type": "git",
|
|
@@ -15,10 +23,15 @@
|
|
|
15
23
|
"url": "https://github.com/morganney/magic-comments-loader/issues"
|
|
16
24
|
},
|
|
17
25
|
"scripts": {
|
|
18
|
-
"prepack": "
|
|
26
|
+
"prepack": "npm run build",
|
|
27
|
+
"build": "npm run build:esm && npm run build:cjs",
|
|
28
|
+
"build:esm": "babel src --out-dir dist",
|
|
29
|
+
"build:cjs": "BABEL_ENV=cjs babel src --out-dir dist/cjs --out-file-extension .cjs && node cjs.js",
|
|
19
30
|
"lint": "eslint . src __tests__ --ext .js,.cjs",
|
|
20
31
|
"lint:fix": "npm run lint -- --fix",
|
|
21
|
-
"test": "node --experimental-vm-modules ./node_modules/.bin/jest"
|
|
32
|
+
"test:unit": "node --experimental-vm-modules --no-warnings ./node_modules/.bin/jest",
|
|
33
|
+
"test:spec": "NODE_OPTIONS='--loader=babel-register-esm --no-warnings' BABEL_ENV=test jest -c jest.config.spec.js",
|
|
34
|
+
"test": "npm run test:unit && npm run test:spec"
|
|
22
35
|
},
|
|
23
36
|
"keywords": [
|
|
24
37
|
"webpack",
|
|
@@ -34,23 +47,25 @@
|
|
|
34
47
|
"dist"
|
|
35
48
|
],
|
|
36
49
|
"devDependencies": {
|
|
37
|
-
"@babel/cli": "^7.
|
|
38
|
-
"@babel/core": "^7.
|
|
39
|
-
"@babel/eslint-parser": "^7.
|
|
40
|
-
"@babel/preset-env": "^7.
|
|
41
|
-
"
|
|
42
|
-
"
|
|
43
|
-
"eslint
|
|
44
|
-
"eslint-
|
|
45
|
-
"eslint-plugin-
|
|
46
|
-
"
|
|
47
|
-
"
|
|
48
|
-
"
|
|
49
|
-
"
|
|
50
|
+
"@babel/cli": "^7.22.5",
|
|
51
|
+
"@babel/core": "^7.22.5",
|
|
52
|
+
"@babel/eslint-parser": "^7.22.5",
|
|
53
|
+
"@babel/preset-env": "^7.22.5",
|
|
54
|
+
"babel-register-esm": "^1.2.4",
|
|
55
|
+
"codecov": "^4.0.0-0",
|
|
56
|
+
"eslint": "^8.42.0",
|
|
57
|
+
"eslint-config-prettier": "^8.8.0",
|
|
58
|
+
"eslint-plugin-jest": "^27.2.1",
|
|
59
|
+
"eslint-plugin-prettier": "^4.2.0",
|
|
60
|
+
"jest": "^29.5.0",
|
|
61
|
+
"jest-light-runner": "^0.5.0",
|
|
62
|
+
"memfs": "^4.0.0",
|
|
63
|
+
"prettier": "^2.8.8",
|
|
64
|
+
"webpack": "^5.87.0"
|
|
50
65
|
},
|
|
51
66
|
"dependencies": {
|
|
52
|
-
"loader-utils": "^2.
|
|
67
|
+
"loader-utils": "^3.2.1",
|
|
53
68
|
"micromatch": "^4.0.4",
|
|
54
|
-
"schema-utils": "^
|
|
69
|
+
"schema-utils": "^4.1.0"
|
|
55
70
|
}
|
|
56
71
|
}
|
package/dist/booleanComment.js
DELETED
|
@@ -1,107 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.getConfig = exports.getSchema = void 0;
|
|
7
|
-
|
|
8
|
-
var _util = require("./util");
|
|
9
|
-
|
|
10
|
-
const defaultSchema = {
|
|
11
|
-
type: 'object',
|
|
12
|
-
properties: {
|
|
13
|
-
active: {
|
|
14
|
-
oneOf: [{
|
|
15
|
-
type: 'boolean'
|
|
16
|
-
}, {
|
|
17
|
-
instanceof: 'Function'
|
|
18
|
-
}]
|
|
19
|
-
}
|
|
20
|
-
},
|
|
21
|
-
additionalProperties: false
|
|
22
|
-
};
|
|
23
|
-
|
|
24
|
-
const getSchema = (commentSchema = defaultSchema) => ({
|
|
25
|
-
oneOf: [{
|
|
26
|
-
type: 'boolean'
|
|
27
|
-
}, {
|
|
28
|
-
type: 'string'
|
|
29
|
-
}, {
|
|
30
|
-
type: 'array',
|
|
31
|
-
items: {
|
|
32
|
-
type: 'string'
|
|
33
|
-
}
|
|
34
|
-
}, {
|
|
35
|
-
instanceof: 'Function'
|
|
36
|
-
}, {
|
|
37
|
-
type: 'object',
|
|
38
|
-
properties: {
|
|
39
|
-
config: commentSchema,
|
|
40
|
-
overrides: (0, _util.getOverrideSchema)(commentSchema)
|
|
41
|
-
},
|
|
42
|
-
required: ['config'],
|
|
43
|
-
additionalProperties: false
|
|
44
|
-
}]
|
|
45
|
-
});
|
|
46
|
-
|
|
47
|
-
exports.getSchema = getSchema;
|
|
48
|
-
|
|
49
|
-
const getConfig = (value, match, filepath, importPath, defaultConfig = {
|
|
50
|
-
active: true
|
|
51
|
-
}) => {
|
|
52
|
-
const path = match === 'import' ? importPath.replace(_util.importPrefix, '') : filepath;
|
|
53
|
-
|
|
54
|
-
if (value === true) {
|
|
55
|
-
return defaultConfig;
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
if (value === false) {
|
|
59
|
-
return { ...defaultConfig,
|
|
60
|
-
active: false
|
|
61
|
-
};
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
if (Array.isArray(value) || typeof value === 'string') {
|
|
65
|
-
return { ...defaultConfig,
|
|
66
|
-
active: (0, _util.pathIsMatch)(path, value)
|
|
67
|
-
};
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
if (typeof value === 'function') {
|
|
71
|
-
const configValue = value(filepath, importPath);
|
|
72
|
-
|
|
73
|
-
if (configValue) {
|
|
74
|
-
return { ...defaultConfig,
|
|
75
|
-
active: true,
|
|
76
|
-
dynamic: configValue
|
|
77
|
-
};
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
return { ...defaultConfig,
|
|
81
|
-
active: false
|
|
82
|
-
};
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
let config = { ...defaultConfig,
|
|
86
|
-
...value.config
|
|
87
|
-
};
|
|
88
|
-
|
|
89
|
-
if (Array.isArray(value.overrides)) {
|
|
90
|
-
const {
|
|
91
|
-
overrides
|
|
92
|
-
} = value;
|
|
93
|
-
const length = overrides.length;
|
|
94
|
-
|
|
95
|
-
for (let i = 0; i < length; i++) {
|
|
96
|
-
if ((0, _util.pathIsMatch)(path, overrides[i].files)) {
|
|
97
|
-
return { ...config,
|
|
98
|
-
...overrides[i].config
|
|
99
|
-
};
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
return config;
|
|
105
|
-
};
|
|
106
|
-
|
|
107
|
-
exports.getConfig = getConfig;
|
package/dist/comment.js
DELETED
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.getCommenter = void 0;
|
|
7
|
-
|
|
8
|
-
var _strategy = require("./strategy.js");
|
|
9
|
-
|
|
10
|
-
const getCommenter = (filepath, options, logger = console) => (rgxMatch, capturedImportPath) => {
|
|
11
|
-
const importPath = capturedImportPath.trim();
|
|
12
|
-
const bareImportPath = importPath.replace(/['"`]/g, '');
|
|
13
|
-
const {
|
|
14
|
-
verbose,
|
|
15
|
-
match,
|
|
16
|
-
...magicCommentOptions
|
|
17
|
-
} = options;
|
|
18
|
-
const magicComment = Object.keys(magicCommentOptions).map(key => {
|
|
19
|
-
const option = magicCommentOptions[key];
|
|
20
|
-
|
|
21
|
-
if (option) {
|
|
22
|
-
return _strategy.commentFor[key](filepath, bareImportPath, option, match);
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
return null;
|
|
26
|
-
}).filter(comment => comment);
|
|
27
|
-
const magicImport = rgxMatch.replace(capturedImportPath, magicComment.length > 0 ? `/* ${magicComment.join(', ')} */ ${importPath}` : `${importPath}`);
|
|
28
|
-
|
|
29
|
-
if (verbose) {
|
|
30
|
-
logger.info('[MCL]', `${filepath} : ${magicImport}`);
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
return magicImport;
|
|
34
|
-
};
|
|
35
|
-
|
|
36
|
-
exports.getCommenter = getCommenter;
|
package/dist/index.js
DELETED
package/dist/loader.js
DELETED
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.loader = void 0;
|
|
7
|
-
|
|
8
|
-
var _loaderUtils = require("loader-utils");
|
|
9
|
-
|
|
10
|
-
var _schemaUtils = require("schema-utils");
|
|
11
|
-
|
|
12
|
-
var _schema = require("./schema.js");
|
|
13
|
-
|
|
14
|
-
var _comment = require("./comment.js");
|
|
15
|
-
|
|
16
|
-
var _util = require("./util.js");
|
|
17
|
-
|
|
18
|
-
const loader = function (source, map, meta) {
|
|
19
|
-
const options = (0, _loaderUtils.getOptions)(this);
|
|
20
|
-
const optionKeys = Object.keys(options);
|
|
21
|
-
const logger = this.getLogger('MCL');
|
|
22
|
-
(0, _schemaUtils.validate)(_schema.schema, options, {
|
|
23
|
-
name: 'magic-comments-loader'
|
|
24
|
-
});
|
|
25
|
-
const filepath = this.utils.contextify(this.rootContext, this.resourcePath);
|
|
26
|
-
const magicComments = (0, _comment.getCommenter)(filepath.replace(/^\.\/?/, ''), optionKeys.length > 0 ? options : {
|
|
27
|
-
match: 'module',
|
|
28
|
-
webpackChunkName: true
|
|
29
|
-
}, logger);
|
|
30
|
-
this.callback(null, source.replace(_util.dynamicImportsWithoutComments, magicComments), map, meta);
|
|
31
|
-
};
|
|
32
|
-
|
|
33
|
-
exports.loader = loader;
|
package/dist/package.json
DELETED
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "magic-comments-loader",
|
|
3
|
-
"version": "1.4.2",
|
|
4
|
-
"description": "Add webpack magic comments to your dynamic imports during build time",
|
|
5
|
-
"main": "index.js",
|
|
6
|
-
"engines": {
|
|
7
|
-
"node": ">=10.3.0"
|
|
8
|
-
},
|
|
9
|
-
"repository": {
|
|
10
|
-
"type": "git",
|
|
11
|
-
"url": "https://github.com/morganney/magic-comments-loader.git"
|
|
12
|
-
},
|
|
13
|
-
"bugs": {
|
|
14
|
-
"url": "https://github.com/morganney/magic-comments-loader/issues"
|
|
15
|
-
},
|
|
16
|
-
"scripts": {
|
|
17
|
-
"prepack": "node --experimental-json-modules ./prepack.js",
|
|
18
|
-
"lint": "eslint . src __tests__ --ext .js,.cjs",
|
|
19
|
-
"lint:fix": "npm run lint -- --fix",
|
|
20
|
-
"test": "node --experimental-vm-modules ./node_modules/.bin/jest"
|
|
21
|
-
},
|
|
22
|
-
"keywords": [
|
|
23
|
-
"webpack",
|
|
24
|
-
"magic",
|
|
25
|
-
"comments",
|
|
26
|
-
"loader",
|
|
27
|
-
"dynamic",
|
|
28
|
-
"import"
|
|
29
|
-
],
|
|
30
|
-
"author": "Morgan Ney <morganney@gmail.com>",
|
|
31
|
-
"license": "MIT",
|
|
32
|
-
"files": [
|
|
33
|
-
"dist"
|
|
34
|
-
],
|
|
35
|
-
"devDependencies": {
|
|
36
|
-
"@babel/cli": "^7.14.8",
|
|
37
|
-
"@babel/core": "^7.15.0",
|
|
38
|
-
"@babel/eslint-parser": "^7.15.4",
|
|
39
|
-
"@babel/preset-env": "^7.15.0",
|
|
40
|
-
"codecov": "^3.8.3",
|
|
41
|
-
"eslint": "^7.32.0",
|
|
42
|
-
"eslint-config-prettier": "^8.3.0",
|
|
43
|
-
"eslint-plugin-jest": "^24.4.0",
|
|
44
|
-
"eslint-plugin-prettier": "^4.0.0",
|
|
45
|
-
"jest": "^27.1.1",
|
|
46
|
-
"memfs": "^3.2.4",
|
|
47
|
-
"prettier": "^2.3.2",
|
|
48
|
-
"webpack": "^5.52.0"
|
|
49
|
-
},
|
|
50
|
-
"dependencies": {
|
|
51
|
-
"loader-utils": "^2.0.0",
|
|
52
|
-
"micromatch": "^4.0.4",
|
|
53
|
-
"schema-utils": "^3.1.1"
|
|
54
|
-
}
|
|
55
|
-
}
|
package/dist/regexComment.js
DELETED
|
@@ -1,109 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.getRegexComment = void 0;
|
|
7
|
-
|
|
8
|
-
var _util = require("./util");
|
|
9
|
-
|
|
10
|
-
const getRegexComment = type => {
|
|
11
|
-
const configSchema = {
|
|
12
|
-
type: 'object',
|
|
13
|
-
properties: {
|
|
14
|
-
active: {
|
|
15
|
-
oneOf: [{
|
|
16
|
-
type: 'boolean'
|
|
17
|
-
}, {
|
|
18
|
-
instanceof: 'Function'
|
|
19
|
-
}]
|
|
20
|
-
},
|
|
21
|
-
include: {
|
|
22
|
-
oneOf: [{
|
|
23
|
-
instanceof: 'Function'
|
|
24
|
-
}, {
|
|
25
|
-
instanceof: 'RegExp'
|
|
26
|
-
}]
|
|
27
|
-
}
|
|
28
|
-
},
|
|
29
|
-
required: [type],
|
|
30
|
-
additionalProperties: false
|
|
31
|
-
};
|
|
32
|
-
const schema = {
|
|
33
|
-
oneOf: [{
|
|
34
|
-
instanceof: 'Function'
|
|
35
|
-
}, {
|
|
36
|
-
type: 'object',
|
|
37
|
-
properties: {
|
|
38
|
-
config: configSchema,
|
|
39
|
-
overrides: (0, _util.getOverrideSchema)(configSchema)
|
|
40
|
-
},
|
|
41
|
-
required: ['config'],
|
|
42
|
-
additionalProperties: false
|
|
43
|
-
}]
|
|
44
|
-
};
|
|
45
|
-
|
|
46
|
-
const getConfig = (value, filepath) => {
|
|
47
|
-
if (typeof value === 'function') {
|
|
48
|
-
return {
|
|
49
|
-
active: true,
|
|
50
|
-
[type]: value
|
|
51
|
-
};
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
let config = {
|
|
55
|
-
active: true,
|
|
56
|
-
...value.config
|
|
57
|
-
};
|
|
58
|
-
|
|
59
|
-
if (Array.isArray(value.overrides)) {
|
|
60
|
-
config = (0, _util.getOverrideConfig)(value.overrides, filepath, config);
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
return config;
|
|
64
|
-
};
|
|
65
|
-
|
|
66
|
-
const comment = (filepath, importPath, value) => {
|
|
67
|
-
const config = getConfig(value, filepath);
|
|
68
|
-
const isActive = typeof config.active === 'function' ? config.active(filepath, importPath) : config.active;
|
|
69
|
-
let regex = null;
|
|
70
|
-
|
|
71
|
-
if (!isActive) {
|
|
72
|
-
return '';
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
if (typeof config[type] === 'function') {
|
|
76
|
-
regex = config[type](filepath, importPath);
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
if (config[type] instanceof RegExp) {
|
|
80
|
-
regex = config[type];
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
if (!(regex instanceof RegExp)) {
|
|
84
|
-
return '';
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
const source = regex.source;
|
|
88
|
-
const typeName = `${type[0].toUpperCase()}${type.slice(1)}`;
|
|
89
|
-
/**
|
|
90
|
-
* Check if the provided RegExp ends in one or more '*'
|
|
91
|
-
* and if so be sure to escape the ending '/' in the
|
|
92
|
-
* comments regular expression so as not to break the
|
|
93
|
-
* comment and cause a SyntaxError.
|
|
94
|
-
*/
|
|
95
|
-
|
|
96
|
-
if (/(\*+)$/.test(source)) {
|
|
97
|
-
return `webpack${typeName}: /${source}\\/${regex.flags}`;
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
return `webpack${typeName}: /${source}/${regex.flags}`;
|
|
101
|
-
};
|
|
102
|
-
|
|
103
|
-
return {
|
|
104
|
-
comment,
|
|
105
|
-
schema
|
|
106
|
-
};
|
|
107
|
-
};
|
|
108
|
-
|
|
109
|
-
exports.getRegexComment = getRegexComment;
|
package/dist/schema.js
DELETED
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.schema = void 0;
|
|
7
|
-
|
|
8
|
-
var _webpackChunkName = require("./webpackChunkName.js");
|
|
9
|
-
|
|
10
|
-
var _webpackMode = require("./webpackMode.js");
|
|
11
|
-
|
|
12
|
-
var _webpackIgnore = require("./webpackIgnore.js");
|
|
13
|
-
|
|
14
|
-
var _webpackPrefetch = require("./webpackPrefetch.js");
|
|
15
|
-
|
|
16
|
-
var _webpackPreload = require("./webpackPreload.js");
|
|
17
|
-
|
|
18
|
-
var _webpackExports = require("./webpackExports.js");
|
|
19
|
-
|
|
20
|
-
var _webpackInclude = require("./webpackInclude.js");
|
|
21
|
-
|
|
22
|
-
var _webpackExclude = require("./webpackExclude.js");
|
|
23
|
-
|
|
24
|
-
const schema = {
|
|
25
|
-
type: 'object',
|
|
26
|
-
properties: {
|
|
27
|
-
verbose: {
|
|
28
|
-
type: 'boolean'
|
|
29
|
-
},
|
|
30
|
-
match: {
|
|
31
|
-
enum: ['module', 'import']
|
|
32
|
-
},
|
|
33
|
-
webpackChunkName: _webpackChunkName.schema,
|
|
34
|
-
webpackMode: _webpackMode.schema,
|
|
35
|
-
webpackIgnore: _webpackIgnore.schema,
|
|
36
|
-
webpackPrefetch: _webpackPrefetch.schema,
|
|
37
|
-
webpackPreload: _webpackPreload.schema,
|
|
38
|
-
webpackExports: _webpackExports.schema,
|
|
39
|
-
webpackInclude: _webpackInclude.schema,
|
|
40
|
-
webpackExclude: _webpackExclude.schema
|
|
41
|
-
},
|
|
42
|
-
additionalProperties: false
|
|
43
|
-
};
|
|
44
|
-
exports.schema = schema;
|
package/dist/strategy.js
DELETED
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.commentFor = void 0;
|
|
7
|
-
|
|
8
|
-
var _webpackChunkName = require("./webpackChunkName.js");
|
|
9
|
-
|
|
10
|
-
var _webpackMode = require("./webpackMode.js");
|
|
11
|
-
|
|
12
|
-
var _webpackIgnore = require("./webpackIgnore.js");
|
|
13
|
-
|
|
14
|
-
var _webpackPreload = require("./webpackPreload.js");
|
|
15
|
-
|
|
16
|
-
var _webpackPrefetch = require("./webpackPrefetch.js");
|
|
17
|
-
|
|
18
|
-
var _webpackExports = require("./webpackExports.js");
|
|
19
|
-
|
|
20
|
-
var _webpackInclude = require("./webpackInclude.js");
|
|
21
|
-
|
|
22
|
-
var _webpackExclude = require("./webpackExclude.js");
|
|
23
|
-
|
|
24
|
-
const commentFor = {
|
|
25
|
-
webpackChunkName: _webpackChunkName.webpackChunkName,
|
|
26
|
-
webpackMode: _webpackMode.webpackMode,
|
|
27
|
-
webpackIgnore: _webpackIgnore.webpackIgnore,
|
|
28
|
-
webpackPreload: _webpackPreload.webpackPreload,
|
|
29
|
-
webpackPrefetch: _webpackPrefetch.webpackPrefetch,
|
|
30
|
-
webpackExports: _webpackExports.webpackExports,
|
|
31
|
-
webpackInclude: _webpackInclude.webpackInclude,
|
|
32
|
-
webpackExclude: _webpackExclude.webpackExclude
|
|
33
|
-
};
|
|
34
|
-
exports.commentFor = commentFor;
|
package/dist/util.js
DELETED
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.dynamicImportsWithoutComments = exports.importPrefix = exports.pathIsMatch = exports.getOverrideSchema = exports.getOverrideConfig = void 0;
|
|
7
|
-
|
|
8
|
-
var _micromatch = _interopRequireDefault(require("micromatch"));
|
|
9
|
-
|
|
10
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
11
|
-
|
|
12
|
-
const pathIsMatch = (path, files) => {
|
|
13
|
-
const globs = [];
|
|
14
|
-
const notglobs = [];
|
|
15
|
-
|
|
16
|
-
if (!Array.isArray(files)) {
|
|
17
|
-
files = [files];
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
files.forEach(file => {
|
|
21
|
-
if (/^!/.test(file)) {
|
|
22
|
-
notglobs.push(file);
|
|
23
|
-
} else {
|
|
24
|
-
globs.push(file);
|
|
25
|
-
}
|
|
26
|
-
});
|
|
27
|
-
return (globs.length === 0 || globs.some(glob => _micromatch.default.isMatch(path, glob))) && notglobs.every(notglob => _micromatch.default.isMatch(path, notglob));
|
|
28
|
-
};
|
|
29
|
-
|
|
30
|
-
exports.pathIsMatch = pathIsMatch;
|
|
31
|
-
|
|
32
|
-
const getOverrideSchema = commentSchema => ({
|
|
33
|
-
type: 'array',
|
|
34
|
-
items: {
|
|
35
|
-
type: 'object',
|
|
36
|
-
properties: {
|
|
37
|
-
config: commentSchema,
|
|
38
|
-
files: {
|
|
39
|
-
oneOf: [{
|
|
40
|
-
type: 'string'
|
|
41
|
-
}, {
|
|
42
|
-
type: 'array',
|
|
43
|
-
items: {
|
|
44
|
-
type: 'string'
|
|
45
|
-
}
|
|
46
|
-
}]
|
|
47
|
-
}
|
|
48
|
-
},
|
|
49
|
-
additionalProperties: false
|
|
50
|
-
}
|
|
51
|
-
});
|
|
52
|
-
|
|
53
|
-
exports.getOverrideSchema = getOverrideSchema;
|
|
54
|
-
|
|
55
|
-
const getOverrideConfig = (overrides, filepath, config) => {
|
|
56
|
-
const length = overrides.length;
|
|
57
|
-
|
|
58
|
-
for (let i = 0; i < length; i++) {
|
|
59
|
-
if (pathIsMatch(filepath, overrides[i].files)) {
|
|
60
|
-
return { ...config,
|
|
61
|
-
...overrides[i].config
|
|
62
|
-
};
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
return config;
|
|
67
|
-
};
|
|
68
|
-
|
|
69
|
-
exports.getOverrideConfig = getOverrideConfig;
|
|
70
|
-
const importPrefix = /^(?:(\.{1,2}\/)+)|^\/|^.+:\/\/\/?[.-\w]+\//;
|
|
71
|
-
exports.importPrefix = importPrefix;
|
|
72
|
-
const dynamicImportsWithoutComments = /(?<![\w.]|#!|\*[\s\w]*?|\/\/\s*|['"`][^)$]*)import\s*\((?!\s*\/\*)(?<path>\s*?['"`][^)]+['"`]\s*)\)(?!\s*?\*\/)/g;
|
|
73
|
-
exports.dynamicImportsWithoutComments = dynamicImportsWithoutComments;
|
package/dist/webpackChunkName.js
DELETED
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.schema = exports.webpackChunkName = void 0;
|
|
7
|
-
|
|
8
|
-
var _path = require("path");
|
|
9
|
-
|
|
10
|
-
var _booleanComment = require("./booleanComment.js");
|
|
11
|
-
|
|
12
|
-
const schema = (0, _booleanComment.getSchema)({
|
|
13
|
-
type: 'object',
|
|
14
|
-
properties: {
|
|
15
|
-
active: {
|
|
16
|
-
oneOf: [{
|
|
17
|
-
type: 'boolean'
|
|
18
|
-
}, {
|
|
19
|
-
instanceof: 'Function'
|
|
20
|
-
}]
|
|
21
|
-
},
|
|
22
|
-
basename: {
|
|
23
|
-
type: 'boolean'
|
|
24
|
-
}
|
|
25
|
-
},
|
|
26
|
-
additionalProperties: false
|
|
27
|
-
});
|
|
28
|
-
exports.schema = schema;
|
|
29
|
-
|
|
30
|
-
const webpackChunkName = (filepath, importPath, value, match) => {
|
|
31
|
-
const config = (0, _booleanComment.getConfig)(value, match, filepath, importPath, {
|
|
32
|
-
active: true,
|
|
33
|
-
basename: false
|
|
34
|
-
});
|
|
35
|
-
const isActive = typeof config.active === 'function' ? config.active(filepath, importPath) : config.active;
|
|
36
|
-
|
|
37
|
-
if (!isActive) {
|
|
38
|
-
return '';
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
if (typeof config.dynamic === 'string') {
|
|
42
|
-
return `webpackChunkName: "${config.dynamic}"`;
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
const {
|
|
46
|
-
basename
|
|
47
|
-
} = config;
|
|
48
|
-
const {
|
|
49
|
-
dir,
|
|
50
|
-
name
|
|
51
|
-
} = (0, _path.parse)(importPath);
|
|
52
|
-
const segments = `${dir}/${name}`.split('/').filter(segment => /\w/.test(segment));
|
|
53
|
-
const chunkName = basename ? name : segments.reduce((prev, curr) => {
|
|
54
|
-
/**
|
|
55
|
-
* Check for dynamic expressions in imports.
|
|
56
|
-
* If it exists, it has to be at least the second path
|
|
57
|
-
* segment or greater, i.e. can not be the first.
|
|
58
|
-
*
|
|
59
|
-
* @see https://webpack.js.org/api/module-methods/#dynamic-expressions-in-import
|
|
60
|
-
*/
|
|
61
|
-
if (/^\${/.test(curr)) {
|
|
62
|
-
return prev ? `${prev}-[request]` : '[request]';
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
return prev ? `${prev}-${curr}` : curr;
|
|
66
|
-
}, '');
|
|
67
|
-
return `webpackChunkName: "${chunkName}"`;
|
|
68
|
-
};
|
|
69
|
-
|
|
70
|
-
exports.webpackChunkName = webpackChunkName;
|
package/dist/webpackExclude.js
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.schema = exports.webpackExclude = void 0;
|
|
7
|
-
|
|
8
|
-
var _regexComment = require("./regexComment.js");
|
|
9
|
-
|
|
10
|
-
const {
|
|
11
|
-
comment: webpackExclude,
|
|
12
|
-
schema
|
|
13
|
-
} = (0, _regexComment.getRegexComment)('exclude');
|
|
14
|
-
exports.schema = schema;
|
|
15
|
-
exports.webpackExclude = webpackExclude;
|