@unpackjs/core 1.7.5 → 1.7.7

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.
Files changed (116) hide show
  1. package/compiled/css-loader/index.js +180 -178
  2. package/compiled/less-loader/index.js +11 -11
  3. package/compiled/line-diff/index.js +4 -4
  4. package/compiled/line-diff/license +1 -1
  5. package/compiled/line-diff/package.json +1 -1
  6. package/compiled/portfinder/index.js +37 -37
  7. package/compiled/postcss-loader/index.js +261 -256
  8. package/compiled/sass-loader/index.js +24 -20
  9. package/compiled/sass-loader/package.json +1 -1
  10. package/compiled/semver/index.js +188 -170
  11. package/compiled/semver/package.json +1 -1
  12. package/compiled/style-loader/index.js +13 -13
  13. package/compiled/webpack-bundle-analyzer/index.js +198 -198
  14. package/compiled/webpack-merge/index.js +29 -29
  15. package/dist/bundler-config/chunkSplit.cjs +169 -156
  16. package/dist/bundler-config/chunkSplit.js +125 -134
  17. package/dist/bundler-config/css.cjs +181 -158
  18. package/dist/bundler-config/css.js +139 -151
  19. package/dist/bundler-config/experimentCss.cjs +203 -159
  20. package/dist/bundler-config/experimentCss.js +162 -152
  21. package/dist/bundler-config/helper.cjs +82 -78
  22. package/dist/bundler-config/helper.js +36 -55
  23. package/dist/bundler-config/index.cjs +260 -209
  24. package/dist/bundler-config/index.d.ts.map +1 -1
  25. package/dist/bundler-config/index.js +209 -182
  26. package/dist/bundler-config/jsMinify.cjs +114 -95
  27. package/dist/bundler-config/jsMinify.js +70 -73
  28. package/dist/colors.cjs +83 -56
  29. package/dist/colors.js +38 -37
  30. package/dist/config.cjs +107 -93
  31. package/dist/config.d.ts.map +1 -1
  32. package/dist/config.js +64 -70
  33. package/dist/constants.cjs +65 -62
  34. package/dist/constants.d.ts +1 -0
  35. package/dist/constants.d.ts.map +1 -1
  36. package/dist/constants.js +22 -38
  37. package/dist/createUnpack.cjs +111 -104
  38. package/dist/createUnpack.js +67 -82
  39. package/dist/global.cjs +36 -0
  40. package/dist/global.d.ts +2 -0
  41. package/dist/global.d.ts.map +1 -0
  42. package/dist/global.js +4 -0
  43. package/dist/index.cjs +174 -51
  44. package/dist/index.d.ts +2 -0
  45. package/dist/index.d.ts.map +1 -1
  46. package/dist/index.js +33 -15
  47. package/dist/lightningcss/loader.cjs +56 -53
  48. package/dist/lightningcss/loader.d.ts.map +1 -1
  49. package/dist/lightningcss/loader.js +25 -34
  50. package/dist/lightningcss/minimizer.cjs +90 -109
  51. package/dist/lightningcss/minimizer.d.ts.map +1 -1
  52. package/dist/lightningcss/minimizer.js +59 -87
  53. package/dist/logger.cjs +104 -98
  54. package/dist/logger.js +59 -76
  55. package/dist/openBrowser.cjs +104 -81
  56. package/dist/openBrowser.js +56 -52
  57. package/dist/plugin-progress/rspack.cjs +104 -79
  58. package/dist/plugin-progress/rspack.js +59 -57
  59. package/dist/plugin-progress/webpack.cjs +111 -89
  60. package/dist/plugin-progress/webpack.js +65 -67
  61. package/dist/plugin.cjs +38 -29
  62. package/dist/plugin.js +8 -17
  63. package/dist/prebundleDeps.cjs +327 -337
  64. package/dist/prebundleDeps.d.ts.map +1 -1
  65. package/dist/prebundleDeps.js +278 -324
  66. package/dist/progressBar.cjs +82 -65
  67. package/dist/progressBar.js +38 -43
  68. package/dist/reporter.cjs +149 -124
  69. package/dist/reporter.d.ts.map +1 -1
  70. package/dist/reporter.js +102 -102
  71. package/dist/run/build.cjs +68 -67
  72. package/dist/run/build.js +24 -45
  73. package/dist/run/dev.cjs +96 -83
  74. package/dist/run/dev.d.ts.map +1 -1
  75. package/dist/run/dev.js +50 -61
  76. package/dist/run/index.cjs +74 -21
  77. package/dist/run/index.js +2 -9
  78. package/dist/typed-css-modules/loader.cjs +179 -188
  79. package/dist/typed-css-modules/loader.js +118 -151
  80. package/dist/typed-css-modules/plugin.cjs +113 -88
  81. package/dist/typed-css-modules/plugin.js +68 -66
  82. package/dist/typed-css-modules/utils.cjs +43 -42
  83. package/dist/typed-css-modules/utils.js +13 -30
  84. package/dist/types/chunkSplit.cjs +19 -15
  85. package/dist/types/chunkSplit.d.ts +2 -10
  86. package/dist/types/chunkSplit.d.ts.map +1 -1
  87. package/dist/types/chunkSplit.js +2 -9
  88. package/dist/types/config.cjs +19 -15
  89. package/dist/types/config.js +2 -9
  90. package/dist/types/index.cjs +101 -27
  91. package/dist/types/index.js +2 -9
  92. package/dist/types/lightningcss.cjs +19 -15
  93. package/dist/types/lightningcss.js +2 -9
  94. package/dist/types/logger.cjs +43 -34
  95. package/dist/types/logger.js +13 -22
  96. package/dist/types/plugin.cjs +19 -15
  97. package/dist/types/plugin.js +2 -9
  98. package/dist/utils.cjs +280 -304
  99. package/dist/utils.js +195 -241
  100. package/dist/watchFiles.cjs +73 -0
  101. package/dist/watchFiles.d.ts +3 -0
  102. package/dist/watchFiles.d.ts.map +1 -0
  103. package/dist/watchFiles.js +27 -0
  104. package/package.json +18 -21
  105. package/compiled/commander/index.d.ts +0 -1047
  106. package/compiled/commander/index.js +0 -2428
  107. package/compiled/commander/license +0 -22
  108. package/compiled/commander/package.json +0 -1
  109. package/dist/bundleRequire.cjs +0 -200
  110. package/dist/bundleRequire.d.ts +0 -5
  111. package/dist/bundleRequire.d.ts.map +0 -1
  112. package/dist/bundleRequire.js +0 -173
  113. package/dist/lightningcss/cache.cjs +0 -36
  114. package/dist/lightningcss/cache.d.ts +0 -2
  115. package/dist/lightningcss/cache.d.ts.map +0 -1
  116. package/dist/lightningcss/cache.js +0 -22
@@ -1,36 +1,27 @@
1
- import { createRequire } from 'node:module';
2
- var require = createRequire(import.meta['url']);
3
-
4
- import path from "path";
5
- import { fileURLToPath } from "url";
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__constants_js_59e7fa1b__ from "../constants.js";
13
6
  async function LightningcssLoader(source, prevSourceMap) {
14
- const done = this.async();
15
- const options = this.getOptions();
16
- const { implementation, sourceMap, ...opts } = options;
17
- const transform = implementation?.transform ?? lightningcss.transform;
18
- try {
19
- const { code, map } = transform({
20
- filename: this.resourcePath,
21
- code: Buffer.from(source),
22
- sourceMap,
23
- targets: getLightningcssTargets(),
24
- inputSourceMap: sourceMap && prevSourceMap ? JSON.stringify(prevSourceMap) : void 0,
25
- ...opts
26
- });
27
- const codeAsString = code.toString();
28
- done(null, codeAsString, map && JSON.parse(map.toString()));
29
- } catch (error) {
30
- done(error);
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: __WEBPACK_EXTERNAL_MODULE__constants_js_59e7fa1b__.LIGHTNINGCSS_TARGET,
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
- var loader_default = LightningcssLoader;
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
- var __create = Object.create;
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __getProtoOf = Object.getPrototypeOf;
6
- var __hasOwnProp = Object.prototype.hasOwnProperty;
7
- var __export = (target, all) => {
8
- for (var name in all)
9
- __defProp(target, name, { get: all[name], enumerable: true });
10
- };
11
- var __copyProps = (to, from, except, desc) => {
12
- if (from && typeof from === "object" || typeof from === "function") {
13
- for (let key of __getOwnPropNames(from))
14
- if (!__hasOwnProp.call(to, key) && key !== except)
15
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
- }
17
- return to;
18
- };
19
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
20
- // If the importer is in node compatibility mode or this is not an ESM
21
- // file that has been converted to a CommonJS file using a Babel-
22
- // compatible transform (i.e. "__esModule" has not been set), then set
23
- // "default" to the CommonJS "module.exports" for node compatibility.
24
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
25
- mod
26
- ));
27
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
28
- var minimizer_exports = {};
29
- __export(minimizer_exports, {
30
- LightningcssMinifyPlugin: () => LightningcssMinifyPlugin,
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
- module.exports = __toCommonJS(minimizer_exports);
34
- var import_node_buffer = require("node:buffer");
35
- var lightningcss = __toESM(require("lightningcss"));
36
- var import_cache = require("./cache.cjs");
37
- const PLUGIN_NAME = "LightningcssMinifyPlugin";
38
- class LightningcssMinifyPlugin {
39
- constructor(opts = {}) {
40
- this.transform = opts.implementation?.transform ?? lightningcss.transform;
41
- this.options = opts;
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_constants_cjs_namespaceObject = require("../constants.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
- async transformAssets(compilation) {
61
- const {
62
- options: { devtool },
63
- webpack: {
64
- sources: { SourceMapSource, RawSource }
65
- }
66
- } = compilation.compiler;
67
- const sourceMap = this.options.sourceMap === void 0 ? devtool && devtool.includes("source-map") : this.options.sourceMap;
68
- const { implementation, ...transformOptions } = this.options;
69
- const assets = compilation.getAssets().filter(
70
- (asset) => (
71
- // Filter out already minimized
72
- !asset.info.minimized && // Filter out by file type
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
- const codeString = result.code.toString();
90
- compilation.updateAsset(
91
- asset.name,
92
- sourceMap ? new SourceMapSource(
93
- codeString,
94
- asset.name,
95
- // @ts-ignore
96
- JSON.parse(result.map.toString()),
97
- sourceAsString,
98
- map,
99
- true
100
- ) : new RawSource(codeString),
101
- {
102
- ...asset.info,
103
- minimized: true
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: external_constants_cjs_namespaceObject.LIGHTNINGCSS_TARGET,
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
- var minimizer_default = LightningcssMinifyPlugin;
111
- // Annotate the CommonJS export names for ESM import in node:
112
- 0 && (module.exports = {
113
- LightningcssMinifyPlugin
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 +1 @@
1
- {"version":3,"file":"minimizer.d.ts","sourceRoot":"","sources":["../../src/lightningcss/minimizer.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAgB,+BAA+B,EAAE,MAAM,iBAAiB,CAAA;AACpF,OAAO,KAAK,EAAe,QAAQ,EAAE,MAAM,SAAS,CAAA;AAIpD,qBAAa,wBAAwB;IACnC,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAiC;IACzD,OAAO,CAAC,QAAQ,CAAC,SAAS,CAA2B;gBAEzC,IAAI,GAAE,+BAAoC;IAKtD,KAAK,CAAC,QAAQ,EAAE,QAAQ;YAoBV,eAAe;CA4D9B;AAED,eAAe,wBAAwB,CAAA"}
1
+ {"version":3,"file":"minimizer.d.ts","sourceRoot":"","sources":["../../src/lightningcss/minimizer.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAgB,+BAA+B,EAAE,MAAM,iBAAiB,CAAA;AACpF,OAAO,KAAK,EAAe,QAAQ,EAAE,MAAM,SAAS,CAAA;AAGpD,qBAAa,wBAAwB;IACnC,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAiC;IACzD,OAAO,CAAC,QAAQ,CAAC,SAAS,CAA2B;gBAEzC,IAAI,GAAE,+BAAoC;IAKtD,KAAK,CAAC,QAAQ,EAAE,QAAQ;YAoBV,eAAe;CA4D9B;AAED,eAAe,wBAAwB,CAAA"}
@@ -1,90 +1,62 @@
1
- import { createRequire } from 'node:module';
2
- var require = createRequire(import.meta['url']);
3
-
4
- import path from "path";
5
- import { fileURLToPath } from "url";
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";
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__constants_js_59e7fa1b__ from "../constants.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
- async transformAssets(compilation) {
37
- const {
38
- options: { devtool },
39
- webpack: {
40
- sources: { SourceMapSource, RawSource }
41
- }
42
- } = compilation.compiler;
43
- const sourceMap = this.options.sourceMap === void 0 ? devtool && devtool.includes("source-map") : this.options.sourceMap;
44
- const { implementation, ...transformOptions } = this.options;
45
- const assets = compilation.getAssets().filter(
46
- (asset) => (
47
- // Filter out already minimized
48
- !asset.info.minimized && // Filter out by file type
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
- const codeString = result.code.toString();
66
- compilation.updateAsset(
67
- asset.name,
68
- sourceMap ? new SourceMapSource(
69
- codeString,
70
- asset.name,
71
- // @ts-ignore
72
- JSON.parse(result.map.toString()),
73
- sourceAsString,
74
- map,
75
- true
76
- ) : new RawSource(codeString),
77
- {
78
- ...asset.info,
79
- minimized: true
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: __WEBPACK_EXTERNAL_MODULE__constants_js_59e7fa1b__.LIGHTNINGCSS_TARGET,
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
- var minimizer_default = LightningcssMinifyPlugin;
87
- export {
88
- LightningcssMinifyPlugin,
89
- minimizer_default as default
90
- };
61
+ const minimizer_rslib_entry_ = LightningcssMinifyPlugin;
62
+ export { LightningcssMinifyPlugin, minimizer_rslib_entry_ as default };
package/dist/logger.cjs CHANGED
@@ -1,105 +1,111 @@
1
- var __create = Object.create;
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __getProtoOf = Object.getPrototypeOf;
6
- var __hasOwnProp = Object.prototype.hasOwnProperty;
7
- var __export = (target, all) => {
8
- for (var name in all)
9
- __defProp(target, name, { get: all[name], enumerable: true });
10
- };
11
- var __copyProps = (to, from, except, desc) => {
12
- if (from && typeof from === "object" || typeof from === "function") {
13
- for (let key of __getOwnPropNames(from))
14
- if (!__hasOwnProp.call(to, key) && key !== except)
15
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
- }
17
- return to;
18
- };
19
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
20
- // If the importer is in node compatibility mode or this is not an ESM
21
- // file that has been converted to a CommonJS file using a Babel-
22
- // compatible transform (i.e. "__esModule" has not been set), then set
23
- // "default" to the CommonJS "module.exports" for node compatibility.
24
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
25
- mod
26
- ));
27
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
28
- var logger_exports = {};
29
- __export(logger_exports, {
30
- logger: () => logger
1
+ "use strict";
2
+ var __webpack_require__ = {};
3
+ (()=>{
4
+ __webpack_require__.n = function(module) {
5
+ var getter = module && module.__esModule ? function() {
6
+ return module['default'];
7
+ } : function() {
8
+ return module;
9
+ };
10
+ __webpack_require__.d(getter, {
11
+ a: getter
12
+ });
13
+ return getter;
14
+ };
15
+ })();
16
+ (()=>{
17
+ __webpack_require__.d = function(exports1, definition) {
18
+ for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
19
+ enumerable: true,
20
+ get: definition[key]
21
+ });
22
+ };
23
+ })();
24
+ (()=>{
25
+ __webpack_require__.o = function(obj, prop) {
26
+ return Object.prototype.hasOwnProperty.call(obj, prop);
27
+ };
28
+ })();
29
+ (()=>{
30
+ __webpack_require__.r = function(exports1) {
31
+ if ('undefined' != typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
32
+ value: 'Module'
33
+ });
34
+ Object.defineProperty(exports1, '__esModule', {
35
+ value: true
36
+ });
37
+ };
38
+ })();
39
+ var __webpack_exports__ = {};
40
+ __webpack_require__.r(__webpack_exports__);
41
+ __webpack_require__.d(__webpack_exports__, {
42
+ logger: ()=>logger_rslib_entry_logger
31
43
  });
32
- module.exports = __toCommonJS(logger_exports);
33
- var import_node_readline = __toESM(require("node:readline"));
34
- var import_colors = __toESM(require("./colors.cjs"));
35
- var import_types = require("./types/index.cjs");
44
+ const external_node_readline_namespaceObject = require("node:readline");
45
+ var external_node_readline_default = /*#__PURE__*/ __webpack_require__.n(external_node_readline_namespaceObject);
46
+ const external_colors_cjs_namespaceObject = require("./colors.cjs");
47
+ var external_colors_cjs_default = /*#__PURE__*/ __webpack_require__.n(external_colors_cjs_namespaceObject);
48
+ const index_cjs_namespaceObject = require("./types/index.cjs");
36
49
  const prefixes = {
37
- wait: "",
38
- error: "",
39
- warn: "",
40
- info: "",
41
- ready: "",
42
- event: "»",
43
- debug: ""
50
+ wait: '',
51
+ error: '',
52
+ warn: '',
53
+ info: '',
54
+ ready: '',
55
+ event: '»',
56
+ debug: ''
44
57
  };
45
- const createLogger = () => {
46
- const log = (type, message, ...args) => {
47
- const label = import_colors.default[import_types.LogColor[type]](import_colors.default.bold(prefixes[type]));
48
- let text = "";
49
- switch (type) {
50
- case "error":
51
- if (message instanceof Error) {
52
- if (message.stack) {
53
- let [name, ...rest] = message.stack.split("\n");
54
- if (name.startsWith("Error: ")) {
55
- name = name.slice(7);
56
- rest = rest.map((line) => line.slice(2));
57
- }
58
- text = `${import_colors.default.red(name)}
59
- ${import_colors.default.dim(rest.join("\n"))}`;
60
- } else {
61
- text = import_colors.default.red(message.message);
62
- }
63
- } else {
64
- text = import_colors.default.red(message);
58
+ const createLogger = ()=>{
59
+ const log = (type, message, ...args)=>{
60
+ const label = external_colors_cjs_default()[index_cjs_namespaceObject.LogColor[type]](external_colors_cjs_default().bold(prefixes[type]));
61
+ let text = '';
62
+ switch(type){
63
+ case 'error':
64
+ if (message instanceof Error) {
65
+ if (message.stack) {
66
+ let [name, ...rest] = message.stack.split('\n');
67
+ if (name.startsWith('Error: ')) {
68
+ name = name.slice(7);
69
+ rest = rest.map((line)=>line.slice(2));
70
+ }
71
+ text = `${external_colors_cjs_default().red(name)}\n${external_colors_cjs_default().dim(rest.join('\n'))}`;
72
+ } else text = external_colors_cjs_default().red(message.message);
73
+ } else text = external_colors_cjs_default().red(message);
74
+ break;
75
+ case 'warn':
76
+ text = external_colors_cjs_default().yellow(message);
77
+ break;
78
+ default:
79
+ text = message;
80
+ break;
81
+ }
82
+ if ('debug' === type && 'unpack' !== process.env.DEBUG) return;
83
+ console.log(`${label} ${text}`, ...args);
84
+ };
85
+ const logger = {
86
+ clear: ()=>{
87
+ const repeatCount = process.stdout.rows - 2;
88
+ const blank = repeatCount > 0 ? '\n'.repeat(repeatCount) : '';
89
+ console.log(blank);
90
+ external_node_readline_default().cursorTo(process.stdout, 0, 0);
91
+ external_node_readline_default().clearScreenDown(process.stdout);
92
+ },
93
+ greet: (msg)=>{
94
+ const { npm_execpath, npm_lifecycle_event } = process.env;
95
+ if (!npm_execpath || 'npx' === npm_lifecycle_event || npm_execpath.includes('npx-cli') || npm_execpath.includes('.bun') || npm_execpath.includes('yarn')) console.log();
96
+ console.log(msg);
65
97
  }
66
- break;
67
- case "warn":
68
- text = import_colors.default.yellow(message);
69
- break;
70
- default:
71
- text = message;
72
- break;
73
- }
74
- if (type === "debug" && process.env.DEBUG !== "unpack")
75
- return;
76
- console.log(`${label} ${text}`, ...args);
77
- };
78
- const logger2 = {
79
- clear: () => {
80
- const repeatCount = process.stdout.rows - 2;
81
- const blank = repeatCount > 0 ? "\n".repeat(repeatCount) : "";
82
- console.log(blank);
83
- import_node_readline.default.cursorTo(process.stdout, 0, 0);
84
- import_node_readline.default.clearScreenDown(process.stdout);
85
- },
86
- greet: (msg) => {
87
- const { npm_execpath, npm_lifecycle_event } = process.env;
88
- if (!npm_execpath || npm_lifecycle_event === "npx" || npm_execpath.includes("npx-cli") || npm_execpath.includes(".bun") || npm_execpath.includes("yarn")) {
89
- console.log();
90
- }
91
- console.log(msg);
92
- }
93
- };
94
- Object.keys(prefixes).forEach((type) => {
95
- logger2[type] = (message, ...args) => {
96
- log(type, message, ...args);
97
98
  };
98
- });
99
- return logger2;
99
+ Object.keys(prefixes).forEach((type)=>{
100
+ logger[type] = (message, ...args)=>{
101
+ log(type, message, ...args);
102
+ };
103
+ });
104
+ return logger;
100
105
  };
101
- const logger = createLogger();
102
- // Annotate the CommonJS export names for ESM import in node:
103
- 0 && (module.exports = {
104
- logger
106
+ const logger_rslib_entry_logger = createLogger();
107
+ var __webpack_export_target__ = exports;
108
+ for(var __webpack_i__ in __webpack_exports__)__webpack_export_target__[__webpack_i__] = __webpack_exports__[__webpack_i__];
109
+ if (__webpack_exports__.__esModule) Object.defineProperty(__webpack_export_target__, '__esModule', {
110
+ value: true
105
111
  });