@unpackjs/core 1.7.5 → 1.7.6
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/compiled/css-loader/index.js +180 -178
- package/compiled/less-loader/index.js +11 -11
- package/compiled/line-diff/index.js +4 -4
- package/compiled/portfinder/index.js +37 -37
- package/compiled/postcss-loader/index.js +261 -256
- package/compiled/sass-loader/index.js +18 -18
- package/compiled/semver/index.js +188 -170
- package/compiled/semver/package.json +1 -1
- package/compiled/style-loader/index.js +13 -13
- package/compiled/webpack-bundle-analyzer/index.js +198 -198
- package/compiled/webpack-merge/index.js +29 -29
- package/dist/bundler-config/chunkSplit.cjs +169 -156
- package/dist/bundler-config/chunkSplit.d.ts +1 -1
- package/dist/bundler-config/chunkSplit.js +125 -134
- package/dist/bundler-config/css.cjs +181 -158
- package/dist/bundler-config/css.d.ts +1 -1
- package/dist/bundler-config/css.js +139 -151
- package/dist/bundler-config/experimentCss.cjs +203 -159
- package/dist/bundler-config/experimentCss.d.ts +1 -1
- package/dist/bundler-config/experimentCss.js +162 -152
- package/dist/bundler-config/helper.cjs +82 -78
- package/dist/bundler-config/helper.js +36 -55
- package/dist/bundler-config/index.cjs +260 -209
- package/dist/bundler-config/index.d.ts +1 -1
- package/dist/bundler-config/index.d.ts.map +1 -1
- package/dist/bundler-config/index.js +209 -182
- package/dist/bundler-config/jsMinify.cjs +114 -95
- package/dist/bundler-config/jsMinify.js +70 -73
- package/dist/colors.cjs +83 -56
- package/dist/colors.js +38 -37
- package/dist/config.cjs +107 -93
- package/dist/config.d.ts +1 -1
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +64 -70
- package/dist/constants.cjs +62 -62
- package/dist/constants.js +20 -38
- package/dist/createUnpack.cjs +111 -104
- package/dist/createUnpack.js +67 -82
- package/dist/global.cjs +36 -0
- package/dist/global.d.ts +2 -0
- package/dist/global.d.ts.map +1 -0
- package/dist/global.js +4 -0
- package/dist/index.cjs +174 -51
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +33 -15
- package/dist/lightningcss/cache.cjs +40 -32
- package/dist/lightningcss/cache.js +10 -20
- package/dist/lightningcss/loader.cjs +56 -53
- package/dist/lightningcss/loader.d.ts +1 -1
- package/dist/lightningcss/loader.js +25 -34
- package/dist/lightningcss/minimizer.cjs +90 -109
- package/dist/lightningcss/minimizer.d.ts +1 -1
- package/dist/lightningcss/minimizer.js +59 -87
- package/dist/logger.cjs +104 -98
- package/dist/logger.d.ts +1 -1
- package/dist/logger.js +59 -76
- package/dist/openBrowser.cjs +104 -81
- package/dist/openBrowser.js +56 -52
- package/dist/plugin-progress/rspack.cjs +104 -79
- package/dist/plugin-progress/rspack.d.ts +1 -1
- package/dist/plugin-progress/rspack.js +59 -57
- package/dist/plugin-progress/webpack.cjs +111 -89
- package/dist/plugin-progress/webpack.d.ts +1 -1
- package/dist/plugin-progress/webpack.js +65 -67
- package/dist/plugin.cjs +38 -29
- package/dist/plugin.js +8 -17
- package/dist/prebundleDeps.cjs +327 -337
- package/dist/prebundleDeps.d.ts.map +1 -1
- package/dist/prebundleDeps.js +278 -324
- package/dist/progressBar.cjs +82 -65
- package/dist/progressBar.js +38 -43
- package/dist/reporter.cjs +135 -120
- package/dist/reporter.js +88 -98
- package/dist/run/build.cjs +68 -67
- package/dist/run/build.d.ts +1 -1
- package/dist/run/build.js +24 -45
- package/dist/run/dev.cjs +96 -83
- package/dist/run/dev.d.ts +1 -1
- package/dist/run/dev.d.ts.map +1 -1
- package/dist/run/dev.js +50 -61
- package/dist/run/index.cjs +74 -21
- package/dist/run/index.js +2 -9
- package/dist/typed-css-modules/loader.cjs +179 -188
- package/dist/typed-css-modules/loader.d.ts +1 -1
- package/dist/typed-css-modules/loader.js +118 -151
- package/dist/typed-css-modules/plugin.cjs +113 -88
- package/dist/typed-css-modules/plugin.d.ts +1 -1
- package/dist/typed-css-modules/plugin.js +68 -66
- package/dist/typed-css-modules/utils.cjs +43 -42
- package/dist/typed-css-modules/utils.d.ts +1 -1
- package/dist/typed-css-modules/utils.js +13 -30
- package/dist/types/chunkSplit.cjs +19 -15
- package/dist/types/chunkSplit.d.ts +2 -10
- package/dist/types/chunkSplit.d.ts.map +1 -1
- package/dist/types/chunkSplit.js +2 -9
- package/dist/types/config.cjs +19 -15
- package/dist/types/config.d.ts +1 -1
- package/dist/types/config.js +2 -9
- package/dist/types/index.cjs +101 -27
- package/dist/types/index.js +2 -9
- package/dist/types/lightningcss.cjs +19 -15
- package/dist/types/lightningcss.js +2 -9
- package/dist/types/logger.cjs +43 -34
- package/dist/types/logger.js +13 -22
- package/dist/types/plugin.cjs +19 -15
- package/dist/types/plugin.js +2 -9
- package/dist/utils.cjs +280 -304
- package/dist/utils.js +195 -241
- package/dist/watchFiles.cjs +73 -0
- package/dist/watchFiles.d.ts +3 -0
- package/dist/watchFiles.d.ts.map +1 -0
- package/dist/watchFiles.js +27 -0
- package/package.json +14 -17
- package/compiled/commander/index.d.ts +0 -1047
- package/compiled/commander/index.js +0 -2428
- package/compiled/commander/license +0 -22
- package/compiled/commander/package.json +0 -1
- package/dist/bundleRequire.cjs +0 -200
- package/dist/bundleRequire.d.ts +0 -5
- package/dist/bundleRequire.d.ts.map +0 -1
- package/dist/bundleRequire.js +0 -173
|
@@ -1,56 +1,59 @@
|
|
|
1
|
-
|
|
2
|
-
var
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
var
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
};
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
default: () => loader_default
|
|
1
|
+
"use strict";
|
|
2
|
+
var __webpack_require__ = {};
|
|
3
|
+
(()=>{
|
|
4
|
+
__webpack_require__.d = function(exports1, definition) {
|
|
5
|
+
for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: definition[key]
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
})();
|
|
11
|
+
(()=>{
|
|
12
|
+
__webpack_require__.o = function(obj, prop) {
|
|
13
|
+
return Object.prototype.hasOwnProperty.call(obj, prop);
|
|
14
|
+
};
|
|
15
|
+
})();
|
|
16
|
+
(()=>{
|
|
17
|
+
__webpack_require__.r = function(exports1) {
|
|
18
|
+
if ('undefined' != typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
|
|
19
|
+
value: 'Module'
|
|
20
|
+
});
|
|
21
|
+
Object.defineProperty(exports1, '__esModule', {
|
|
22
|
+
value: true
|
|
23
|
+
});
|
|
24
|
+
};
|
|
25
|
+
})();
|
|
26
|
+
var __webpack_exports__ = {};
|
|
27
|
+
__webpack_require__.r(__webpack_exports__);
|
|
28
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
29
|
+
default: ()=>loader_rslib_entry_
|
|
31
30
|
});
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
var import_cache = require("./cache.cjs");
|
|
31
|
+
const external_node_buffer_namespaceObject = require("node:buffer");
|
|
32
|
+
const external_lightningcss_namespaceObject = require("lightningcss");
|
|
33
|
+
const external_cache_cjs_namespaceObject = require("./cache.cjs");
|
|
36
34
|
async function LightningcssLoader(source, prevSourceMap) {
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
35
|
+
const done = this.async();
|
|
36
|
+
const options = this.getOptions();
|
|
37
|
+
const { implementation, sourceMap, ...opts } = options;
|
|
38
|
+
const transform = (null == implementation ? void 0 : implementation.transform) ?? external_lightningcss_namespaceObject.transform;
|
|
39
|
+
try {
|
|
40
|
+
const { code, map } = transform({
|
|
41
|
+
filename: this.resourcePath,
|
|
42
|
+
code: external_node_buffer_namespaceObject.Buffer.from(source),
|
|
43
|
+
sourceMap,
|
|
44
|
+
targets: (0, external_cache_cjs_namespaceObject.getLightningcssTargets)(),
|
|
45
|
+
inputSourceMap: sourceMap && prevSourceMap ? JSON.stringify(prevSourceMap) : void 0,
|
|
46
|
+
...opts
|
|
47
|
+
});
|
|
48
|
+
const codeAsString = code.toString();
|
|
49
|
+
done(null, codeAsString, map && JSON.parse(map.toString()));
|
|
50
|
+
} catch (error) {
|
|
51
|
+
done(error);
|
|
52
|
+
}
|
|
55
53
|
}
|
|
56
|
-
|
|
54
|
+
const loader_rslib_entry_ = LightningcssLoader;
|
|
55
|
+
var __webpack_export_target__ = exports;
|
|
56
|
+
for(var __webpack_i__ in __webpack_exports__)__webpack_export_target__[__webpack_i__] = __webpack_exports__[__webpack_i__];
|
|
57
|
+
if (__webpack_exports__.__esModule) Object.defineProperty(__webpack_export_target__, '__esModule', {
|
|
58
|
+
value: true
|
|
59
|
+
});
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { LightningcssLoaderOptions } from '
|
|
1
|
+
import type { LightningcssLoaderOptions } from 'src/types/index';
|
|
2
2
|
import type { LoaderContext } from 'webpack';
|
|
3
3
|
declare function LightningcssLoader(this: LoaderContext<LightningcssLoaderOptions>, source: string, prevSourceMap?: Record<string, unknown>): Promise<void>;
|
|
4
4
|
export default LightningcssLoader;
|
|
@@ -1,36 +1,27 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
var getFilename = () => fileURLToPath(import.meta.url);
|
|
7
|
-
var getDirname = () => path.dirname(getFilename());
|
|
8
|
-
var __dirname = /* @__PURE__ */ getDirname();
|
|
9
|
-
var __filename = /* @__PURE__ */ getFilename();
|
|
10
|
-
import { Buffer } from "node:buffer";
|
|
11
|
-
import * as lightningcss from "lightningcss";
|
|
12
|
-
import { getLightningcssTargets } from "./cache.js";
|
|
1
|
+
import __rslib_shim_module__ from 'module';
|
|
2
|
+
/*#__PURE__*/ import.meta.url;
|
|
3
|
+
import * as __WEBPACK_EXTERNAL_MODULE_node_buffer_fb286294__ from "node:buffer";
|
|
4
|
+
import * as __WEBPACK_EXTERNAL_MODULE_lightningcss__ from "lightningcss";
|
|
5
|
+
import * as __WEBPACK_EXTERNAL_MODULE__cache_js_cdc28063__ from "./cache.js";
|
|
13
6
|
async function LightningcssLoader(source, prevSourceMap) {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
7
|
+
const done = this.async();
|
|
8
|
+
const options = this.getOptions();
|
|
9
|
+
const { implementation, sourceMap, ...opts } = options;
|
|
10
|
+
const transform = (null == implementation ? void 0 : implementation.transform) ?? __WEBPACK_EXTERNAL_MODULE_lightningcss__.transform;
|
|
11
|
+
try {
|
|
12
|
+
const { code, map } = transform({
|
|
13
|
+
filename: this.resourcePath,
|
|
14
|
+
code: __WEBPACK_EXTERNAL_MODULE_node_buffer_fb286294__.Buffer.from(source),
|
|
15
|
+
sourceMap,
|
|
16
|
+
targets: (0, __WEBPACK_EXTERNAL_MODULE__cache_js_cdc28063__.getLightningcssTargets)(),
|
|
17
|
+
inputSourceMap: sourceMap && prevSourceMap ? JSON.stringify(prevSourceMap) : void 0,
|
|
18
|
+
...opts
|
|
19
|
+
});
|
|
20
|
+
const codeAsString = code.toString();
|
|
21
|
+
done(null, codeAsString, map && JSON.parse(map.toString()));
|
|
22
|
+
} catch (error) {
|
|
23
|
+
done(error);
|
|
24
|
+
}
|
|
32
25
|
}
|
|
33
|
-
|
|
34
|
-
export {
|
|
35
|
-
loader_default as default
|
|
36
|
-
};
|
|
26
|
+
const loader_rslib_entry_ = LightningcssLoader;
|
|
27
|
+
export { loader_rslib_entry_ as default };
|
|
@@ -1,114 +1,95 @@
|
|
|
1
|
-
|
|
2
|
-
var
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
var
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
};
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
default: () => minimizer_default
|
|
1
|
+
"use strict";
|
|
2
|
+
var __webpack_require__ = {};
|
|
3
|
+
(()=>{
|
|
4
|
+
__webpack_require__.d = function(exports1, definition) {
|
|
5
|
+
for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: definition[key]
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
})();
|
|
11
|
+
(()=>{
|
|
12
|
+
__webpack_require__.o = function(obj, prop) {
|
|
13
|
+
return Object.prototype.hasOwnProperty.call(obj, prop);
|
|
14
|
+
};
|
|
15
|
+
})();
|
|
16
|
+
(()=>{
|
|
17
|
+
__webpack_require__.r = function(exports1) {
|
|
18
|
+
if ('undefined' != typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
|
|
19
|
+
value: 'Module'
|
|
20
|
+
});
|
|
21
|
+
Object.defineProperty(exports1, '__esModule', {
|
|
22
|
+
value: true
|
|
23
|
+
});
|
|
24
|
+
};
|
|
25
|
+
})();
|
|
26
|
+
var __webpack_exports__ = {};
|
|
27
|
+
__webpack_require__.r(__webpack_exports__);
|
|
28
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
29
|
+
LightningcssMinifyPlugin: ()=>LightningcssMinifyPlugin,
|
|
30
|
+
default: ()=>minimizer_rslib_entry_
|
|
32
31
|
});
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
}
|
|
43
|
-
apply(compiler) {
|
|
44
|
-
compiler.hooks.compilation.tap(PLUGIN_NAME, (compilation) => {
|
|
45
|
-
compilation.hooks.processAssets.tapPromise(
|
|
46
|
-
{
|
|
47
|
-
name: PLUGIN_NAME,
|
|
48
|
-
stage: compiler.webpack.Compilation.PROCESS_ASSETS_STAGE_OPTIMIZE_SIZE
|
|
49
|
-
},
|
|
50
|
-
async () => this.transformAssets(compilation)
|
|
51
|
-
);
|
|
52
|
-
compilation.hooks.statsPrinter.tap(PLUGIN_NAME, (statsPrinter) => {
|
|
53
|
-
statsPrinter.hooks.print.for("asset.info.minimized").tap(
|
|
54
|
-
PLUGIN_NAME,
|
|
55
|
-
(minimized, { green, formatFlag }) => minimized && green && formatFlag ? green(formatFlag("minimized")) : ""
|
|
56
|
-
);
|
|
57
|
-
});
|
|
32
|
+
const external_node_buffer_namespaceObject = require("node:buffer");
|
|
33
|
+
const external_lightningcss_namespaceObject = require("lightningcss");
|
|
34
|
+
const external_cache_cjs_namespaceObject = require("./cache.cjs");
|
|
35
|
+
function _define_property(obj, key, value) {
|
|
36
|
+
if (key in obj) Object.defineProperty(obj, key, {
|
|
37
|
+
value: value,
|
|
38
|
+
enumerable: true,
|
|
39
|
+
configurable: true,
|
|
40
|
+
writable: true
|
|
58
41
|
});
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
/\.css$/.test(asset.name)
|
|
74
|
-
)
|
|
75
|
-
);
|
|
76
|
-
await Promise.all(
|
|
77
|
-
assets.map(async (asset) => {
|
|
78
|
-
const { source, map } = asset.source.sourceAndMap();
|
|
79
|
-
const sourceAsString = source.toString();
|
|
80
|
-
const code = typeof source === "string" ? import_node_buffer.Buffer.from(source) : source;
|
|
81
|
-
const result = this.transform({
|
|
82
|
-
filename: asset.name,
|
|
83
|
-
code,
|
|
84
|
-
minify: true,
|
|
85
|
-
sourceMap,
|
|
86
|
-
targets: (0, import_cache.getLightningcssTargets)(),
|
|
87
|
-
...transformOptions
|
|
42
|
+
else obj[key] = value;
|
|
43
|
+
return obj;
|
|
44
|
+
}
|
|
45
|
+
const PLUGIN_NAME = 'LightningcssMinifyPlugin';
|
|
46
|
+
class LightningcssMinifyPlugin {
|
|
47
|
+
apply(compiler) {
|
|
48
|
+
compiler.hooks.compilation.tap(PLUGIN_NAME, (compilation)=>{
|
|
49
|
+
compilation.hooks.processAssets.tapPromise({
|
|
50
|
+
name: PLUGIN_NAME,
|
|
51
|
+
stage: compiler.webpack.Compilation.PROCESS_ASSETS_STAGE_OPTIMIZE_SIZE
|
|
52
|
+
}, async ()=>this.transformAssets(compilation));
|
|
53
|
+
compilation.hooks.statsPrinter.tap(PLUGIN_NAME, (statsPrinter)=>{
|
|
54
|
+
statsPrinter.hooks.print.for('asset.info.minimized').tap(PLUGIN_NAME, (minimized, { green, formatFlag })=>minimized && green && formatFlag ? green(formatFlag('minimized')) : '');
|
|
55
|
+
});
|
|
88
56
|
});
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
sourceAsString
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
57
|
+
}
|
|
58
|
+
async transformAssets(compilation) {
|
|
59
|
+
const { options: { devtool }, webpack: { sources: { SourceMapSource, RawSource } } } = compilation.compiler;
|
|
60
|
+
const sourceMap = void 0 === this.options.sourceMap ? devtool && devtool.includes('source-map') : this.options.sourceMap;
|
|
61
|
+
const { implementation, ...transformOptions } = this.options;
|
|
62
|
+
const assets = compilation.getAssets().filter((asset)=>!asset.info.minimized && /\.css$/.test(asset.name));
|
|
63
|
+
await Promise.all(assets.map(async (asset)=>{
|
|
64
|
+
const { source, map } = asset.source.sourceAndMap();
|
|
65
|
+
const sourceAsString = source.toString();
|
|
66
|
+
const code = 'string' == typeof source ? external_node_buffer_namespaceObject.Buffer.from(source) : source;
|
|
67
|
+
const result = this.transform({
|
|
68
|
+
filename: asset.name,
|
|
69
|
+
code,
|
|
70
|
+
minify: true,
|
|
71
|
+
sourceMap,
|
|
72
|
+
targets: (0, external_cache_cjs_namespaceObject.getLightningcssTargets)(),
|
|
73
|
+
...transformOptions
|
|
74
|
+
});
|
|
75
|
+
const codeString = result.code.toString();
|
|
76
|
+
compilation.updateAsset(asset.name, sourceMap ? new SourceMapSource(codeString, asset.name, JSON.parse(result.map.toString()), sourceAsString, map, true) : new RawSource(codeString), {
|
|
77
|
+
...asset.info,
|
|
78
|
+
minimized: true
|
|
79
|
+
});
|
|
80
|
+
}));
|
|
81
|
+
}
|
|
82
|
+
constructor(opts = {}){
|
|
83
|
+
var _opts_implementation;
|
|
84
|
+
_define_property(this, "options", void 0);
|
|
85
|
+
_define_property(this, "transform", void 0);
|
|
86
|
+
this.transform = (null === (_opts_implementation = opts.implementation) || void 0 === _opts_implementation ? void 0 : _opts_implementation.transform) ?? external_lightningcss_namespaceObject.transform;
|
|
87
|
+
this.options = opts;
|
|
88
|
+
}
|
|
109
89
|
}
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
90
|
+
const minimizer_rslib_entry_ = LightningcssMinifyPlugin;
|
|
91
|
+
var __webpack_export_target__ = exports;
|
|
92
|
+
for(var __webpack_i__ in __webpack_exports__)__webpack_export_target__[__webpack_i__] = __webpack_exports__[__webpack_i__];
|
|
93
|
+
if (__webpack_exports__.__esModule) Object.defineProperty(__webpack_export_target__, '__esModule', {
|
|
94
|
+
value: true
|
|
114
95
|
});
|
|
@@ -1,90 +1,62 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
import { getLightningcssTargets } from "./cache.js";
|
|
13
|
-
const PLUGIN_NAME = "LightningcssMinifyPlugin";
|
|
14
|
-
class LightningcssMinifyPlugin {
|
|
15
|
-
constructor(opts = {}) {
|
|
16
|
-
this.transform = opts.implementation?.transform ?? lightningcss.transform;
|
|
17
|
-
this.options = opts;
|
|
18
|
-
}
|
|
19
|
-
apply(compiler) {
|
|
20
|
-
compiler.hooks.compilation.tap(PLUGIN_NAME, (compilation) => {
|
|
21
|
-
compilation.hooks.processAssets.tapPromise(
|
|
22
|
-
{
|
|
23
|
-
name: PLUGIN_NAME,
|
|
24
|
-
stage: compiler.webpack.Compilation.PROCESS_ASSETS_STAGE_OPTIMIZE_SIZE
|
|
25
|
-
},
|
|
26
|
-
async () => this.transformAssets(compilation)
|
|
27
|
-
);
|
|
28
|
-
compilation.hooks.statsPrinter.tap(PLUGIN_NAME, (statsPrinter) => {
|
|
29
|
-
statsPrinter.hooks.print.for("asset.info.minimized").tap(
|
|
30
|
-
PLUGIN_NAME,
|
|
31
|
-
(minimized, { green, formatFlag }) => minimized && green && formatFlag ? green(formatFlag("minimized")) : ""
|
|
32
|
-
);
|
|
33
|
-
});
|
|
1
|
+
import __rslib_shim_module__ from 'module';
|
|
2
|
+
/*#__PURE__*/ import.meta.url;
|
|
3
|
+
import * as __WEBPACK_EXTERNAL_MODULE_node_buffer_fb286294__ from "node:buffer";
|
|
4
|
+
import * as __WEBPACK_EXTERNAL_MODULE_lightningcss__ from "lightningcss";
|
|
5
|
+
import * as __WEBPACK_EXTERNAL_MODULE__cache_js_cdc28063__ from "./cache.js";
|
|
6
|
+
function _define_property(obj, key, value) {
|
|
7
|
+
if (key in obj) Object.defineProperty(obj, key, {
|
|
8
|
+
value: value,
|
|
9
|
+
enumerable: true,
|
|
10
|
+
configurable: true,
|
|
11
|
+
writable: true
|
|
34
12
|
});
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
/\.css$/.test(asset.name)
|
|
50
|
-
)
|
|
51
|
-
);
|
|
52
|
-
await Promise.all(
|
|
53
|
-
assets.map(async (asset) => {
|
|
54
|
-
const { source, map } = asset.source.sourceAndMap();
|
|
55
|
-
const sourceAsString = source.toString();
|
|
56
|
-
const code = typeof source === "string" ? Buffer.from(source) : source;
|
|
57
|
-
const result = this.transform({
|
|
58
|
-
filename: asset.name,
|
|
59
|
-
code,
|
|
60
|
-
minify: true,
|
|
61
|
-
sourceMap,
|
|
62
|
-
targets: getLightningcssTargets(),
|
|
63
|
-
...transformOptions
|
|
13
|
+
else obj[key] = value;
|
|
14
|
+
return obj;
|
|
15
|
+
}
|
|
16
|
+
const PLUGIN_NAME = 'LightningcssMinifyPlugin';
|
|
17
|
+
class LightningcssMinifyPlugin {
|
|
18
|
+
apply(compiler) {
|
|
19
|
+
compiler.hooks.compilation.tap(PLUGIN_NAME, (compilation)=>{
|
|
20
|
+
compilation.hooks.processAssets.tapPromise({
|
|
21
|
+
name: PLUGIN_NAME,
|
|
22
|
+
stage: compiler.webpack.Compilation.PROCESS_ASSETS_STAGE_OPTIMIZE_SIZE
|
|
23
|
+
}, async ()=>this.transformAssets(compilation));
|
|
24
|
+
compilation.hooks.statsPrinter.tap(PLUGIN_NAME, (statsPrinter)=>{
|
|
25
|
+
statsPrinter.hooks.print.for('asset.info.minimized').tap(PLUGIN_NAME, (minimized, { green, formatFlag })=>minimized && green && formatFlag ? green(formatFlag('minimized')) : '');
|
|
26
|
+
});
|
|
64
27
|
});
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
sourceAsString
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
28
|
+
}
|
|
29
|
+
async transformAssets(compilation) {
|
|
30
|
+
const { options: { devtool }, webpack: { sources: { SourceMapSource, RawSource } } } = compilation.compiler;
|
|
31
|
+
const sourceMap = void 0 === this.options.sourceMap ? devtool && devtool.includes('source-map') : this.options.sourceMap;
|
|
32
|
+
const { implementation, ...transformOptions } = this.options;
|
|
33
|
+
const assets = compilation.getAssets().filter((asset)=>!asset.info.minimized && /\.css$/.test(asset.name));
|
|
34
|
+
await Promise.all(assets.map(async (asset)=>{
|
|
35
|
+
const { source, map } = asset.source.sourceAndMap();
|
|
36
|
+
const sourceAsString = source.toString();
|
|
37
|
+
const code = 'string' == typeof source ? __WEBPACK_EXTERNAL_MODULE_node_buffer_fb286294__.Buffer.from(source) : source;
|
|
38
|
+
const result = this.transform({
|
|
39
|
+
filename: asset.name,
|
|
40
|
+
code,
|
|
41
|
+
minify: true,
|
|
42
|
+
sourceMap,
|
|
43
|
+
targets: (0, __WEBPACK_EXTERNAL_MODULE__cache_js_cdc28063__.getLightningcssTargets)(),
|
|
44
|
+
...transformOptions
|
|
45
|
+
});
|
|
46
|
+
const codeString = result.code.toString();
|
|
47
|
+
compilation.updateAsset(asset.name, sourceMap ? new SourceMapSource(codeString, asset.name, JSON.parse(result.map.toString()), sourceAsString, map, true) : new RawSource(codeString), {
|
|
48
|
+
...asset.info,
|
|
49
|
+
minimized: true
|
|
50
|
+
});
|
|
51
|
+
}));
|
|
52
|
+
}
|
|
53
|
+
constructor(opts = {}){
|
|
54
|
+
var _opts_implementation;
|
|
55
|
+
_define_property(this, "options", void 0);
|
|
56
|
+
_define_property(this, "transform", void 0);
|
|
57
|
+
this.transform = (null === (_opts_implementation = opts.implementation) || void 0 === _opts_implementation ? void 0 : _opts_implementation.transform) ?? __WEBPACK_EXTERNAL_MODULE_lightningcss__.transform;
|
|
58
|
+
this.options = opts;
|
|
59
|
+
}
|
|
85
60
|
}
|
|
86
|
-
|
|
87
|
-
export {
|
|
88
|
-
LightningcssMinifyPlugin,
|
|
89
|
-
minimizer_default as default
|
|
90
|
-
};
|
|
61
|
+
const minimizer_rslib_entry_ = LightningcssMinifyPlugin;
|
|
62
|
+
export { LightningcssMinifyPlugin, minimizer_rslib_entry_ as default };
|