weboptimizer 2.0.1491 → 2.0.1492
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/browser.js +7 -5
- package/configurator.js +12 -12
- package/declarations.d.ts +3 -7
- package/ejsLoader.d.ts +1 -1
- package/ejsLoader.js +24 -23
- package/eslint.config.d.ts +2 -2
- package/eslint.config.mjs +39 -18
- package/helper.d.ts +242 -261
- package/helper.js +830 -894
- package/index.js +15 -13
- package/jestEnvironmentBrowser.js +3 -1
- package/jestSetup.js +2 -0
- package/package.json +23 -42
- package/plugins/HTMLTransformation.js +4 -3
- package/plugins/InPlaceAssetsIntoHTML.js +1 -1
- package/tsconfig.json +3 -1
- package/type.d.ts +11 -10
- package/webpackConfigurator.js +17 -15
package/index.js
CHANGED
|
@@ -36,7 +36,7 @@ var _globAll = require("glob-all");
|
|
|
36
36
|
var _path = _interopRequireWildcard(require("path"));
|
|
37
37
|
var _rimraf = require("rimraf");
|
|
38
38
|
var _configurator = require("./configurator");
|
|
39
|
-
var _helper =
|
|
39
|
+
var _helper = require("./helper");
|
|
40
40
|
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
|
|
41
41
|
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { "default": e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n["default"] = e, t && t.set(e, n), n; }
|
|
42
42
|
function _createForOfIteratorHelper(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (!t) { if (Array.isArray(r) || (t = _unsupportedIterableToArray(r)) || e && r && "number" == typeof r.length) { t && (r = t); var _n = 0, F = function F() {}; return { s: F, n: function n() { return _n >= r.length ? { done: !0 } : { done: !1, value: r[_n++] }; }, e: function e(r) { throw r; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var o, a = !0, u = !1; return { s: function s() { t = t.call(r); }, n: function n() { var r = t.next(); return a = r.done, r; }, e: function e(r) { u = !0, o = r; }, f: function f() { try { a || null == t["return"] || t["return"](); } finally { if (u) throw o; } } }; }
|
|
@@ -96,13 +96,13 @@ var main = function main(context) {
|
|
|
96
96
|
};
|
|
97
97
|
if (configuration.givenCommandLineArguments.length > 3 && (0, _clientnode.parseEncodedObject)(configuration.givenCommandLineArguments[configuration.givenCommandLineArguments.length - 1], configuration, 'configuration')) configuration.givenCommandLineArguments.pop();
|
|
98
98
|
count = 0;
|
|
99
|
-
filePath = (0, _path.resolve)(configuration.path.context, ".dynamicConfiguration-".concat(count, ".json"));
|
|
99
|
+
filePath = (0, _path.resolve)(configuration.path.context, ".dynamicConfiguration-".concat(String(count), ".json"));
|
|
100
100
|
case 15:
|
|
101
|
-
if (!
|
|
101
|
+
if (!(count < _clientnode.MAXIMAL_NUMBER_OF_ITERATIONS.value)) {
|
|
102
102
|
_context3.next = 24;
|
|
103
103
|
break;
|
|
104
104
|
}
|
|
105
|
-
filePath = (0, _path.resolve)(configuration.path.context, ".dynamicConfiguration-".concat(count, ".json"));
|
|
105
|
+
filePath = (0, _path.resolve)(configuration.path.context, ".dynamicConfiguration-".concat(String(count), ".json"));
|
|
106
106
|
_context3.next = 19;
|
|
107
107
|
return (0, _clientnode.isFile)(filePath);
|
|
108
108
|
case 19:
|
|
@@ -112,7 +112,7 @@ var main = function main(context) {
|
|
|
112
112
|
}
|
|
113
113
|
return _context3.abrupt("break", 24);
|
|
114
114
|
case 21:
|
|
115
|
-
count
|
|
115
|
+
count++;
|
|
116
116
|
_context3.next = 15;
|
|
117
117
|
break;
|
|
118
118
|
case 24:
|
|
@@ -151,7 +151,7 @@ var main = function main(context) {
|
|
|
151
151
|
return _regenerator["default"].wrap(function _callee$(_context) {
|
|
152
152
|
while (1) switch (_context.prev = _context.next) {
|
|
153
153
|
case 0:
|
|
154
|
-
if (!_helper
|
|
154
|
+
if (!(0, _helper.isFilePathInLocation)(file.path, configuration.path.ignore.concat(configuration.module.directoryNames, configuration.loader.directoryNames).map(function (filePath) {
|
|
155
155
|
return (0, _path.resolve)(configuration.path.context, filePath);
|
|
156
156
|
}).filter(function (filePath) {
|
|
157
157
|
return !configuration.path.context.startsWith(filePath);
|
|
@@ -269,7 +269,7 @@ var main = function main(context) {
|
|
|
269
269
|
case 67:
|
|
270
270
|
// endregion
|
|
271
271
|
// region handle build
|
|
272
|
-
buildConfigurations = _helper
|
|
272
|
+
buildConfigurations = (0, _helper.resolveBuildConfigurationFilePaths)(configuration.buildContext.types, configuration.path.source.asset.base, configuration.path.ignore.concat(configuration.module.directoryNames, configuration.loader.directoryNames).map(function (filePath) {
|
|
273
273
|
return (0, _path.resolve)(configuration.path.context, filePath);
|
|
274
274
|
}).filter(function (filePath) {
|
|
275
275
|
return !configuration.path.context.startsWith(filePath);
|
|
@@ -295,13 +295,13 @@ var main = function main(context) {
|
|
|
295
295
|
try {
|
|
296
296
|
for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
|
|
297
297
|
var moduleID = _step3.value;
|
|
298
|
-
var _filePath2 = _helper
|
|
298
|
+
var _filePath2 = (0, _helper.determineModuleFilePath)(moduleID, configuration.module.aliases, configuration.module.replacements.normal, {
|
|
299
299
|
file: configuration.extensions.file.internal
|
|
300
300
|
}, configuration.path.context, configuration.path.source.asset.base, configuration.path.ignore, configuration.module.directoryNames, configuration["package"].main.fileNames, configuration["package"].main.propertyNames, configuration["package"].aliasPropertyNames, configuration.encoding);
|
|
301
301
|
var type = null;
|
|
302
|
-
if (_filePath2) type = _helper
|
|
303
|
-
if (typeof type === 'string' && configuration.buildContext.types
|
|
304
|
-
var _filePath3 = _helper
|
|
302
|
+
if (_filePath2) type = (0, _helper.determineAssetType)(_filePath2, configuration.buildContext.types, configuration.path);
|
|
303
|
+
if (typeof type === 'string' && Object.prototype.hasOwnProperty.call(configuration.buildContext.types, type)) {
|
|
304
|
+
var _filePath3 = (0, _helper.renderFilePathTemplate)((0, _helper.stripLoader)(configuration.files.compose.javaScript), {
|
|
305
305
|
'[name]': chunkName
|
|
306
306
|
});
|
|
307
307
|
/*
|
|
@@ -347,6 +347,8 @@ var main = function main(context) {
|
|
|
347
347
|
NOTE: Take current weboptimizer's dependencies into
|
|
348
348
|
account.
|
|
349
349
|
*/
|
|
350
|
+
if (!childProcessOptions.env) childProcessOptions.env = {};
|
|
351
|
+
if (typeof childProcessOptions.env.PATH !== 'string') childProcessOptions.env.PATH = '';
|
|
350
352
|
childProcessOptions.env.PATH += ":".concat(webOptimizerPath, "/node_modules/.bin");
|
|
351
353
|
var childProcess = (0, _child_process.spawn)(configuration.commandLine.build.command, commandLineArguments, childProcessOptions);
|
|
352
354
|
var copyAdditionalFilesAndTidyUp = function copyAdditionalFilesAndTidyUp() {
|
|
@@ -398,7 +400,7 @@ var main = function main(context) {
|
|
|
398
400
|
}
|
|
399
401
|
// Perform all file specific preprocessing stuff.
|
|
400
402
|
testModuleFilePaths = [];
|
|
401
|
-
if ((0, _clientnode.isPlainObject)(configuration['test:browser'].injection) && configuration['test:browser'].injection.entry) testModuleFilePaths = _helper
|
|
403
|
+
if ((0, _clientnode.isPlainObject)(configuration['test:browser'].injection) && configuration['test:browser'].injection.entry) testModuleFilePaths = (0, _helper.determineModuleLocations)(configuration['test:browser'].injection.entry, configuration.module.aliases, configuration.module.replacements.normal, {
|
|
402
404
|
file: configuration.extensions.file.internal
|
|
403
405
|
}, configuration.path.context, configuration.path.source.asset.base, configuration.path.ignore).filePaths;
|
|
404
406
|
_iterator7 = _createForOfIteratorHelper(buildConfigurations);
|
|
@@ -442,7 +444,7 @@ var main = function main(context) {
|
|
|
442
444
|
return [(0, _clientnode.handleChildProcess)((0, _child_process.exec)(evaluated.result, _objectSpread({
|
|
443
445
|
encoding: configuration.encoding
|
|
444
446
|
}, processOptions), function (error) {
|
|
445
|
-
|
|
447
|
+
if (error) reject(error);else resolve({
|
|
446
448
|
reason: 'Finished.',
|
|
447
449
|
parameters: []
|
|
448
450
|
});
|
|
@@ -38,7 +38,9 @@ var BrowserEnvironment = exports.BrowserEnvironment = /*#__PURE__*/function () {
|
|
|
38
38
|
}
|
|
39
39
|
}, {
|
|
40
40
|
key: "teardown",
|
|
41
|
-
value: function teardown() {
|
|
41
|
+
value: function teardown() {
|
|
42
|
+
// Stub method.
|
|
43
|
+
}
|
|
42
44
|
}, {
|
|
43
45
|
key: "runScript",
|
|
44
46
|
value: function runScript() {
|
package/jestSetup.js
CHANGED
|
@@ -22,6 +22,8 @@ _clientnode.globalContext.TextEncoder = _util.TextEncoder;
|
|
|
22
22
|
_clientnode.globalContext.TextDecoder = _util.TextDecoder;
|
|
23
23
|
try {
|
|
24
24
|
if (eval('require')('jest-canvas-mock')) console.info('Canvas mocking module loaded.');
|
|
25
|
+
/* eslint-disable @typescript-eslint/no-unused-vars */
|
|
25
26
|
} catch (error) {
|
|
27
|
+
/* eslint-enable @typescript-eslint/no-unused-vars */
|
|
26
28
|
// Do nothing.
|
|
27
29
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "weboptimizer",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.1492",
|
|
4
4
|
"description": "A generic web optimizer, (module) bundler and development environment.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"webpack",
|
|
@@ -76,7 +76,7 @@
|
|
|
76
76
|
"clear": "rimraf --glob apiDocumentation browser.d.ts configurator.d.ts ejsLoader.d.ts eslint.config.d.ts helper.d.ts index.d.ts jestSetup.d.ts jestEnvironmentBrowser.d.ts 'plugins/*.d.ts' 'plugins/*.js' stylelintConfigurator.d.ts 'test/*.js' 'test/*.compiled.*' 'test/*.d.ts' 'test/**/yarn.lock' 'test/**/node_modules' type.d.ts webpackConfigurator.d.ts '*.compiled.*' '*.compiled' '*.html' '*.js' '*.log' '*.mjs' node_modules/weboptimizer .coverage .nyc_output",
|
|
77
77
|
"document": "yarn build:plain && jsdoc --package ./package.json --readme ./readme.md --destination apiDocumentation *.js",
|
|
78
78
|
"lint": "yarn build:lint && yarn lint:base",
|
|
79
|
-
"lint:base": "eslint *.ts */*.ts test/*/*.ts",
|
|
79
|
+
"lint:base": "eslint --no-warn-ignored *.ts */*.ts test/*/*.ts",
|
|
80
80
|
"prepare": "yarn build",
|
|
81
81
|
"prettify": "yarn lint:base --fix || true",
|
|
82
82
|
"test": "yarn build:test && jest --config ./jest.json --noStackTrace --root-dir './' --test-regex '/test/.+\\\\.js$' test/browser.js test/configurator.js test/helper.js test/ejsLoader.js test/stylelintConfigurator.js test/index.js test/webpackConfigurator.js",
|
|
@@ -89,77 +89,77 @@
|
|
|
89
89
|
},
|
|
90
90
|
"runkitExample": "require('@babel/runtime/package.json')\n\nconst {default: main} = require('weboptimizer')\n\nawait main('./', './', ['clear'])",
|
|
91
91
|
"dependencies": {
|
|
92
|
-
"@babel/core": "^7.
|
|
92
|
+
"@babel/core": "^7.25.2",
|
|
93
93
|
"@babel/plugin-proposal-class-properties": "^7.18.6",
|
|
94
94
|
"@babel/plugin-proposal-decorators": "^7.24.7",
|
|
95
95
|
"@babel/plugin-proposal-nullish-coalescing-operator": "^7.18.6",
|
|
96
96
|
"@babel/plugin-transform-runtime": "^7.24.7",
|
|
97
|
-
"@babel/preset-env": "^7.
|
|
97
|
+
"@babel/preset-env": "^7.25.3",
|
|
98
98
|
"@babel/preset-typescript": "^7.24.7",
|
|
99
|
-
"@babel/runtime": "^7.
|
|
99
|
+
"@babel/runtime": "^7.25.0",
|
|
100
100
|
"babel-loader": "^9.1.3",
|
|
101
101
|
"babel-plugin-transform-modern-regexp": "^0.0.6",
|
|
102
102
|
"babel-preset-minify": "^0.5.2",
|
|
103
|
-
"clientnode": "3.0.
|
|
103
|
+
"clientnode": "3.0.1169",
|
|
104
104
|
"ejs": "^3.1.10",
|
|
105
105
|
"exports-loader": "^5.0.0",
|
|
106
106
|
"extract-loader": "^5.1.0",
|
|
107
107
|
"glob-all": "^3.3.1",
|
|
108
|
-
"html-loader": "^5.
|
|
108
|
+
"html-loader": "^5.1.0",
|
|
109
109
|
"html-minifier": "^4.0.0",
|
|
110
110
|
"html-webpack-plugin": "^5.6.0",
|
|
111
111
|
"imports-loader": "^5.0.0",
|
|
112
112
|
"jest-environment-jsdom": "^29.7.0",
|
|
113
113
|
"rimraf": "^6.0.1",
|
|
114
114
|
"script-loader": "^0.7.2",
|
|
115
|
-
"typescript": "^5.5.
|
|
115
|
+
"typescript": "^5.5.4",
|
|
116
116
|
"webpack": "^5.93.0",
|
|
117
117
|
"webpack-cli": "^5.1.4",
|
|
118
118
|
"webpack-sources": "^3.2.3"
|
|
119
119
|
},
|
|
120
120
|
"devDependencies": {
|
|
121
121
|
"@babel/cli": "^7.24.8",
|
|
122
|
-
"@babel/eslint-parser": "^7.
|
|
122
|
+
"@babel/eslint-parser": "^7.25.1",
|
|
123
|
+
"@stylistic/eslint-plugin": "^2.6.1",
|
|
123
124
|
"@types/ejs": "^3.1.5",
|
|
124
|
-
"@types/eslint": "^
|
|
125
|
+
"@types/eslint": "^9.6.0",
|
|
125
126
|
"@types/html-minifier": "^4.0.5",
|
|
126
127
|
"@types/html-minifier-terser": "^7.0.2",
|
|
127
128
|
"@types/imagemin": "^9.0.0",
|
|
128
|
-
"@types/node": "^
|
|
129
|
+
"@types/node": "^22.1.0",
|
|
129
130
|
"@types/postcss-import": "^14.0.3",
|
|
130
131
|
"@types/postcss-url": "^10.0.4",
|
|
131
132
|
"@types/webpack-env": "^1.18.5",
|
|
132
133
|
"@types/webpack-sources": "^3.2.3",
|
|
133
|
-
"@typescript-eslint/
|
|
134
|
-
"@typescript-eslint/parser": "^7.16.1",
|
|
134
|
+
"@typescript-eslint/parser": "^8.0.1",
|
|
135
135
|
"css-loader": "^7.1.2",
|
|
136
136
|
"cssnano": "^7.0.4",
|
|
137
|
-
"documentation-website": "^1.0.
|
|
138
|
-
"eslint": "^9.
|
|
137
|
+
"documentation-website": "^1.0.330",
|
|
138
|
+
"eslint": "^9.8.0",
|
|
139
139
|
"eslint-config-google": "^0.14.0",
|
|
140
|
-
"eslint-plugin-jsdoc": "^
|
|
140
|
+
"eslint-plugin-jsdoc": "^50.0.0",
|
|
141
141
|
"favicons": "^7.2.0",
|
|
142
142
|
"favicons-webpack-plugin": "^6.0.1",
|
|
143
|
-
"globals": "^15.
|
|
144
|
-
"image-minimizer-webpack-plugin": "^4.0
|
|
143
|
+
"globals": "^15.9.0",
|
|
144
|
+
"image-minimizer-webpack-plugin": "^4.1.0",
|
|
145
145
|
"jest": "^29.7.0",
|
|
146
146
|
"jsdoc": "^4.0.3",
|
|
147
147
|
"mini-css-extract-plugin": "^2.9.0",
|
|
148
148
|
"mkdirp": "^3.0.1",
|
|
149
149
|
"node-fetch": "^3.3.2",
|
|
150
|
-
"postcss": "^8.4.
|
|
150
|
+
"postcss": "^8.4.41",
|
|
151
151
|
"postcss-fontpath": "^1.0.0",
|
|
152
152
|
"postcss-import": "^16.1.0",
|
|
153
153
|
"postcss-loader": "^8.1.1",
|
|
154
|
-
"postcss-preset-env": "^
|
|
154
|
+
"postcss-preset-env": "^10.0.0",
|
|
155
155
|
"postcss-sprites": "^4.2.1",
|
|
156
156
|
"postcss-url": "^10.1.3",
|
|
157
157
|
"shx": "^0.3.4",
|
|
158
158
|
"style-loader": "^4.0.0",
|
|
159
|
-
"stylelint": "^16.
|
|
159
|
+
"stylelint": "^16.8.1",
|
|
160
160
|
"stylelint-config-standard": "^36.0.1",
|
|
161
161
|
"stylelint-config-standard-scss": "^13.1.0",
|
|
162
|
-
"typescript-eslint": "^
|
|
162
|
+
"typescript-eslint": "^8.0.1",
|
|
163
163
|
"typescript-plugin-css-modules": "^5.1.0",
|
|
164
164
|
"workbox-webpack-plugin": "^7.1.0"
|
|
165
165
|
},
|
|
@@ -482,26 +482,7 @@
|
|
|
482
482
|
{
|
|
483
483
|
"__evaluate__": "filesystem.isFileSync(path.resolve(currentPath, 'tsconfig.json')) ? '--parser-options=project:tsconfig.json' : ''"
|
|
484
484
|
},
|
|
485
|
-
"--
|
|
486
|
-
"'**/.git/*'",
|
|
487
|
-
"--ignore-pattern",
|
|
488
|
-
"'**/.cache/*'",
|
|
489
|
-
"--ignore-pattern",
|
|
490
|
-
"'**/.config/*'",
|
|
491
|
-
"--ignore-pattern",
|
|
492
|
-
"'**/.npm/*'",
|
|
493
|
-
"--ignore-pattern",
|
|
494
|
-
"'**/log/*'",
|
|
495
|
-
"--ignore-pattern",
|
|
496
|
-
"'**/node_modules/*'",
|
|
497
|
-
"--ignore-pattern",
|
|
498
|
-
"'**/backup/*'",
|
|
499
|
-
"--ignore-pattern",
|
|
500
|
-
"'**/exclude/*'",
|
|
501
|
-
"--ignore-pattern",
|
|
502
|
-
"'**/plugins/*'",
|
|
503
|
-
"--ignore-pattern",
|
|
504
|
-
"'*.d.ts'",
|
|
485
|
+
"--no-warn-ignored",
|
|
505
486
|
"'**/*.{jsx,ts,tsx}'"
|
|
506
487
|
],
|
|
507
488
|
"command": "eslint",
|
|
@@ -62,7 +62,7 @@ var HTMLTransformation = exports.HTMLTransformation = /*#__PURE__*/function () {
|
|
|
62
62
|
unexpected escape sequences in resulting html.
|
|
63
63
|
*/
|
|
64
64
|
dom = new _jsdom.JSDOM(data.html.replace(/<%/g, '##+#+#+##').replace(/%>/g, '##-#-#-##'));
|
|
65
|
-
} catch (
|
|
65
|
+
} catch (_error) {
|
|
66
66
|
return data;
|
|
67
67
|
}
|
|
68
68
|
var linkables = {
|
|
@@ -80,7 +80,8 @@ var HTMLTransformation = exports.HTMLTransformation = /*#__PURE__*/function () {
|
|
|
80
80
|
necessary to match the generated request strings in offline
|
|
81
81
|
plugin.
|
|
82
82
|
*/
|
|
83
|
-
|
|
83
|
+
var value = domNode.getAttribute(attributeName);
|
|
84
|
+
if (value) domNode.setAttribute(attributeName, value.replace(new RegExp("(\\?".concat(this.options.hashAlgorithm, "=[^&]+).*$")), '$1'));
|
|
84
85
|
}
|
|
85
86
|
}
|
|
86
87
|
// NOTE: We have to restore template delimiter and style contents.
|
|
@@ -101,7 +102,7 @@ var HTMLTransformation = exports.HTMLTransformation = /*#__PURE__*/function () {
|
|
|
101
102
|
var _loaderConfiguration$;
|
|
102
103
|
var loaderConfiguration = _step2.value;
|
|
103
104
|
if ((_loaderConfiguration$ = loaderConfiguration.options) !== null && _loaderConfiguration$ !== void 0 && _loaderConfiguration$.compileSteps && typeof loaderConfiguration.options.compileSteps === 'number') data.html = _ejsLoader["default"].bind({
|
|
104
|
-
query: (0, _clientnode.extend)(true, (0, _clientnode.copy)(loaderConfiguration.options)
|
|
105
|
+
query: (0, _clientnode.extend)(true, Object.prototype.hasOwnProperty.call(loaderConfiguration, 'options') ? (0, _clientnode.copy)(loaderConfiguration.options) : {}, htmlFileSpecification.template.postCompileOptions)
|
|
105
106
|
})(data.html);
|
|
106
107
|
}
|
|
107
108
|
} catch (err) {
|
|
@@ -56,7 +56,7 @@ var InPlaceAssetsIntoHTML = exports.InPlaceAssetsIntoHTML = /*#__PURE__*/functio
|
|
|
56
56
|
}
|
|
57
57
|
if (!(url && typeof url === 'string')) return tag;
|
|
58
58
|
var name = publicPath ? url.replace(publicPath, '') : url;
|
|
59
|
-
if (compilation.assets
|
|
59
|
+
if (Object.prototype.hasOwnProperty.call(compilation.assets, name) && settings && settings[type] && [].concat(settings[type]).some(function (pattern) {
|
|
60
60
|
return new RegExp(pattern).test(name);
|
|
61
61
|
})) {
|
|
62
62
|
var newAttributes = _objectSpread({}, tag.attributes);
|
package/tsconfig.json
CHANGED
|
@@ -23,11 +23,13 @@
|
|
|
23
23
|
"target": "esnext"
|
|
24
24
|
},
|
|
25
25
|
"exclude": [
|
|
26
|
-
"**/exclude/*"
|
|
26
|
+
"**/exclude/*",
|
|
27
|
+
"test/**/*.d.ts"
|
|
27
28
|
],
|
|
28
29
|
"include": [
|
|
29
30
|
"*.ts", "*.tsx",
|
|
30
31
|
"*/*.ts", "*/*.tsx",
|
|
32
|
+
"*/declarations.d.ts",
|
|
31
33
|
|
|
32
34
|
"assets/src/**/*.ts", "/assets/src/**/*.tsx",
|
|
33
35
|
"assets/source/**/*.ts", "/assets/source/**/*.tsx",
|
package/type.d.ts
CHANGED
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
import { AnyFunction, Encoding, Mapping, PlainObject, SecondParameter } from 'clientnode';
|
|
2
|
-
import FaviconWebpackPlugin from 'favicons-webpack-plugin';
|
|
2
|
+
import type FaviconWebpackPlugin from 'favicons-webpack-plugin';
|
|
3
3
|
import { FaviconWebpackPlugionOptions as FaviconWebpackPluginOptions } from 'favicons-webpack-plugin/src/options';
|
|
4
4
|
import HtmlWebpackPlugin from 'html-webpack-plugin';
|
|
5
|
-
import ImageMinimizerWebpackPlugin
|
|
5
|
+
import type ImageMinimizerWebpackPlugin from 'image-minimizer-webpack-plugin';
|
|
6
|
+
import { PluginOptions as ImageMinimizerOptions } from 'image-minimizer-webpack-plugin';
|
|
6
7
|
import { JSDOM } from 'jsdom';
|
|
7
|
-
import MiniCSSExtractPlugin from 'mini-css-extract-plugin';
|
|
8
|
-
import TerserWebpackPlugin from 'terser-webpack-plugin';
|
|
8
|
+
import type MiniCSSExtractPlugin from 'mini-css-extract-plugin';
|
|
9
|
+
import type TerserWebpackPlugin from 'terser-webpack-plugin';
|
|
9
10
|
import { DefinePlugin as WebpackDefinePlugin, Configuration as BaseWebpackConfiguration, IgnorePlugin as WebpackIgnorePlugin, library as webpackLibrary, ModuleOptions as WebpackModuleOptions, RuleSetRule as WebpackRuleSetRule, RuleSetUseItem as WebpackRuleSetUseItem, WebpackOptionsNormalized } from 'webpack';
|
|
10
11
|
import { WebpackPartial as WorkboxBaseCommonOptions, BasePartial as WorkboxCommonOptions, WebpackGenerateSWOptions as WorkboxGenerateSWOptions, WebpackInjectManifestOptions as WorkboxInjectManifestOptions } from 'workbox-build';
|
|
11
|
-
import OfflinePlugin from 'workbox-webpack-plugin';
|
|
12
|
+
import type OfflinePlugin from 'workbox-webpack-plugin';
|
|
12
13
|
export interface Browser {
|
|
13
14
|
debug: boolean;
|
|
14
15
|
domContentLoaded: boolean;
|
|
@@ -170,7 +171,7 @@ export interface WebpackLoaderConfiguration {
|
|
|
170
171
|
}
|
|
171
172
|
export type WebpackLoaderIndicator = WebpackRuleSetRule['include'];
|
|
172
173
|
export interface Command {
|
|
173
|
-
arguments
|
|
174
|
+
arguments?: Array<string>;
|
|
174
175
|
command: string;
|
|
175
176
|
indicator?: string;
|
|
176
177
|
}
|
|
@@ -442,8 +443,8 @@ export interface WebpackBaseAssets {
|
|
|
442
443
|
plugin: HtmlWebpackPlugin;
|
|
443
444
|
}
|
|
444
445
|
export interface WebpackAssets extends WebpackBaseAssets {
|
|
445
|
-
bodyTags: HtmlWebpackPlugin.HtmlTagObject
|
|
446
|
-
headTags: HtmlWebpackPlugin.HtmlTagObject
|
|
446
|
+
bodyTags: Array<HtmlWebpackPlugin.HtmlTagObject>;
|
|
447
|
+
headTags: Array<HtmlWebpackPlugin.HtmlTagObject>;
|
|
447
448
|
outputName: string;
|
|
448
449
|
publicPath: string;
|
|
449
450
|
plugin: HtmlWebpackPlugin;
|
|
@@ -472,8 +473,8 @@ export type WebpackExtendedResolveData = WebpackResolveData & {
|
|
|
472
473
|
};
|
|
473
474
|
};
|
|
474
475
|
export interface HTMLWebpackPluginAssetTagGroupsData {
|
|
475
|
-
bodyTags: HtmlWebpackPlugin.HtmlTagObject
|
|
476
|
-
headTags: HtmlWebpackPlugin.HtmlTagObject
|
|
476
|
+
bodyTags: Array<HtmlWebpackPlugin.HtmlTagObject>;
|
|
477
|
+
headTags: Array<HtmlWebpackPlugin.HtmlTagObject>;
|
|
477
478
|
outputName: string;
|
|
478
479
|
plugin: HtmlWebpackPlugin;
|
|
479
480
|
}
|
package/webpackConfigurator.js
CHANGED
|
@@ -32,7 +32,7 @@ var _util = _interopRequireDefault(require("util"));
|
|
|
32
32
|
var _webpack = require("webpack");
|
|
33
33
|
var _webpackSources = require("webpack-sources");
|
|
34
34
|
var _configurator = _interopRequireDefault(require("./configurator"));
|
|
35
|
-
var _helper =
|
|
35
|
+
var _helper = require("./helper");
|
|
36
36
|
var _InPlaceAssetsIntoHTML = _interopRequireDefault(require("./plugins/InPlaceAssetsIntoHTML"));
|
|
37
37
|
var _HTMLTransformation = _interopRequireDefault(require("./plugins/HTMLTransformation"));
|
|
38
38
|
var _optionalRequire, _configuration$path$c, _configuration$cache$, _configuration$cache, _configuration$cache2, _configuration$cache3, _configuration$path$c2;
|
|
@@ -52,7 +52,9 @@ eval("typeof require === 'undefined' ? null : require");
|
|
|
52
52
|
var optionalRequire = exports.optionalRequire = function optionalRequire(id) {
|
|
53
53
|
try {
|
|
54
54
|
return currentRequire ? currentRequire(id) : null;
|
|
55
|
+
/* eslint-disable @typescript-eslint/no-unused-vars */
|
|
55
56
|
} catch (error) {
|
|
57
|
+
/* eslint-enable @typescript-eslint/no-unused-vars */
|
|
56
58
|
return null;
|
|
57
59
|
}
|
|
58
60
|
};
|
|
@@ -195,7 +197,7 @@ pluginInstances.push({
|
|
|
195
197
|
request = _Object$entries4$_i[0],
|
|
196
198
|
asset = _Object$entries4$_i[1];
|
|
197
199
|
var filePath = request.replace(/\?[^?]+$/, '');
|
|
198
|
-
var _type = _helper
|
|
200
|
+
var _type = (0, _helper.determineAssetType)(filePath, configuration.buildContext.types, configuration.path);
|
|
199
201
|
if (_type && configuration.assetPattern[_type] && new RegExp(configuration.assetPattern[_type].includeFilePathRegularExpression).test(filePath) && !new RegExp(configuration.assetPattern[_type].excludeFilePathRegularExpression).test(filePath)) {
|
|
200
202
|
var source = asset.source();
|
|
201
203
|
if (typeof source === 'string') compilation.assets[request] = new _webpackSources.RawSource(configuration.assetPattern[_type].pattern.replace(/\{1\}/g, source.replace(/\$/g, '$$$')));
|
|
@@ -274,7 +276,7 @@ if (configuration.injection.external.modules === '__implicit__')
|
|
|
274
276
|
} finally {
|
|
275
277
|
_iterator3.f();
|
|
276
278
|
}
|
|
277
|
-
var filePath = _helper
|
|
279
|
+
var filePath = (0, _helper.determineModuleFilePath)(request, {}, {}, {
|
|
278
280
|
file: configuration.extensions.file.external
|
|
279
281
|
}, configuration.path.context, context, configuration.path.ignore, _module.directoryNames, configuration["package"].main.fileNames, configuration["package"].main.propertyNames, configuration["package"].aliasPropertyNames, configuration.encoding);
|
|
280
282
|
if (filePath) for (var _i6 = 0, _Object$entries5 = Object.entries(configuration.injection.external.aliases); _i6 < _Object$entries5.length; _i6++) {
|
|
@@ -292,7 +294,7 @@ if (configuration.injection.external.modules === '__implicit__')
|
|
|
292
294
|
if (target.startsWith('?')) {
|
|
293
295
|
target = target.substring(1);
|
|
294
296
|
var aliasedRequest = request.replace(replacementRegularExpression, target);
|
|
295
|
-
if (aliasedRequest !== request) match = Boolean(_helper
|
|
297
|
+
if (aliasedRequest !== request) match = Boolean((0, _helper.determineModuleFilePath)(aliasedRequest, {}, {}, {
|
|
296
298
|
file: configuration.extensions.file.external
|
|
297
299
|
}, configuration.path.context, context, configuration.path.ignore, _module.directoryNames, configuration["package"].main.fileNames, configuration["package"].main.propertyNames, configuration["package"].aliasPropertyNames, configuration.encoding));
|
|
298
300
|
} else match = true;
|
|
@@ -304,7 +306,7 @@ if (configuration.injection.external.modules === '__implicit__')
|
|
|
304
306
|
}
|
|
305
307
|
}
|
|
306
308
|
// endregion
|
|
307
|
-
var resolvedRequest = _helper
|
|
309
|
+
var resolvedRequest = (0, _helper.determineExternalRequest)(request, configuration.path.context, context, configuration.injection.entry.normalized, _module.directoryNames, _module.aliases, _module.replacements.normal, configuration.extensions, configuration.path.source.asset.base, configuration.path.ignore, _module.directoryNames, configuration["package"].main.fileNames, configuration["package"].main.propertyNames, configuration["package"].aliasPropertyNames, configuration.injection.external.implicit.pattern.include, configuration.injection.external.implicit.pattern.exclude, configuration.inPlace.externalLibrary.normal, configuration.inPlace.externalLibrary.dynamic, configuration.encoding);
|
|
308
310
|
if (resolvedRequest) {
|
|
309
311
|
var keys = ['amd', 'commonjs', 'commonjs2', 'root'];
|
|
310
312
|
var result = resolvedRequest;
|
|
@@ -407,7 +409,7 @@ if (_module.enforceDeduplication) {
|
|
|
407
409
|
var consolidator = function consolidator(result) {
|
|
408
410
|
var targetPath = result.createData.resource;
|
|
409
411
|
if (targetPath && /((?:^|\/)node_modules\/.+)/.test(targetPath) && (!targetPath.startsWith(absoluteContextPath) || /((?:^|\/)node_modules\/.+){2}/.test(targetPath)) && (0, _clientnode.isFileSync)(targetPath)) {
|
|
410
|
-
var packageDescriptor = _helper
|
|
412
|
+
var packageDescriptor = (0, _helper.getClosestPackageDescriptor)(targetPath);
|
|
411
413
|
if (packageDescriptor) {
|
|
412
414
|
var pathPrefixes;
|
|
413
415
|
var pathSuffix;
|
|
@@ -450,7 +452,7 @@ if (_module.enforceDeduplication) {
|
|
|
450
452
|
var _pathPrefix = _step9.value;
|
|
451
453
|
var alternateTargetPath = (0, _path.resolve)(_pathPrefix, pathSuffix);
|
|
452
454
|
if ((0, _clientnode.isFileSync)(alternateTargetPath)) {
|
|
453
|
-
var otherPackageDescriptor = _helper
|
|
455
|
+
var otherPackageDescriptor = (0, _helper.getClosestPackageDescriptor)(alternateTargetPath);
|
|
454
456
|
if (otherPackageDescriptor) {
|
|
455
457
|
if (packageDescriptor.configuration.version === otherPackageDescriptor.configuration.version) {
|
|
456
458
|
console.info('\nConsolidate module request "' + "".concat(targetPath, "\" to \"") + "".concat(alternateTargetPath, "\"."));
|
|
@@ -574,8 +576,8 @@ new NormalModuleReplacementPlugin(
|
|
|
574
576
|
/// endregion
|
|
575
577
|
/// region loader helper
|
|
576
578
|
var isFilePathInDependencies = function isFilePathInDependencies(filePath) {
|
|
577
|
-
filePath = _helper
|
|
578
|
-
return _helper
|
|
579
|
+
filePath = (0, _helper.stripLoader)(filePath);
|
|
580
|
+
return (0, _helper.isFilePathInLocation)(filePath, configuration.path.ignore.concat(_module.directoryNames, configuration.loader.directoryNames).map(function (filePath) {
|
|
579
581
|
return (0, _path.resolve)(configuration.path.context, filePath);
|
|
580
582
|
}).filter(function (filePath) {
|
|
581
583
|
return !configuration.path.context.startsWith(filePath);
|
|
@@ -613,7 +615,7 @@ var evaluateAdditionalLoaderConfiguration = function evaluateAdditionalLoaderCon
|
|
|
613
615
|
};
|
|
614
616
|
};
|
|
615
617
|
var getIncludingPaths = function getIncludingPaths(path) {
|
|
616
|
-
return _helper
|
|
618
|
+
return (0, _helper.normalizePaths)([path].concat(_module.locations.directoryPaths));
|
|
617
619
|
};
|
|
618
620
|
var cssUse = _module.preprocessor.cascadingStyleSheet.additional.pre.map(evaluateMapper).concat({
|
|
619
621
|
loader: _module.style.loader,
|
|
@@ -686,7 +688,7 @@ var genericLoader = {
|
|
|
686
688
|
// region generic template
|
|
687
689
|
ejs: {
|
|
688
690
|
exclude: function exclude(filePath) {
|
|
689
|
-
return _helper
|
|
691
|
+
return (0, _helper.normalizePaths)(configuration.files.html.concat(configuration.files.defaultHTML).map(function (htmlConfiguration) {
|
|
690
692
|
return htmlConfiguration.template.filePath;
|
|
691
693
|
})).includes(filePath) || _module.preprocessor.ejs.exclude === null ? false : Boolean(evaluateAnThrow(_module.preprocessor.ejs.exclude, filePath));
|
|
692
694
|
},
|
|
@@ -744,7 +746,7 @@ var genericLoader = {
|
|
|
744
746
|
},
|
|
745
747
|
ejs: {
|
|
746
748
|
exclude: function exclude(filePath) {
|
|
747
|
-
return _helper
|
|
749
|
+
return (0, _helper.normalizePaths)(configuration.files.html.concat(configuration.files.defaultHTML).map(function (htmlConfiguration) {
|
|
748
750
|
return htmlConfiguration.template.filePath;
|
|
749
751
|
})).includes(filePath) || (_module.preprocessor.html.exclude === null ? false : Boolean(evaluateAnThrow(_module.preprocessor.html.exclude, filePath)));
|
|
750
752
|
},
|
|
@@ -768,7 +770,7 @@ var genericLoader = {
|
|
|
768
770
|
},
|
|
769
771
|
html: {
|
|
770
772
|
exclude: function exclude(filePath) {
|
|
771
|
-
return _helper
|
|
773
|
+
return (0, _helper.normalizePaths)(configuration.files.html.concat(configuration.files.defaultHTML).map(function (htmlConfiguration) {
|
|
772
774
|
return htmlConfiguration.template.filePath;
|
|
773
775
|
})).includes(filePath) || (_module.html.exclude === null ? true : Boolean(evaluateAnThrow(_module.html.exclude, filePath)));
|
|
774
776
|
},
|
|
@@ -909,7 +911,7 @@ var genericLoader = {
|
|
|
909
911
|
data: {
|
|
910
912
|
exclude: function exclude(filePath) {
|
|
911
913
|
if (typeof filePath !== 'string') return false;
|
|
912
|
-
return configuration.extensions.file.internal.includes((0, _path.extname)(_helper
|
|
914
|
+
return configuration.extensions.file.internal.includes((0, _path.extname)((0, _helper.stripLoader)(filePath))) || (_module.optimizer.data.exclude === null ? isFilePathInDependencies(filePath) : Boolean(evaluateAnThrow(_module.optimizer.data.exclude, filePath)));
|
|
913
915
|
},
|
|
914
916
|
generator: {
|
|
915
917
|
filename: (0, _path.join)((0, _path.relative)(configuration.path.target.base, configuration.path.target.asset.data), '[name][ext]') + "?".concat(configuration.hashAlgorithm, "=[contenthash]")
|
|
@@ -1019,7 +1021,7 @@ var webpackConfiguration = exports.webpackConfiguration = (0, _clientnode.extend
|
|
|
1019
1021
|
extensions: configuration.extensions.file.internal,
|
|
1020
1022
|
mainFields: configuration["package"].main.propertyNames,
|
|
1021
1023
|
mainFiles: configuration["package"].main.fileNames,
|
|
1022
|
-
modules: _helper
|
|
1024
|
+
modules: (0, _helper.normalizePaths)(_module.directoryNames),
|
|
1023
1025
|
symlinks: _module.resolveSymlinks,
|
|
1024
1026
|
unsafeCache: Boolean((_configuration$cache$ = (_configuration$cache = configuration.cache) === null || _configuration$cache === void 0 ? void 0 : _configuration$cache.unsafe) !== null && _configuration$cache$ !== void 0 ? _configuration$cache$ : (_configuration$cache2 = configuration.cache) === null || _configuration$cache2 === void 0 ? void 0 : _configuration$cache2.main)
|
|
1025
1027
|
},
|