@umijs/bundler-webpack 3.5.18 → 4.0.0-beta.2
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 +2 -0
- package/bin/bundler-webpack.js +1 -2
- package/client/client/client.js +202 -0
- package/client/constants.js +12 -0
- package/client/utils/formatWebpackMessages.js +92 -0
- package/compiled/@svgr/webpack/.svgo.yml +75 -0
- package/compiled/@svgr/webpack/LICENSE +7 -0
- package/compiled/@svgr/webpack/index.js +343 -0
- package/compiled/@svgr/webpack/package.json +1 -0
- package/compiled/autoprefixer/LICENSE +20 -0
- package/compiled/autoprefixer/browserslist/index.d.ts +172 -0
- package/compiled/autoprefixer/index.js +9 -0
- package/compiled/autoprefixer/lib/autoprefixer.d.ts +95 -0
- package/compiled/autoprefixer/package.json +1 -0
- package/compiled/autoprefixer/postcss/lib/at-rule.d.ts +106 -0
- package/compiled/autoprefixer/postcss/lib/comment.d.ts +56 -0
- package/compiled/autoprefixer/postcss/lib/container.d.ts +442 -0
- package/compiled/autoprefixer/postcss/lib/css-syntax-error.d.ts +192 -0
- package/compiled/autoprefixer/postcss/lib/declaration.d.ts +124 -0
- package/compiled/autoprefixer/postcss/lib/document.d.ts +57 -0
- package/compiled/autoprefixer/postcss/lib/input.d.ts +130 -0
- package/compiled/autoprefixer/postcss/lib/lazy-result.d.ts +175 -0
- package/compiled/autoprefixer/postcss/lib/list.d.ts +51 -0
- package/compiled/autoprefixer/postcss/lib/node.d.ts +444 -0
- package/compiled/autoprefixer/postcss/lib/postcss.d.ts +472 -0
- package/compiled/autoprefixer/postcss/lib/previous-map.d.ts +72 -0
- package/compiled/autoprefixer/postcss/lib/processor.d.ts +101 -0
- package/compiled/autoprefixer/postcss/lib/result.d.ts +195 -0
- package/compiled/autoprefixer/postcss/lib/root.d.ts +73 -0
- package/compiled/autoprefixer/postcss/lib/rule.d.ts +104 -0
- package/compiled/autoprefixer/postcss/lib/warning.d.ts +104 -0
- package/compiled/autoprefixer/source-map-js/source-map.d.ts +98 -0
- package/compiled/babel-loader/LICENSE +22 -0
- package/compiled/babel-loader/index.js +3 -0
- package/compiled/babel-loader/package.json +1 -0
- package/compiled/compression/LICENSE +23 -0
- package/compiled/compression/index.js +57 -0
- package/compiled/compression/package.json +1 -0
- package/compiled/connect-history-api-fallback/LICENSE +21 -0
- package/compiled/connect-history-api-fallback/index.js +1 -0
- package/compiled/connect-history-api-fallback/package.json +1 -0
- package/{lib/webpack/plugins/mini-css-extract-plugin → compiled/copy-webpack-plugin}/LICENSE +0 -0
- package/compiled/copy-webpack-plugin/index.js +46 -0
- package/compiled/copy-webpack-plugin/package.json +1 -0
- package/{lib/webpack/plugins/terser-webpack-plugin → compiled/css-loader}/LICENSE +0 -0
- package/compiled/css-loader/api.js +102 -0
- package/compiled/css-loader/getUrl.js +29 -0
- package/compiled/css-loader/index.js +2 -0
- package/compiled/css-loader/noSourceMaps.js +5 -0
- package/compiled/css-loader/package.json +1 -0
- package/compiled/css-loader/sourceMaps.js +22 -0
- package/compiled/css-minimizer-webpack-plugin/LICENSE +20 -0
- package/compiled/css-minimizer-webpack-plugin/index.js +3 -0
- package/compiled/css-minimizer-webpack-plugin/minify.js +72 -0
- package/compiled/css-minimizer-webpack-plugin/package.json +1 -0
- package/compiled/css-minimizer-webpack-plugin/utils.js +166 -0
- package/compiled/cssnano/index.js +192 -0
- package/compiled/cssnano/package.json +1 -0
- package/compiled/express/LICENSE +24 -0
- package/compiled/express/body-parser/index.d.ts +104 -0
- package/compiled/express/connect/index.d.ts +93 -0
- package/compiled/express/express-serve-static-core/index.d.ts +1252 -0
- package/compiled/express/index.d.ts +133 -0
- package/compiled/express/index.js +338 -0
- package/compiled/express/mime/index.d.ts +35 -0
- package/compiled/express/package.json +1 -0
- package/compiled/express/qs/index.d.ts +62 -0
- package/compiled/express/range-parser/index.d.ts +35 -0
- package/compiled/express/serve-static/index.d.ts +108 -0
- package/compiled/http-proxy-middleware/LICENSE +22 -0
- package/compiled/http-proxy-middleware/dist/index.d.ts +4 -0
- package/compiled/http-proxy-middleware/dist/types.d.ts +54 -0
- package/compiled/http-proxy-middleware/http-proxy/index.d.ts +226 -0
- package/compiled/http-proxy-middleware/index.js +66 -0
- package/compiled/http-proxy-middleware/package.json +1 -0
- package/compiled/less/index.js +31 -0
- package/compiled/less/package.json +1 -0
- package/compiled/less-loader/LICENSE +20 -0
- package/compiled/less-loader/index.js +1 -0
- package/compiled/less-loader/package.json +1 -0
- package/compiled/mini-css-extract-plugin/LICENSE +20 -0
- package/{lib/webpack/plugins/mini-css-extract-plugin/src → compiled/mini-css-extract-plugin}/hmr/hotModuleReplacement.js +50 -52
- package/compiled/mini-css-extract-plugin/hmr/normalize-url.js +35 -0
- package/compiled/mini-css-extract-plugin/index.js +11606 -0
- package/compiled/mini-css-extract-plugin/loader-options.json +32 -0
- package/compiled/mini-css-extract-plugin/loader.js +315 -0
- package/compiled/mini-css-extract-plugin/package.json +1 -0
- package/compiled/mini-css-extract-plugin/utils.js +154 -0
- package/compiled/postcss-flexbugs-fixes/LICENSE +20 -0
- package/compiled/postcss-flexbugs-fixes/index.js +1 -0
- package/compiled/postcss-flexbugs-fixes/package.json +1 -0
- package/compiled/postcss-loader/LICENSE +20 -0
- package/compiled/postcss-loader/index.js +1 -0
- package/compiled/postcss-loader/package.json +1 -0
- package/compiled/purgecss-webpack-plugin/LICENSE +21 -0
- package/compiled/purgecss-webpack-plugin/index.js +7781 -0
- package/compiled/purgecss-webpack-plugin/package.json +1 -0
- package/compiled/react-refresh/index.js +19 -0
- package/compiled/sass-loader/LICENSE +20 -0
- package/compiled/sass-loader/index.js +1 -0
- package/compiled/sass-loader/package.json +1 -0
- package/compiled/schema-utils/LICENSE +20 -0
- package/compiled/schema-utils/ajv/lib/ajv.d.ts +397 -0
- package/compiled/schema-utils/declarations/ValidationError.d.ts +74 -0
- package/compiled/schema-utils/declarations/index.d.ts +3 -0
- package/compiled/schema-utils/declarations/validate.d.ts +37 -0
- package/compiled/schema-utils/index.js +3 -0
- package/compiled/schema-utils/json-schema/index.d.ts +751 -0
- package/compiled/schema-utils/package.json +1 -0
- package/compiled/speed-measure-webpack-plugin/LICENSE +21 -0
- package/compiled/speed-measure-webpack-plugin/index.js +1 -0
- package/compiled/speed-measure-webpack-plugin/package.json +1 -0
- package/compiled/style-loader/LICENSE +20 -0
- package/compiled/style-loader/index.js +1 -0
- package/compiled/style-loader/package.json +1 -0
- package/compiled/style-loader/runtime/injectStylesIntoLinkTag.js +29 -0
- package/compiled/style-loader/runtime/injectStylesIntoStyleTag.js +104 -0
- package/compiled/style-loader/runtime/insertBySelector.js +39 -0
- package/compiled/style-loader/runtime/insertStyleElement.js +11 -0
- package/compiled/style-loader/runtime/isEqualLocals.js +35 -0
- package/compiled/style-loader/runtime/isOldIE.js +19 -0
- package/compiled/style-loader/runtime/setAttributesWithAttributes.js +16 -0
- package/compiled/style-loader/runtime/setAttributesWithAttributesAndNonce.js +10 -0
- package/compiled/style-loader/runtime/setAttributesWithoutAttributes.js +12 -0
- package/compiled/style-loader/runtime/singletonStyleDomAPI.js +93 -0
- package/compiled/style-loader/runtime/styleDomAPI.js +70 -0
- package/compiled/style-loader/runtime/styleTagTransform.js +16 -0
- package/compiled/svgo-loader/LICENSE +22 -0
- package/compiled/svgo-loader/index.js +4 -0
- package/compiled/svgo-loader/package.json +1 -0
- package/compiled/swc-loader/LICENSE +25 -0
- package/compiled/swc-loader/index.js +1 -0
- package/compiled/swc-loader/package.json +1 -0
- package/compiled/tapable/LICENSE +21 -0
- package/compiled/tapable/index.js +1 -0
- package/compiled/tapable/package.json +1 -0
- package/compiled/tapable/tapable.d.ts +116 -0
- package/compiled/terser/LICENSE +29 -0
- package/compiled/terser/index.js +1 -0
- package/compiled/terser/mappings.wasm +0 -0
- package/compiled/terser/package.json +1 -0
- package/compiled/terser/source-map/source-map.d.ts +369 -0
- package/compiled/terser/tools/terser.d.ts +207 -0
- package/compiled/terser-webpack-plugin/LICENSE +20 -0
- package/compiled/terser-webpack-plugin/ajv/lib/ajv.d.ts +397 -0
- package/compiled/terser-webpack-plugin/index.js +15142 -0
- package/compiled/terser-webpack-plugin/jest-worker/build/index.d.ts +49 -0
- package/compiled/terser-webpack-plugin/jest-worker/build/types.d.ts +142 -0
- package/compiled/terser-webpack-plugin/json-schema/index.d.ts +751 -0
- package/compiled/terser-webpack-plugin/minify.js +43 -0
- package/compiled/terser-webpack-plugin/package.json +1 -0
- package/compiled/terser-webpack-plugin/schema-utils/declarations/ValidationError.d.ts +74 -0
- package/compiled/terser-webpack-plugin/schema-utils/declarations/index.d.ts +3 -0
- package/compiled/terser-webpack-plugin/schema-utils/declarations/validate.d.ts +37 -0
- package/compiled/terser-webpack-plugin/source-map/source-map.d.ts +98 -0
- package/compiled/terser-webpack-plugin/types/cjs.d.ts +3 -0
- package/compiled/terser-webpack-plugin/types/index.d.ts +295 -0
- package/compiled/terser-webpack-plugin/types/utils.d.ts +105 -0
- package/compiled/terser-webpack-plugin/utils.js +594 -0
- package/compiled/url-loader/LICENSE +20 -0
- package/compiled/url-loader/index.js +15 -0
- package/compiled/url-loader/package.json +1 -0
- package/compiled/webpack/Chunk.js +1 -0
- package/compiled/webpack/Compilation.js +1 -0
- package/compiled/webpack/HotModuleReplacement.runtime.js +394 -0
- package/compiled/webpack/JavascriptHotModuleReplacement.runtime.js +462 -0
- package/compiled/webpack/LICENSE +20 -0
- package/compiled/webpack/LibraryTemplatePlugin.js +1 -0
- package/compiled/webpack/LoaderTargetPlugin.js +1 -0
- package/compiled/webpack/ModuleFilenameHelpers.js +1 -0
- package/compiled/webpack/NormalModule.js +1 -0
- package/compiled/webpack/RuntimeGlobals.js +1 -0
- package/compiled/webpack/RuntimeModule.js +1 -0
- package/compiled/webpack/SingleEntryPlugin.js +1 -0
- package/compiled/webpack/Template.js +1 -0
- package/compiled/webpack/ajv/lib/ajv.d.ts +397 -0
- package/compiled/webpack/deepImports.json +12 -0
- package/compiled/webpack/index.js +162861 -0
- package/compiled/webpack/json-schema/index.d.ts +751 -0
- package/compiled/webpack/lazy-compilation-node.js +40 -0
- package/compiled/webpack/lazy-compilation-web.js +74 -0
- package/compiled/webpack/package.json +5 -0
- package/compiled/webpack/schema-utils/declarations/ValidationError.d.ts +74 -0
- package/compiled/webpack/schema-utils/declarations/index.d.ts +3 -0
- package/compiled/webpack/schema-utils/declarations/validate.d.ts +37 -0
- package/compiled/webpack/types.d.ts +12664 -0
- package/compiled/webpack-5-chain/LICENSE +373 -0
- package/compiled/webpack-5-chain/index.js +1 -0
- package/compiled/webpack-5-chain/package.json +1 -0
- package/compiled/webpack-5-chain/types/index.d.ts +543 -0
- package/compiled/webpack-bundle-analyzer/LICENSE +20 -0
- package/compiled/webpack-bundle-analyzer/index.js +30 -0
- package/compiled/webpack-bundle-analyzer/package.json +1 -0
- package/compiled/webpack-bundle-analyzer/public/viewer.js +16 -0
- package/compiled/webpack-bundle-analyzer/public/viewer.js.LICENSE.txt +10 -0
- package/compiled/webpack-bundle-analyzer/public/viewer.js.map +1 -0
- package/compiled/webpack-dev-middleware/LICENSE +20 -0
- package/compiled/webpack-dev-middleware/index.js +21 -0
- package/compiled/webpack-dev-middleware/package.json +1 -0
- package/compiled/webpack-sources/LICENSE +21 -0
- package/compiled/webpack-sources/index.d.ts +20 -0
- package/compiled/webpack-sources/index.js +1 -0
- package/compiled/webpack-sources/lib/CachedSource.d.ts +18 -0
- package/compiled/webpack-sources/lib/CompatSource.d.ts +9 -0
- package/compiled/webpack-sources/lib/ConcatSource.d.ts +22 -0
- package/compiled/webpack-sources/lib/OriginalSource.d.ts +18 -0
- package/compiled/webpack-sources/lib/PrefixSource.d.ts +12 -0
- package/compiled/webpack-sources/lib/RawSource.d.ts +13 -0
- package/compiled/webpack-sources/lib/ReplaceSource.d.ts +35 -0
- package/compiled/webpack-sources/lib/SizeOnlySource.d.ts +7 -0
- package/compiled/webpack-sources/lib/Source.d.ts +45 -0
- package/compiled/webpack-sources/lib/SourceMapSource.d.ts +22 -0
- package/compiled/webpack-sources/lib/index.d.ts +60 -0
- package/compiled/webpack-sources/package.json +1 -0
- package/compiled/webpack-sources/source-list-map/index.d.ts +91 -0
- package/compiled/webpack-sources/source-map/source-map.d.ts +369 -0
- package/compiled/ws/LICENSE +19 -0
- package/compiled/ws/index.d.ts +359 -0
- package/compiled/ws/index.js +1 -0
- package/compiled/ws/package.json +1 -0
- package/dist/build.d.ts +16 -0
- package/dist/build.js +71 -0
- package/{lib → dist}/cli.d.ts +0 -0
- package/dist/cli.js +113 -0
- package/{lib/webpackHotDevClient/webpackHotDevClient.d.ts → dist/client/client.d.ts} +0 -0
- package/dist/client/client.js +239 -0
- package/dist/config/_sampleFeature.d.ts +10 -0
- package/dist/config/_sampleFeature.js +22 -0
- package/dist/config/assetRules.d.ts +11 -0
- package/dist/config/assetRules.js +57 -0
- package/dist/config/bundleAnalyzerPlugin.d.ts +10 -0
- package/dist/config/bundleAnalyzerPlugin.js +30 -0
- package/dist/config/compressPlugin.d.ts +10 -0
- package/dist/config/compressPlugin.js +77 -0
- package/dist/config/config.d.ts +19 -0
- package/dist/config/config.js +171 -0
- package/dist/config/copyPlugin.d.ts +10 -0
- package/dist/config/copyPlugin.js +49 -0
- package/dist/config/cssRules.d.ts +11 -0
- package/dist/config/cssRules.js +98 -0
- package/dist/config/definePlugin.d.ts +15 -0
- package/dist/config/definePlugin.js +45 -0
- package/dist/config/fastRefreshPlugin.d.ts +12 -0
- package/dist/config/fastRefreshPlugin.js +34 -0
- package/dist/config/ignorePlugin.d.ts +10 -0
- package/dist/config/ignorePlugin.js +27 -0
- package/dist/config/javaScriptRules.d.ts +14 -0
- package/dist/config/javaScriptRules.js +150 -0
- package/dist/config/miniCSSExtractPlugin.d.ts +10 -0
- package/dist/config/miniCSSExtractPlugin.js +34 -0
- package/dist/config/nodePolyfill.d.ts +10 -0
- package/dist/config/nodePolyfill.js +34 -0
- package/dist/config/progressPlugin.d.ts +11 -0
- package/dist/config/progressPlugin.js +27 -0
- package/dist/config/purgecssWebpackPlugin.d.ts +10 -0
- package/dist/config/purgecssWebpackPlugin.js +32 -0
- package/dist/config/speedMeasureWebpackPlugin.d.ts +6 -0
- package/dist/config/speedMeasureWebpackPlugin.js +34 -0
- package/dist/config/svgRules.d.ts +11 -0
- package/dist/config/svgRules.js +56 -0
- package/dist/constants.d.ts +11 -0
- package/dist/constants.js +15 -0
- package/dist/dev.d.ts +18 -0
- package/dist/dev.js +80 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.js +16 -0
- package/dist/plugins/ESBuildCSSMinifyPlugin.d.ts +11 -0
- package/dist/plugins/ESBuildCSSMinifyPlugin.js +65 -0
- package/dist/plugins/ProgressPlugin.d.ts +15 -0
- package/dist/plugins/ProgressPlugin.js +44 -0
- package/dist/plugins/_SamplePlugin.d.ts +9 -0
- package/dist/plugins/_SamplePlugin.js +14 -0
- package/dist/requireHook.d.ts +1 -0
- package/dist/requireHook.js +31 -0
- package/dist/schema.d.ts +3 -0
- package/dist/schema.js +68 -0
- package/dist/server/server.d.ts +16 -0
- package/dist/server/server.js +157 -0
- package/dist/server/ws.d.ts +8 -0
- package/dist/server/ws.js +42 -0
- package/dist/types.d.ts +97 -0
- package/dist/types.js +29 -0
- package/dist/utils/browsersList.d.ts +5 -0
- package/dist/utils/browsersList.js +10 -0
- package/dist/utils/depMatch.d.ts +6 -0
- package/dist/utils/depMatch.js +46 -0
- package/dist/utils/formatWebpackMessages.d.ts +12 -0
- package/dist/utils/formatWebpackMessages.js +100 -0
- package/package.json +163 -35
- package/bundled/css/hotModuleReplacement.js +0 -1203
- package/bundled/js/webpackHotDevClient.js +0 -13386
- package/lib/DevCompileDonePlugin.d.ts +0 -10
- package/lib/DevCompileDonePlugin.js +0 -53
- package/lib/cli.js +0 -184
- package/lib/getConfig/css.d.ts +0 -22
- package/lib/getConfig/css.js +0 -186
- package/lib/getConfig/getConfig.d.ts +0 -26
- package/lib/getConfig/getConfig.js +0 -578
- package/lib/getConfig/nodeModulesTransform.d.ts +0 -13
- package/lib/getConfig/nodeModulesTransform.js +0 -141
- package/lib/getConfig/pkgMatch.d.ts +0 -2
- package/lib/getConfig/pkgMatch.js +0 -58
- package/lib/getConfig/resolveDefine.d.ts +0 -5
- package/lib/getConfig/resolveDefine.js +0 -53
- package/lib/getConfig/runtimePublicPathEntry.d.ts +0 -1
- package/lib/getConfig/runtimePublicPathEntry.js +0 -3
- package/lib/getConfig/terserOptions.d.ts +0 -41
- package/lib/getConfig/terserOptions.js +0 -64
- package/lib/index.d.ts +0 -34
- package/lib/index.js +0 -314
- package/lib/requireHook.d.ts +0 -3
- package/lib/requireHook.js +0 -51
- package/lib/webpack/plugins/mini-css-extract-plugin/src/CssDependency.js +0 -94
- package/lib/webpack/plugins/mini-css-extract-plugin/src/CssDependencyTemplate.js +0 -26
- package/lib/webpack/plugins/mini-css-extract-plugin/src/CssLoadingRuntimeModule.js +0 -93
- package/lib/webpack/plugins/mini-css-extract-plugin/src/CssModule.js +0 -164
- package/lib/webpack/plugins/mini-css-extract-plugin/src/CssModuleFactory.js +0 -32
- package/lib/webpack/plugins/mini-css-extract-plugin/src/cjs.js +0 -15
- package/lib/webpack/plugins/mini-css-extract-plugin/src/index.js +0 -542
- package/lib/webpack/plugins/mini-css-extract-plugin/src/loader.js +0 -319
- package/lib/webpack/plugins/mini-css-extract-plugin/src/utils.js +0 -97
- package/lib/webpack/plugins/mini-css-extract-plugin.d.ts +0 -1
- package/lib/webpack/plugins/mini-css-extract-plugin.js +0 -15
- package/lib/webpack/plugins/terser-webpack-plugin/package.json +0 -3
- package/lib/webpack/plugins/terser-webpack-plugin/src/Webpack4Cache.js +0 -187
- package/lib/webpack/plugins/terser-webpack-plugin/src/Webpack5Cache.js +0 -61
- package/lib/webpack/plugins/terser-webpack-plugin/src/index.js +0 -683
- package/lib/webpack/plugins/terser-webpack-plugin/src/minify.js +0 -197
- package/lib/webpack/plugins/terser-webpack-plugin.d.ts +0 -1
- package/lib/webpack/plugins/terser-webpack-plugin.js +0 -15
- package/lib/webpackHotDevClient/formatWebpackMessages.d.ts +0 -11
- package/lib/webpackHotDevClient/formatWebpackMessages.js +0 -127
- package/lib/webpackHotDevClient/webpackHotDevClient.js +0 -311
|
@@ -1,683 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.default = void 0;
|
|
7
|
-
|
|
8
|
-
function _react() {
|
|
9
|
-
const data = _interopRequireDefault(require("react"));
|
|
10
|
-
|
|
11
|
-
_react = function _react() {
|
|
12
|
-
return data;
|
|
13
|
-
};
|
|
14
|
-
|
|
15
|
-
return data;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
function _path() {
|
|
19
|
-
const data = _interopRequireDefault(require("path"));
|
|
20
|
-
|
|
21
|
-
_path = function _path() {
|
|
22
|
-
return data;
|
|
23
|
-
};
|
|
24
|
-
|
|
25
|
-
return data;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
function _os() {
|
|
29
|
-
const data = _interopRequireDefault(require("os"));
|
|
30
|
-
|
|
31
|
-
_os = function _os() {
|
|
32
|
-
return data;
|
|
33
|
-
};
|
|
34
|
-
|
|
35
|
-
return data;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
function _sourceMap() {
|
|
39
|
-
const data = require("@umijs/deps/compiled/source-map");
|
|
40
|
-
|
|
41
|
-
_sourceMap = function _sourceMap() {
|
|
42
|
-
return data;
|
|
43
|
-
};
|
|
44
|
-
|
|
45
|
-
return data;
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
function _webpack() {
|
|
49
|
-
const data = _interopRequireWildcard(require("webpack"));
|
|
50
|
-
|
|
51
|
-
_webpack = function _webpack() {
|
|
52
|
-
return data;
|
|
53
|
-
};
|
|
54
|
-
|
|
55
|
-
return data;
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
function _RequestShortener() {
|
|
59
|
-
const data = _interopRequireDefault(require("webpack/lib/RequestShortener"));
|
|
60
|
-
|
|
61
|
-
_RequestShortener = function _RequestShortener() {
|
|
62
|
-
return data;
|
|
63
|
-
};
|
|
64
|
-
|
|
65
|
-
return data;
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
function _serializeJavascript() {
|
|
69
|
-
const data = _interopRequireDefault(require("@umijs/deps/compiled/serialize-javascript"));
|
|
70
|
-
|
|
71
|
-
_serializeJavascript = function _serializeJavascript() {
|
|
72
|
-
return data;
|
|
73
|
-
};
|
|
74
|
-
|
|
75
|
-
return data;
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
var _package = _interopRequireDefault(require("terser/package.json"));
|
|
79
|
-
|
|
80
|
-
function _pLimit() {
|
|
81
|
-
const data = _interopRequireDefault(require("@umijs/deps/compiled/p-limit"));
|
|
82
|
-
|
|
83
|
-
_pLimit = function _pLimit() {
|
|
84
|
-
return data;
|
|
85
|
-
};
|
|
86
|
-
|
|
87
|
-
return data;
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
function _jestWorker() {
|
|
91
|
-
const data = _interopRequireDefault(require("jest-worker"));
|
|
92
|
-
|
|
93
|
-
_jestWorker = function _jestWorker() {
|
|
94
|
-
return data;
|
|
95
|
-
};
|
|
96
|
-
|
|
97
|
-
return data;
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
var _minify = require("./minify");
|
|
101
|
-
|
|
102
|
-
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
103
|
-
|
|
104
|
-
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
105
|
-
|
|
106
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
107
|
-
|
|
108
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
|
|
109
|
-
|
|
110
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
|
111
|
-
|
|
112
|
-
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
113
|
-
|
|
114
|
-
function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, 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 normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
|
|
115
|
-
|
|
116
|
-
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
117
|
-
|
|
118
|
-
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
119
|
-
|
|
120
|
-
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
|
|
121
|
-
|
|
122
|
-
function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
|
|
123
|
-
|
|
124
|
-
// webpack 5 exposes the sources property to ensure the right version of webpack-sources is used
|
|
125
|
-
const _ref = // eslint-disable-next-line global-require
|
|
126
|
-
_webpack().default.sources || require('@umijs/deps/compiled/webpack-sources'),
|
|
127
|
-
SourceMapSource = _ref.SourceMapSource,
|
|
128
|
-
RawSource = _ref.RawSource,
|
|
129
|
-
ConcatSource = _ref.ConcatSource;
|
|
130
|
-
|
|
131
|
-
class TerserPlugin {
|
|
132
|
-
constructor(options = {}) {
|
|
133
|
-
const minify = options.minify,
|
|
134
|
-
_options$terserOption = options.terserOptions,
|
|
135
|
-
terserOptions = _options$terserOption === void 0 ? {} : _options$terserOption,
|
|
136
|
-
_options$test = options.test,
|
|
137
|
-
test = _options$test === void 0 ? /\.[cm]?js(\?.*)?$/i : _options$test,
|
|
138
|
-
_options$extractComme = options.extractComments,
|
|
139
|
-
extractComments = _options$extractComme === void 0 ? true : _options$extractComme,
|
|
140
|
-
sourceMap = options.sourceMap,
|
|
141
|
-
_options$cache = options.cache,
|
|
142
|
-
cache = _options$cache === void 0 ? true : _options$cache,
|
|
143
|
-
_options$cacheKeys = options.cacheKeys,
|
|
144
|
-
cacheKeys = _options$cacheKeys === void 0 ? defaultCacheKeys => defaultCacheKeys : _options$cacheKeys,
|
|
145
|
-
_options$parallel = options.parallel,
|
|
146
|
-
parallel = _options$parallel === void 0 ? true : _options$parallel,
|
|
147
|
-
include = options.include,
|
|
148
|
-
exclude = options.exclude;
|
|
149
|
-
this.options = {
|
|
150
|
-
test,
|
|
151
|
-
extractComments,
|
|
152
|
-
sourceMap,
|
|
153
|
-
cache,
|
|
154
|
-
cacheKeys,
|
|
155
|
-
parallel,
|
|
156
|
-
include,
|
|
157
|
-
exclude,
|
|
158
|
-
minify,
|
|
159
|
-
terserOptions
|
|
160
|
-
};
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
static isSourceMap(input) {
|
|
164
|
-
// All required options for `new SourceMapConsumer(...options)`
|
|
165
|
-
// https://github.com/mozilla/source-map#new-sourcemapconsumerrawsourcemap
|
|
166
|
-
return Boolean(input && input.version && input.sources && Array.isArray(input.sources) && typeof input.mappings === 'string');
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
static buildError(error, file, sourceMap, requestShortener) {
|
|
170
|
-
if (error.line) {
|
|
171
|
-
const original = sourceMap && sourceMap.originalPositionFor({
|
|
172
|
-
line: error.line,
|
|
173
|
-
column: error.col
|
|
174
|
-
});
|
|
175
|
-
|
|
176
|
-
if (original && original.source && requestShortener) {
|
|
177
|
-
return new Error(`${file} from Terser\n${error.message} [${requestShortener.shorten(original.source)}:${original.line},${original.column}][${file}:${error.line},${error.col}]${error.stack ? `\n${error.stack.split('\n').slice(1).join('\n')}` : ''}`);
|
|
178
|
-
}
|
|
179
|
-
|
|
180
|
-
return new Error(`${file} from Terser\n${error.message} [${file}:${error.line},${error.col}]${error.stack ? `\n${error.stack.split('\n').slice(1).join('\n')}` : ''}`);
|
|
181
|
-
}
|
|
182
|
-
|
|
183
|
-
if (error.stack) {
|
|
184
|
-
return new Error(`${file} from Terser\n${error.stack}`);
|
|
185
|
-
}
|
|
186
|
-
|
|
187
|
-
return new Error(`${file} from Terser\n${error.message}`);
|
|
188
|
-
}
|
|
189
|
-
|
|
190
|
-
static isWebpack4() {
|
|
191
|
-
return _webpack().version[0] === '4';
|
|
192
|
-
}
|
|
193
|
-
|
|
194
|
-
static getAvailableNumberOfCores(parallel) {
|
|
195
|
-
// In some cases cpus() returns undefined
|
|
196
|
-
// https://github.com/nodejs/node/issues/19022
|
|
197
|
-
const cpus = _os().default.cpus() || {
|
|
198
|
-
length: 1
|
|
199
|
-
};
|
|
200
|
-
return parallel === true ? cpus.length - 1 : Math.min(Number(parallel) || 0, cpus.length - 1);
|
|
201
|
-
} // eslint-disable-next-line consistent-return
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
static getAsset(compilation, name) {
|
|
205
|
-
// New API
|
|
206
|
-
if (compilation.getAsset) {
|
|
207
|
-
return compilation.getAsset(name);
|
|
208
|
-
}
|
|
209
|
-
/* istanbul ignore next */
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
if (compilation.assets[name]) {
|
|
213
|
-
return {
|
|
214
|
-
name,
|
|
215
|
-
source: compilation.assets[name],
|
|
216
|
-
info: {}
|
|
217
|
-
};
|
|
218
|
-
}
|
|
219
|
-
}
|
|
220
|
-
|
|
221
|
-
static emitAsset(compilation, name, source, assetInfo) {
|
|
222
|
-
// New API
|
|
223
|
-
if (compilation.emitAsset) {
|
|
224
|
-
compilation.emitAsset(name, source, assetInfo);
|
|
225
|
-
} // eslint-disable-next-line no-param-reassign
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
compilation.assets[name] = source;
|
|
229
|
-
}
|
|
230
|
-
|
|
231
|
-
static updateAsset(compilation, name, newSource, assetInfo) {
|
|
232
|
-
// New API
|
|
233
|
-
if (compilation.updateAsset) {
|
|
234
|
-
compilation.updateAsset(name, newSource, assetInfo);
|
|
235
|
-
} // eslint-disable-next-line no-param-reassign
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
compilation.assets[name] = newSource;
|
|
239
|
-
}
|
|
240
|
-
|
|
241
|
-
optimize(compiler, compilation, assets, CacheEngine, weakCache) {
|
|
242
|
-
var _this = this;
|
|
243
|
-
|
|
244
|
-
return _asyncToGenerator(function* () {
|
|
245
|
-
let assetNames;
|
|
246
|
-
|
|
247
|
-
if (TerserPlugin.isWebpack4()) {
|
|
248
|
-
assetNames = [].concat(Array.from(compilation.additionalChunkAssets || [])).concat( // In webpack@4 it is `chunks`
|
|
249
|
-
Array.from(assets).reduce((acc, chunk) => acc.concat(Array.from(chunk.files || [])), [])).concat(Object.keys(compilation.assets)).filter((assetName, index, existingAssets) => existingAssets.indexOf(assetName) === index).filter(assetName => _webpack().ModuleFilenameHelpers.matchObject.bind( // eslint-disable-next-line no-undefined
|
|
250
|
-
undefined, _this.options)(assetName));
|
|
251
|
-
} else {
|
|
252
|
-
assetNames = Object.keys(assets).filter(assetName => _webpack().ModuleFilenameHelpers.matchObject.bind( // eslint-disable-next-line no-undefined
|
|
253
|
-
undefined, _this.options)(assetName));
|
|
254
|
-
}
|
|
255
|
-
|
|
256
|
-
if (assetNames.length === 0) {
|
|
257
|
-
return;
|
|
258
|
-
}
|
|
259
|
-
|
|
260
|
-
const availableNumberOfCores = TerserPlugin.getAvailableNumberOfCores(_this.options.parallel);
|
|
261
|
-
let concurrency = Infinity;
|
|
262
|
-
let worker;
|
|
263
|
-
|
|
264
|
-
if (availableNumberOfCores > 0) {
|
|
265
|
-
// Do not create unnecessary workers when the number of files is less than the available cores, it saves memory
|
|
266
|
-
const numWorkers = Math.min(assetNames.length, availableNumberOfCores);
|
|
267
|
-
concurrency = numWorkers;
|
|
268
|
-
worker = new (_jestWorker().default)(require.resolve('./minify'), {
|
|
269
|
-
numWorkers
|
|
270
|
-
}); // https://github.com/facebook/jest/issues/8872#issuecomment-524822081
|
|
271
|
-
|
|
272
|
-
const workerStdout = worker.getStdout();
|
|
273
|
-
|
|
274
|
-
if (workerStdout) {
|
|
275
|
-
workerStdout.on('data', chunk => {
|
|
276
|
-
return process.stdout.write(chunk);
|
|
277
|
-
});
|
|
278
|
-
}
|
|
279
|
-
|
|
280
|
-
const workerStderr = worker.getStderr();
|
|
281
|
-
|
|
282
|
-
if (workerStderr) {
|
|
283
|
-
workerStderr.on('data', chunk => {
|
|
284
|
-
return process.stderr.write(chunk);
|
|
285
|
-
});
|
|
286
|
-
}
|
|
287
|
-
}
|
|
288
|
-
|
|
289
|
-
const limit = (0, _pLimit().default)(concurrency);
|
|
290
|
-
const cache = new CacheEngine(compilation, {
|
|
291
|
-
cache: _this.options.cache
|
|
292
|
-
}, weakCache);
|
|
293
|
-
const allExtractedComments = new Map();
|
|
294
|
-
const scheduledTasks = [];
|
|
295
|
-
|
|
296
|
-
var _iterator = _createForOfIteratorHelper(assetNames),
|
|
297
|
-
_step;
|
|
298
|
-
|
|
299
|
-
try {
|
|
300
|
-
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
301
|
-
const name = _step.value;
|
|
302
|
-
scheduledTasks.push(limit( /*#__PURE__*/_asyncToGenerator(function* () {
|
|
303
|
-
const _TerserPlugin$getAsse = TerserPlugin.getAsset(compilation, name),
|
|
304
|
-
info = _TerserPlugin$getAsse.info,
|
|
305
|
-
inputSource = _TerserPlugin$getAsse.source; // Skip double minimize assets from child compilation
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
if (info.minimized) {
|
|
309
|
-
return;
|
|
310
|
-
}
|
|
311
|
-
|
|
312
|
-
let input;
|
|
313
|
-
let inputSourceMap; // TODO refactor after drop webpack@4, webpack@5 always has `sourceAndMap` on sources
|
|
314
|
-
|
|
315
|
-
if (_this.options.sourceMap && inputSource.sourceAndMap) {
|
|
316
|
-
const _inputSource$sourceAn = inputSource.sourceAndMap(),
|
|
317
|
-
source = _inputSource$sourceAn.source,
|
|
318
|
-
map = _inputSource$sourceAn.map;
|
|
319
|
-
|
|
320
|
-
input = source;
|
|
321
|
-
|
|
322
|
-
if (map) {
|
|
323
|
-
if (TerserPlugin.isSourceMap(map)) {
|
|
324
|
-
inputSourceMap = map;
|
|
325
|
-
} else {
|
|
326
|
-
inputSourceMap = map;
|
|
327
|
-
compilation.warnings.push(new Error(`${name} contains invalid source map`));
|
|
328
|
-
}
|
|
329
|
-
}
|
|
330
|
-
} else {
|
|
331
|
-
input = inputSource.source();
|
|
332
|
-
inputSourceMap = null;
|
|
333
|
-
}
|
|
334
|
-
|
|
335
|
-
if (Buffer.isBuffer(input)) {
|
|
336
|
-
input = input.toString();
|
|
337
|
-
}
|
|
338
|
-
|
|
339
|
-
const cacheData = {
|
|
340
|
-
name,
|
|
341
|
-
inputSource
|
|
342
|
-
};
|
|
343
|
-
|
|
344
|
-
if (TerserPlugin.isWebpack4()) {
|
|
345
|
-
if (_this.options.cache) {
|
|
346
|
-
const _compilation$outputOp2 = compilation.outputOptions,
|
|
347
|
-
hashSalt = _compilation$outputOp2.hashSalt,
|
|
348
|
-
hashDigest = _compilation$outputOp2.hashDigest,
|
|
349
|
-
hashDigestLength = _compilation$outputOp2.hashDigestLength,
|
|
350
|
-
hashFunction = _compilation$outputOp2.hashFunction;
|
|
351
|
-
|
|
352
|
-
const hash = _webpack().util.createHash(hashFunction);
|
|
353
|
-
|
|
354
|
-
if (hashSalt) {
|
|
355
|
-
hash.update(hashSalt);
|
|
356
|
-
}
|
|
357
|
-
|
|
358
|
-
hash.update(input);
|
|
359
|
-
const digest = hash.digest(hashDigest);
|
|
360
|
-
cacheData.input = input;
|
|
361
|
-
cacheData.inputSourceMap = inputSourceMap;
|
|
362
|
-
cacheData.cacheKeys = _this.options.cacheKeys({
|
|
363
|
-
terser: _package.default.version,
|
|
364
|
-
// eslint-disable-next-line global-require
|
|
365
|
-
'terser-webpack-plugin': require('../package.json').version,
|
|
366
|
-
'terser-webpack-plugin-options': _this.options,
|
|
367
|
-
name,
|
|
368
|
-
contentHash: digest.substr(0, hashDigestLength)
|
|
369
|
-
}, name);
|
|
370
|
-
}
|
|
371
|
-
}
|
|
372
|
-
|
|
373
|
-
let output = yield cache.get(cacheData, {
|
|
374
|
-
RawSource,
|
|
375
|
-
ConcatSource,
|
|
376
|
-
SourceMapSource
|
|
377
|
-
});
|
|
378
|
-
|
|
379
|
-
if (!output) {
|
|
380
|
-
const minimizerOptions = {
|
|
381
|
-
name,
|
|
382
|
-
input,
|
|
383
|
-
inputSourceMap,
|
|
384
|
-
minify: _this.options.minify,
|
|
385
|
-
minimizerOptions: _this.options.terserOptions,
|
|
386
|
-
extractComments: _this.options.extractComments
|
|
387
|
-
};
|
|
388
|
-
|
|
389
|
-
if (/\.mjs(\?.*)?$/i.test(name)) {
|
|
390
|
-
_this.options.terserOptions.module = true;
|
|
391
|
-
}
|
|
392
|
-
|
|
393
|
-
try {
|
|
394
|
-
output = yield worker ? worker.transform((0, _serializeJavascript().default)(minimizerOptions)) : (0, _minify.minify)(minimizerOptions);
|
|
395
|
-
} catch (error) {
|
|
396
|
-
compilation.errors.push(TerserPlugin.buildError(error, name, inputSourceMap && TerserPlugin.isSourceMap(inputSourceMap) ? new (_sourceMap().SourceMapConsumer)(inputSourceMap) : null, new (_RequestShortener().default)(compiler.context)));
|
|
397
|
-
return;
|
|
398
|
-
}
|
|
399
|
-
|
|
400
|
-
let shebang;
|
|
401
|
-
|
|
402
|
-
if (_this.options.extractComments.banner !== false && output.extractedComments && output.extractedComments.length > 0 && output.code.startsWith('#!')) {
|
|
403
|
-
const firstNewlinePosition = output.code.indexOf('\n');
|
|
404
|
-
shebang = output.code.substring(0, firstNewlinePosition);
|
|
405
|
-
output.code = output.code.substring(firstNewlinePosition + 1);
|
|
406
|
-
}
|
|
407
|
-
|
|
408
|
-
if (output.map) {
|
|
409
|
-
output.source = new SourceMapSource(output.code, name, output.map, input, inputSourceMap, true);
|
|
410
|
-
} else {
|
|
411
|
-
output.source = new RawSource(output.code);
|
|
412
|
-
}
|
|
413
|
-
|
|
414
|
-
let commentsFilename;
|
|
415
|
-
|
|
416
|
-
if (output.extractedComments && output.extractedComments.length > 0) {
|
|
417
|
-
commentsFilename = _this.options.extractComments.filename || '[file].LICENSE.txt[query]';
|
|
418
|
-
let query = '';
|
|
419
|
-
let filename = name;
|
|
420
|
-
const querySplit = filename.indexOf('?');
|
|
421
|
-
|
|
422
|
-
if (querySplit >= 0) {
|
|
423
|
-
query = filename.substr(querySplit);
|
|
424
|
-
filename = filename.substr(0, querySplit);
|
|
425
|
-
}
|
|
426
|
-
|
|
427
|
-
const lastSlashIndex = filename.lastIndexOf('/');
|
|
428
|
-
const basename = lastSlashIndex === -1 ? filename : filename.substr(lastSlashIndex + 1);
|
|
429
|
-
const data = {
|
|
430
|
-
filename,
|
|
431
|
-
basename,
|
|
432
|
-
query
|
|
433
|
-
};
|
|
434
|
-
commentsFilename = compilation.getPath(commentsFilename, data);
|
|
435
|
-
output.commentsFilename = commentsFilename;
|
|
436
|
-
let banner; // Add a banner to the original file
|
|
437
|
-
|
|
438
|
-
if (_this.options.extractComments.banner !== false) {
|
|
439
|
-
banner = _this.options.extractComments.banner || `For license information please see ${_path().default.relative(_path().default.dirname(name), commentsFilename).replace(/\\/g, '/')}`;
|
|
440
|
-
|
|
441
|
-
if (typeof banner === 'function') {
|
|
442
|
-
banner = banner(commentsFilename);
|
|
443
|
-
}
|
|
444
|
-
|
|
445
|
-
if (banner) {
|
|
446
|
-
output.source = new ConcatSource(shebang ? `${shebang}\n` : '', `/*! ${banner} */\n`, output.source);
|
|
447
|
-
output.banner = banner;
|
|
448
|
-
output.shebang = shebang;
|
|
449
|
-
}
|
|
450
|
-
}
|
|
451
|
-
|
|
452
|
-
const extractedCommentsString = output.extractedComments.sort().join('\n\n');
|
|
453
|
-
output.extractedCommentsSource = new RawSource(`${extractedCommentsString}\n`);
|
|
454
|
-
}
|
|
455
|
-
|
|
456
|
-
yield cache.store(_objectSpread(_objectSpread({}, output), cacheData));
|
|
457
|
-
} // TODO `...` required only for webpack@4
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
const newInfo = _objectSpread(_objectSpread({}, info), {}, {
|
|
461
|
-
minimized: true
|
|
462
|
-
});
|
|
463
|
-
|
|
464
|
-
const _output = output,
|
|
465
|
-
source = _output.source,
|
|
466
|
-
extractedCommentsSource = _output.extractedCommentsSource; // Write extracted comments to commentsFilename
|
|
467
|
-
|
|
468
|
-
if (extractedCommentsSource) {
|
|
469
|
-
const _output2 = output,
|
|
470
|
-
commentsFilename = _output2.commentsFilename; // TODO `...` required only for webpack@4
|
|
471
|
-
|
|
472
|
-
newInfo.related = _objectSpread({
|
|
473
|
-
license: commentsFilename
|
|
474
|
-
}, info.related);
|
|
475
|
-
allExtractedComments.set(name, {
|
|
476
|
-
extractedCommentsSource,
|
|
477
|
-
commentsFilename
|
|
478
|
-
});
|
|
479
|
-
}
|
|
480
|
-
|
|
481
|
-
TerserPlugin.updateAsset(compilation, name, source, newInfo);
|
|
482
|
-
})));
|
|
483
|
-
}
|
|
484
|
-
} catch (err) {
|
|
485
|
-
_iterator.e(err);
|
|
486
|
-
} finally {
|
|
487
|
-
_iterator.f();
|
|
488
|
-
}
|
|
489
|
-
|
|
490
|
-
yield Promise.all(scheduledTasks);
|
|
491
|
-
|
|
492
|
-
if (worker) {
|
|
493
|
-
yield worker.end();
|
|
494
|
-
}
|
|
495
|
-
|
|
496
|
-
yield Array.from(allExtractedComments).sort().reduce( /*#__PURE__*/function () {
|
|
497
|
-
var _ref2 = _asyncToGenerator(function* (previousPromise, [from, value]) {
|
|
498
|
-
const previous = yield previousPromise;
|
|
499
|
-
const commentsFilename = value.commentsFilename,
|
|
500
|
-
extractedCommentsSource = value.extractedCommentsSource;
|
|
501
|
-
|
|
502
|
-
if (previous && previous.commentsFilename === commentsFilename) {
|
|
503
|
-
const previousFrom = previous.from,
|
|
504
|
-
prevSource = previous.source;
|
|
505
|
-
const mergedName = `${previousFrom}|${from}`;
|
|
506
|
-
const cacheData = {
|
|
507
|
-
target: 'comments'
|
|
508
|
-
};
|
|
509
|
-
|
|
510
|
-
if (TerserPlugin.isWebpack4()) {
|
|
511
|
-
const _compilation$outputOp = compilation.outputOptions,
|
|
512
|
-
hashSalt = _compilation$outputOp.hashSalt,
|
|
513
|
-
hashDigest = _compilation$outputOp.hashDigest,
|
|
514
|
-
hashDigestLength = _compilation$outputOp.hashDigestLength,
|
|
515
|
-
hashFunction = _compilation$outputOp.hashFunction;
|
|
516
|
-
|
|
517
|
-
const previousHash = _webpack().util.createHash(hashFunction);
|
|
518
|
-
|
|
519
|
-
const hash = _webpack().util.createHash(hashFunction);
|
|
520
|
-
|
|
521
|
-
if (hashSalt) {
|
|
522
|
-
previousHash.update(hashSalt);
|
|
523
|
-
hash.update(hashSalt);
|
|
524
|
-
}
|
|
525
|
-
|
|
526
|
-
previousHash.update(prevSource.source());
|
|
527
|
-
hash.update(extractedCommentsSource.source());
|
|
528
|
-
const previousDigest = previousHash.digest(hashDigest);
|
|
529
|
-
const digest = hash.digest(hashDigest);
|
|
530
|
-
cacheData.cacheKeys = {
|
|
531
|
-
mergedName,
|
|
532
|
-
previousContentHash: previousDigest.substr(0, hashDigestLength),
|
|
533
|
-
contentHash: digest.substr(0, hashDigestLength)
|
|
534
|
-
};
|
|
535
|
-
cacheData.inputSource = extractedCommentsSource;
|
|
536
|
-
} else {
|
|
537
|
-
const mergedInputSource = [prevSource, extractedCommentsSource];
|
|
538
|
-
cacheData.name = `${commentsFilename}|${mergedName}`;
|
|
539
|
-
cacheData.inputSource = mergedInputSource;
|
|
540
|
-
}
|
|
541
|
-
|
|
542
|
-
let output = yield cache.get(cacheData, {
|
|
543
|
-
ConcatSource
|
|
544
|
-
});
|
|
545
|
-
|
|
546
|
-
if (!output) {
|
|
547
|
-
output = new ConcatSource(Array.from(new Set([...prevSource.source().split('\n\n'), ...extractedCommentsSource.source().split('\n\n')])).join('\n\n'));
|
|
548
|
-
yield cache.store(_objectSpread(_objectSpread({}, cacheData), {}, {
|
|
549
|
-
output
|
|
550
|
-
}));
|
|
551
|
-
}
|
|
552
|
-
|
|
553
|
-
TerserPlugin.updateAsset(compilation, commentsFilename, output);
|
|
554
|
-
return {
|
|
555
|
-
commentsFilename,
|
|
556
|
-
from: mergedName,
|
|
557
|
-
source: output
|
|
558
|
-
};
|
|
559
|
-
}
|
|
560
|
-
|
|
561
|
-
const existingAsset = TerserPlugin.getAsset(compilation, commentsFilename);
|
|
562
|
-
|
|
563
|
-
if (existingAsset) {
|
|
564
|
-
return {
|
|
565
|
-
commentsFilename,
|
|
566
|
-
from: commentsFilename,
|
|
567
|
-
source: existingAsset.source
|
|
568
|
-
};
|
|
569
|
-
}
|
|
570
|
-
|
|
571
|
-
TerserPlugin.emitAsset(compilation, commentsFilename, extractedCommentsSource);
|
|
572
|
-
return {
|
|
573
|
-
commentsFilename,
|
|
574
|
-
from,
|
|
575
|
-
source: extractedCommentsSource
|
|
576
|
-
};
|
|
577
|
-
});
|
|
578
|
-
|
|
579
|
-
return function (_x, _x2) {
|
|
580
|
-
return _ref2.apply(this, arguments);
|
|
581
|
-
};
|
|
582
|
-
}(), Promise.resolve());
|
|
583
|
-
})();
|
|
584
|
-
}
|
|
585
|
-
|
|
586
|
-
static getEcmaVersion(environment) {
|
|
587
|
-
// ES 6th
|
|
588
|
-
if (environment.arrowFunction || environment.const || environment.destructuring || environment.forOf || environment.module) {
|
|
589
|
-
return 2015;
|
|
590
|
-
} // ES 11th
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
if (environment.bigIntLiteral || environment.dynamicImport) {
|
|
594
|
-
return 2020;
|
|
595
|
-
}
|
|
596
|
-
|
|
597
|
-
return 5;
|
|
598
|
-
}
|
|
599
|
-
|
|
600
|
-
apply(compiler) {
|
|
601
|
-
const _compiler$options = compiler.options,
|
|
602
|
-
devtool = _compiler$options.devtool,
|
|
603
|
-
output = _compiler$options.output,
|
|
604
|
-
plugins = _compiler$options.plugins;
|
|
605
|
-
this.options.sourceMap = typeof this.options.sourceMap === 'undefined' ? devtool && !devtool.includes('eval') && !devtool.includes('cheap') && (devtool.includes('source-map') || // Todo remove when `webpack@4` support will be dropped
|
|
606
|
-
devtool.includes('sourcemap')) || plugins && plugins.some(plugin => plugin instanceof _webpack().SourceMapDevToolPlugin && plugin.options && plugin.options.columns) : Boolean(this.options.sourceMap);
|
|
607
|
-
|
|
608
|
-
if (typeof this.options.terserOptions.module === 'undefined' && typeof output.module !== 'undefined') {
|
|
609
|
-
this.options.terserOptions.module = output.module;
|
|
610
|
-
}
|
|
611
|
-
|
|
612
|
-
if (typeof this.options.terserOptions.ecma === 'undefined') {
|
|
613
|
-
this.options.terserOptions.ecma = TerserPlugin.getEcmaVersion(output.environment || {});
|
|
614
|
-
}
|
|
615
|
-
|
|
616
|
-
const pluginName = this.constructor.name;
|
|
617
|
-
const weakCache = TerserPlugin.isWebpack4() && (this.options.cache === true || typeof this.options.cache === 'string') ? new WeakMap() : // eslint-disable-next-line no-undefined
|
|
618
|
-
undefined;
|
|
619
|
-
compiler.hooks.compilation.tap(pluginName, compilation => {
|
|
620
|
-
if (this.options.sourceMap) {
|
|
621
|
-
compilation.hooks.buildModule.tap(pluginName, moduleArg => {
|
|
622
|
-
// to get detailed location info about errors
|
|
623
|
-
// eslint-disable-next-line no-param-reassign
|
|
624
|
-
moduleArg.useSourceMap = true;
|
|
625
|
-
});
|
|
626
|
-
}
|
|
627
|
-
|
|
628
|
-
if (TerserPlugin.isWebpack4()) {
|
|
629
|
-
// eslint-disable-next-line global-require
|
|
630
|
-
const CacheEngine = require('./Webpack4Cache').default;
|
|
631
|
-
|
|
632
|
-
const mainTemplate = compilation.mainTemplate,
|
|
633
|
-
chunkTemplate = compilation.chunkTemplate;
|
|
634
|
-
const data = (0, _serializeJavascript().default)({
|
|
635
|
-
terser: _package.default.version,
|
|
636
|
-
terserOptions: this.options.terserOptions
|
|
637
|
-
}); // Regenerate `contenthash` for minified assets
|
|
638
|
-
|
|
639
|
-
for (var _i = 0, _arr = [mainTemplate, chunkTemplate]; _i < _arr.length; _i++) {
|
|
640
|
-
const template = _arr[_i];
|
|
641
|
-
template.hooks.hashForChunk.tap(pluginName, hash => {
|
|
642
|
-
hash.update('TerserPlugin');
|
|
643
|
-
hash.update(data);
|
|
644
|
-
});
|
|
645
|
-
}
|
|
646
|
-
|
|
647
|
-
compilation.hooks.optimizeChunkAssets.tapPromise(pluginName, assets => this.optimize(compiler, compilation, assets, CacheEngine, weakCache));
|
|
648
|
-
} else {
|
|
649
|
-
// eslint-disable-next-line global-require
|
|
650
|
-
const CacheEngine = require('./Webpack5Cache').default; // eslint-disable-next-line global-require
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
const Compilation = require('webpack/lib/Compilation');
|
|
654
|
-
|
|
655
|
-
const hooks = _webpack().javascript.JavascriptModulesPlugin.getCompilationHooks(compilation);
|
|
656
|
-
|
|
657
|
-
const data = (0, _serializeJavascript().default)({
|
|
658
|
-
terser: _package.default.version,
|
|
659
|
-
terserOptions: this.options.terserOptions
|
|
660
|
-
});
|
|
661
|
-
hooks.chunkHash.tap(pluginName, (chunk, hash) => {
|
|
662
|
-
hash.update('TerserPlugin');
|
|
663
|
-
hash.update(data);
|
|
664
|
-
});
|
|
665
|
-
compilation.hooks.processAssets.tapPromise({
|
|
666
|
-
name: pluginName,
|
|
667
|
-
stage: Compilation.PROCESS_ASSETS_STAGE_OPTIMIZE_SIZE
|
|
668
|
-
}, assets => this.optimize(compiler, compilation, assets, CacheEngine));
|
|
669
|
-
compilation.hooks.statsPrinter.tap(pluginName, stats => {
|
|
670
|
-
stats.hooks.print.for('asset.info.minimized').tap('terser-webpack-plugin', (minimized, {
|
|
671
|
-
green,
|
|
672
|
-
formatFlag
|
|
673
|
-
}) => // eslint-disable-next-line no-undefined
|
|
674
|
-
minimized ? green(formatFlag('minimized')) : undefined);
|
|
675
|
-
});
|
|
676
|
-
}
|
|
677
|
-
});
|
|
678
|
-
}
|
|
679
|
-
|
|
680
|
-
}
|
|
681
|
-
|
|
682
|
-
var _default = TerserPlugin;
|
|
683
|
-
exports.default = _default;
|