@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.
Files changed (122) 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/portfinder/index.js +37 -37
  5. package/compiled/postcss-loader/index.js +261 -256
  6. package/compiled/sass-loader/index.js +18 -18
  7. package/compiled/semver/index.js +188 -170
  8. package/compiled/semver/package.json +1 -1
  9. package/compiled/style-loader/index.js +13 -13
  10. package/compiled/webpack-bundle-analyzer/index.js +198 -198
  11. package/compiled/webpack-merge/index.js +29 -29
  12. package/dist/bundler-config/chunkSplit.cjs +169 -156
  13. package/dist/bundler-config/chunkSplit.d.ts +1 -1
  14. package/dist/bundler-config/chunkSplit.js +125 -134
  15. package/dist/bundler-config/css.cjs +181 -158
  16. package/dist/bundler-config/css.d.ts +1 -1
  17. package/dist/bundler-config/css.js +139 -151
  18. package/dist/bundler-config/experimentCss.cjs +203 -159
  19. package/dist/bundler-config/experimentCss.d.ts +1 -1
  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 +1 -1
  25. package/dist/bundler-config/index.d.ts.map +1 -1
  26. package/dist/bundler-config/index.js +209 -182
  27. package/dist/bundler-config/jsMinify.cjs +114 -95
  28. package/dist/bundler-config/jsMinify.js +70 -73
  29. package/dist/colors.cjs +83 -56
  30. package/dist/colors.js +38 -37
  31. package/dist/config.cjs +107 -93
  32. package/dist/config.d.ts +1 -1
  33. package/dist/config.d.ts.map +1 -1
  34. package/dist/config.js +64 -70
  35. package/dist/constants.cjs +62 -62
  36. package/dist/constants.js +20 -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/cache.cjs +40 -32
  48. package/dist/lightningcss/cache.js +10 -20
  49. package/dist/lightningcss/loader.cjs +56 -53
  50. package/dist/lightningcss/loader.d.ts +1 -1
  51. package/dist/lightningcss/loader.js +25 -34
  52. package/dist/lightningcss/minimizer.cjs +90 -109
  53. package/dist/lightningcss/minimizer.d.ts +1 -1
  54. package/dist/lightningcss/minimizer.js +59 -87
  55. package/dist/logger.cjs +104 -98
  56. package/dist/logger.d.ts +1 -1
  57. package/dist/logger.js +59 -76
  58. package/dist/openBrowser.cjs +104 -81
  59. package/dist/openBrowser.js +56 -52
  60. package/dist/plugin-progress/rspack.cjs +104 -79
  61. package/dist/plugin-progress/rspack.d.ts +1 -1
  62. package/dist/plugin-progress/rspack.js +59 -57
  63. package/dist/plugin-progress/webpack.cjs +111 -89
  64. package/dist/plugin-progress/webpack.d.ts +1 -1
  65. package/dist/plugin-progress/webpack.js +65 -67
  66. package/dist/plugin.cjs +38 -29
  67. package/dist/plugin.js +8 -17
  68. package/dist/prebundleDeps.cjs +327 -337
  69. package/dist/prebundleDeps.d.ts.map +1 -1
  70. package/dist/prebundleDeps.js +278 -324
  71. package/dist/progressBar.cjs +82 -65
  72. package/dist/progressBar.js +38 -43
  73. package/dist/reporter.cjs +135 -120
  74. package/dist/reporter.js +88 -98
  75. package/dist/run/build.cjs +68 -67
  76. package/dist/run/build.d.ts +1 -1
  77. package/dist/run/build.js +24 -45
  78. package/dist/run/dev.cjs +96 -83
  79. package/dist/run/dev.d.ts +1 -1
  80. package/dist/run/dev.d.ts.map +1 -1
  81. package/dist/run/dev.js +50 -61
  82. package/dist/run/index.cjs +74 -21
  83. package/dist/run/index.js +2 -9
  84. package/dist/typed-css-modules/loader.cjs +179 -188
  85. package/dist/typed-css-modules/loader.d.ts +1 -1
  86. package/dist/typed-css-modules/loader.js +118 -151
  87. package/dist/typed-css-modules/plugin.cjs +113 -88
  88. package/dist/typed-css-modules/plugin.d.ts +1 -1
  89. package/dist/typed-css-modules/plugin.js +68 -66
  90. package/dist/typed-css-modules/utils.cjs +43 -42
  91. package/dist/typed-css-modules/utils.d.ts +1 -1
  92. package/dist/typed-css-modules/utils.js +13 -30
  93. package/dist/types/chunkSplit.cjs +19 -15
  94. package/dist/types/chunkSplit.d.ts +2 -10
  95. package/dist/types/chunkSplit.d.ts.map +1 -1
  96. package/dist/types/chunkSplit.js +2 -9
  97. package/dist/types/config.cjs +19 -15
  98. package/dist/types/config.d.ts +1 -1
  99. package/dist/types/config.js +2 -9
  100. package/dist/types/index.cjs +101 -27
  101. package/dist/types/index.js +2 -9
  102. package/dist/types/lightningcss.cjs +19 -15
  103. package/dist/types/lightningcss.js +2 -9
  104. package/dist/types/logger.cjs +43 -34
  105. package/dist/types/logger.js +13 -22
  106. package/dist/types/plugin.cjs +19 -15
  107. package/dist/types/plugin.js +2 -9
  108. package/dist/utils.cjs +280 -304
  109. package/dist/utils.js +195 -241
  110. package/dist/watchFiles.cjs +73 -0
  111. package/dist/watchFiles.d.ts +3 -0
  112. package/dist/watchFiles.d.ts.map +1 -0
  113. package/dist/watchFiles.js +27 -0
  114. package/package.json +14 -17
  115. package/compiled/commander/index.d.ts +0 -1047
  116. package/compiled/commander/index.js +0 -2428
  117. package/compiled/commander/license +0 -22
  118. package/compiled/commander/package.json +0 -1
  119. package/dist/bundleRequire.cjs +0 -200
  120. package/dist/bundleRequire.d.ts +0 -5
  121. package/dist/bundleRequire.d.ts.map +0 -1
  122. package/dist/bundleRequire.js +0 -173
@@ -1,170 +1,137 @@
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 fs from "node:fs";
11
- import path2 from "node:path";
12
- const LineDiff = require("../../compiled/line-diff/index.js");
13
- import { CSS_NAMED_EXPORT, NODE_MODULES_REGEX } from "../constants.js";
14
- import { isCSSModules } from "./utils.js";
15
- const isInNodeModules = (path3) => NODE_MODULES_REGEX.test(path3);
16
- const getNoDeclarationFileError = ({ filename }) => new Error(
17
- `Generated type declaration does not exist. Run Unpack and commit the type declaration for '${filename}'`
18
- );
19
- const getTypeMismatchError = ({
20
- filename,
21
- expected,
22
- actual
23
- }) => {
24
- const diff = new LineDiff(enforceLFLineSeparators(actual), expected).toString();
25
- return new Error(
26
- `Generated type declaration file is outdated. Run Unpack and commit the updated type declaration for '${filename}'
27
-
28
- ${diff}`
29
- );
1
+ import __rslib_shim_module__ from 'module';
2
+ /*#__PURE__*/ import.meta.url;
3
+ import * as __WEBPACK_EXTERNAL_MODULE__home_runner_work_unpack_unpack_packages_core_compiled_line_diff_index_js_5432ea9f__ from "/home/runner/work/unpack/unpack/packages/core/compiled/line-diff/index.js";
4
+ import * as __WEBPACK_EXTERNAL_MODULE_node_fs_5ea92f0c__ from "node:fs";
5
+ import * as __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__ from "node:path";
6
+ import * as __WEBPACK_EXTERNAL_MODULE__constants_js_59e7fa1b__ from "../constants.js";
7
+ import * as __WEBPACK_EXTERNAL_MODULE__utils_js_d88b7fe1__ from "./utils.js";
8
+ var __webpack_modules__ = {
9
+ "compiled/line-diff/index.js": function(module) {
10
+ module.exports = __WEBPACK_EXTERNAL_MODULE__home_runner_work_unpack_unpack_packages_core_compiled_line_diff_index_js_5432ea9f__;
11
+ }
30
12
  };
31
- function wrapQuotes(key) {
32
- const isValidIdentifier = /^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(key);
33
- if (isValidIdentifier) {
34
- return key;
35
- }
36
- return `'${key}'`;
13
+ var __webpack_module_cache__ = {};
14
+ function __webpack_require__(moduleId) {
15
+ var cachedModule = __webpack_module_cache__[moduleId];
16
+ if (void 0 !== cachedModule) return cachedModule.exports;
17
+ var module = __webpack_module_cache__[moduleId] = {
18
+ exports: {}
19
+ };
20
+ __webpack_modules__[moduleId](module, module.exports, __webpack_require__);
21
+ return module.exports;
37
22
  }
38
- const cssModuleToNamedExports = (cssModuleKeys) => {
39
- return cssModuleKeys.sort().map((key) => `export const ${key}: string;`).join("\n");
23
+ const LineDiff = __webpack_require__("compiled/line-diff/index.js");
24
+ const isInNodeModules = (path)=>__WEBPACK_EXTERNAL_MODULE__constants_js_59e7fa1b__.NODE_MODULES_REGEX.test(path);
25
+ const getNoDeclarationFileError = ({ filename })=>new Error(`Generated type declaration does not exist. Run Unpack and commit the type declaration for '${filename}'`);
26
+ const getTypeMismatchError = ({ filename, expected, actual })=>{
27
+ const diff = new LineDiff(enforceLFLineSeparators(actual), expected).toString();
28
+ return new Error(`Generated type declaration file is outdated. Run Unpack and commit the updated type declaration for '${filename}'\n\n${diff}`);
40
29
  };
41
- const cssModuleToInterface = (cssModulesKeys) => {
42
- const interfaceFields = cssModulesKeys.sort().map((key) => ` ${wrapQuotes(key)}: string;`).join("\n");
43
- return `interface CssExports {
44
- ${interfaceFields}
45
- }`;
46
- };
47
- const filenameToTypingsFilename = (filename) => {
48
- const dirName = path2.dirname(filename);
49
- const baseName = path2.basename(filename);
50
- return path2.join(dirName, `${baseName}.d.ts`);
30
+ function wrapQuotes(key) {
31
+ const isValidIdentifier = /^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(key);
32
+ if (isValidIdentifier) return key;
33
+ return `'${key}'`;
34
+ }
35
+ const cssModuleToNamedExports = (cssModuleKeys)=>cssModuleKeys.sort().map((key)=>`export const ${key}: string;`).join('\n');
36
+ const cssModuleToInterface = (cssModulesKeys)=>{
37
+ const interfaceFields = cssModulesKeys.sort().map((key)=>` ${wrapQuotes(key)}: string;`).join('\n');
38
+ return `interface CssExports {\n${interfaceFields}\n}`;
51
39
  };
52
- const enforceLFLineSeparators = (text) => {
53
- if (text) {
54
- return text.replace(/\r\n/g, "\n");
55
- }
56
- return text;
40
+ const filenameToTypingsFilename = (filename)=>{
41
+ const dirName = __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].dirname(filename);
42
+ const baseName = __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].basename(filename);
43
+ return __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].join(dirName, `${baseName}.d.ts`);
57
44
  };
58
- const compareText = (contentA, contentB) => {
59
- return enforceLFLineSeparators(contentA) === enforceLFLineSeparators(contentB);
45
+ const enforceLFLineSeparators = (text)=>{
46
+ if (text) return text.replace(/\r\n/g, '\n');
47
+ return text;
60
48
  };
61
- const validModes = ["emit", "verify"];
62
- const isFileNotFound = (err) => err && err.code === "ENOENT";
63
- const makeDoneHandlers = (callback, content, rest) => ({
64
- failed: (e) => callback(e),
65
- success: () => callback(null, content, ...rest)
66
- });
67
- const makeFileHandlers = (filename) => ({
68
- read: (handler) => fs.readFile(filename, { encoding: "utf-8" }, handler),
69
- write: (content, handler) => fs.writeFile(filename, content, { encoding: "utf-8" }, handler)
70
- });
71
- const extractLocalExports = (content) => {
72
- let localExports = content.split("exports.locals")[1];
73
- if (!localExports) {
74
- localExports = content.split("___CSS_LOADER_EXPORT___.locals")[1];
75
- }
76
- return localExports;
49
+ const compareText = (contentA, contentB)=>enforceLFLineSeparators(contentA) === enforceLFLineSeparators(contentB);
50
+ const validModes = [
51
+ 'emit',
52
+ 'verify'
53
+ ];
54
+ const isFileNotFound = (err)=>err && 'ENOENT' === err.code;
55
+ const makeDoneHandlers = (callback, content, rest)=>({
56
+ failed: (e)=>callback(e),
57
+ success: ()=>callback(null, content, ...rest)
58
+ });
59
+ const makeFileHandlers = (filename)=>({
60
+ read: (handler)=>__WEBPACK_EXTERNAL_MODULE_node_fs_5ea92f0c__["default"].readFile(filename, {
61
+ encoding: 'utf-8'
62
+ }, handler),
63
+ write: (content, handler)=>__WEBPACK_EXTERNAL_MODULE_node_fs_5ea92f0c__["default"].writeFile(filename, content, {
64
+ encoding: 'utf-8'
65
+ }, handler)
66
+ });
67
+ const extractLocalExports = (content)=>{
68
+ let localExports = content.split('exports.locals')[1];
69
+ if (!localExports) localExports = content.split('___CSS_LOADER_EXPORT___.locals')[1];
70
+ return localExports;
77
71
  };
78
- const getCSSModulesKeys = (content, namedExport) => {
79
- const keys = /* @__PURE__ */ new Set();
80
- if (namedExport) {
81
- const exportsRegex = /export\s+var\s+(\w+)\s*=/g;
82
- let match2 = exportsRegex.exec(content);
83
- while (match2 !== null) {
84
- keys.add(match2[1]);
85
- match2 = exportsRegex.exec(content);
72
+ const getCSSModulesKeys = (content, namedExport)=>{
73
+ const keys = new Set();
74
+ if (namedExport) {
75
+ const exportsRegex = /export\s+var\s+(\w+)\s*=/g;
76
+ let match = exportsRegex.exec(content);
77
+ while(null !== match){
78
+ keys.add(match[1]);
79
+ match = exportsRegex.exec(content);
80
+ }
81
+ return Array.from(keys);
82
+ }
83
+ const localExports = extractLocalExports(content);
84
+ const keyRegex = /"([^\\"]+)":/g;
85
+ let match = keyRegex.exec(localExports);
86
+ while(null !== match){
87
+ keys.add(match[1]);
88
+ match = keyRegex.exec(localExports);
86
89
  }
87
90
  return Array.from(keys);
88
- }
89
- const localExports = extractLocalExports(content);
90
- const keyRegex = /"([^\\"]+)":/g;
91
- let match = keyRegex.exec(localExports);
92
- while (match !== null) {
93
- keys.add(match[1]);
94
- match = keyRegex.exec(localExports);
95
- }
96
- return Array.from(keys);
97
91
  };
98
92
  function codegen(keys, namedExport) {
99
- const bannerMessage = "// Generated automatically, do not edit";
100
- if (namedExport) {
101
- return `${bannerMessage}
102
- ${cssModuleToNamedExports(keys)}
103
- `;
104
- }
105
- const cssModuleExport = "declare const cssExports: CssExports;\nexport default cssExports;\n";
106
- return `${bannerMessage}
107
- ${cssModuleToInterface(keys)}
108
- ${cssModuleExport}`;
93
+ const bannerMessage = '// Generated automatically, do not edit';
94
+ if (namedExport) return `${bannerMessage}\n${cssModuleToNamedExports(keys)}\n`;
95
+ const cssModuleExport = 'declare const cssExports: CssExports;\nexport default cssExports;\n';
96
+ return `${bannerMessage}\n${cssModuleToInterface(keys)}\n${cssModuleExport}`;
109
97
  }
110
- function loader_default(content, ...rest) {
111
- const { failed, success } = makeDoneHandlers(this.async(), content, rest);
112
- const { resourcePath } = this;
113
- const { mode = "emit", modules } = this.getOptions() || {};
114
- if (!validModes.includes(mode)) {
115
- failed(new Error(`Invalid mode option: ${mode}`));
116
- return;
117
- }
118
- if (!isCSSModules({ resourcePath, modules }) || isInNodeModules(resourcePath)) {
119
- success();
120
- return;
121
- }
122
- const cssModuleInterfaceFilename = filenameToTypingsFilename(resourcePath);
123
- const { read, write } = makeFileHandlers(cssModuleInterfaceFilename);
124
- const namedExport = CSS_NAMED_EXPORT;
125
- const cssModulesKeys = getCSSModulesKeys(content, namedExport);
126
- const cssModulesCode = codegen(cssModulesKeys, namedExport);
127
- if (mode === "verify") {
128
- read((err, fileContents) => {
129
- if (isFileNotFound(err)) {
130
- return failed(
131
- getNoDeclarationFileError({
98
+ function loader_rslib_entry_(content, ...rest) {
99
+ const { failed, success } = makeDoneHandlers(this.async(), content, rest);
100
+ const { resourcePath } = this;
101
+ const { mode = 'emit', modules } = this.getOptions() || {};
102
+ if (!validModes.includes(mode)) {
103
+ failed(new Error(`Invalid mode option: ${mode}`));
104
+ return;
105
+ }
106
+ if (!(0, __WEBPACK_EXTERNAL_MODULE__utils_js_d88b7fe1__.isCSSModules)({
107
+ resourcePath,
108
+ modules
109
+ }) || isInNodeModules(resourcePath)) {
110
+ success();
111
+ return;
112
+ }
113
+ const cssModuleInterfaceFilename = filenameToTypingsFilename(resourcePath);
114
+ const { read, write } = makeFileHandlers(cssModuleInterfaceFilename);
115
+ const namedExport = __WEBPACK_EXTERNAL_MODULE__constants_js_59e7fa1b__.CSS_NAMED_EXPORT;
116
+ const cssModulesKeys = getCSSModulesKeys(content, namedExport);
117
+ const cssModulesCode = codegen(cssModulesKeys, namedExport);
118
+ read('verify' === mode ? (err, fileContents)=>{
119
+ if (isFileNotFound(err)) return failed(getNoDeclarationFileError({
132
120
  filename: cssModuleInterfaceFilename
133
- })
134
- );
135
- }
136
- if (err) {
137
- return failed(err);
138
- }
139
- if (!compareText(cssModulesCode, fileContents)) {
140
- return failed(
141
- getTypeMismatchError({
121
+ }));
122
+ if (err) return failed(err);
123
+ if (!compareText(cssModulesCode, fileContents)) return failed(getTypeMismatchError({
142
124
  filename: cssModuleInterfaceFilename,
143
125
  expected: cssModulesCode,
144
126
  actual: fileContents
145
- })
146
- );
147
- }
148
- return success();
149
- });
150
- } else {
151
- read((_, fileContents) => {
152
- if (!compareText(cssModulesCode, fileContents)) {
153
- write(cssModulesCode, (err) => {
154
- if (err) {
155
- failed(err);
156
- } else {
157
- success();
158
- }
127
+ }));
128
+ return success();
129
+ } : (_, fileContents)=>{
130
+ if (compareText(cssModulesCode, fileContents)) success();
131
+ else write(cssModulesCode, (err)=>{
132
+ if (err) failed(err);
133
+ else success();
159
134
  });
160
- } else {
161
- success();
162
- }
163
135
  });
164
- }
165
136
  }
166
- export {
167
- loader_default as default,
168
- isInNodeModules,
169
- wrapQuotes
170
- };
137
+ export { loader_rslib_entry_ as default, isInNodeModules, wrapQuotes };
@@ -1,96 +1,121 @@
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 plugin_exports = {};
29
- __export(plugin_exports, {
30
- PluginTypedCssModules: () => PluginTypedCssModules
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
+ PluginTypedCssModules: ()=>PluginTypedCssModules
31
43
  });
32
- module.exports = __toCommonJS(plugin_exports);
33
- var import_node_fs = __toESM(require("node:fs"));
34
- var import_constants = require("../constants.cjs");
35
- var import_logger = require("../logger.cjs");
36
- var import_tinyglobby = require("tinyglobby");
37
- var import_typed_css_modules = __toESM(require("typed-css-modules"));
38
- var import_utils = require("./utils.cjs");
39
- const statPromise = import_node_fs.default.promises.stat;
44
+ const external_node_fs_namespaceObject = require("node:fs");
45
+ var external_node_fs_default = /*#__PURE__*/ __webpack_require__.n(external_node_fs_namespaceObject);
46
+ const external_constants_cjs_namespaceObject = require("../constants.cjs");
47
+ const external_logger_cjs_namespaceObject = require("../logger.cjs");
48
+ const external_tinyglobby_namespaceObject = require("tinyglobby");
49
+ const external_typed_css_modules_namespaceObject = require("typed-css-modules");
50
+ var external_typed_css_modules_default = /*#__PURE__*/ __webpack_require__.n(external_typed_css_modules_namespaceObject);
51
+ const external_utils_cjs_namespaceObject = require("./utils.cjs");
52
+ function _define_property(obj, key, value) {
53
+ if (key in obj) Object.defineProperty(obj, key, {
54
+ value: value,
55
+ enumerable: true,
56
+ configurable: true,
57
+ writable: true
58
+ });
59
+ else obj[key] = value;
60
+ return obj;
61
+ }
62
+ const statPromise = external_node_fs_default().promises.stat;
40
63
  async function writeFile(dtsCreator, cssFile) {
41
- const content = await dtsCreator.create(cssFile, void 0, true);
42
- await content.writeFile((definition) => {
43
- return `// Generated automatically, do not edit
44
- ${definition}`;
45
- });
64
+ const content = await dtsCreator.create(cssFile, void 0, true);
65
+ await content.writeFile((definition)=>`// Generated automatically, do not edit\n${definition}`);
46
66
  }
47
67
  async function generateTypingIfNecessary(dtsCreator, cssFile) {
48
- let typingStat;
49
- try {
50
- typingStat = await statPromise(`${cssFile}.d.ts`);
51
- } catch (_) {
52
- return writeFile(dtsCreator, cssFile);
53
- }
54
- const cssFileStat = await statPromise(cssFile);
55
- if (cssFileStat.mtime.getTime() > typingStat.mtime.getTime()) {
56
- return writeFile(dtsCreator, cssFile);
57
- }
68
+ let typingStat;
69
+ try {
70
+ typingStat = await statPromise(`${cssFile}.d.ts`);
71
+ } catch (_) {
72
+ return writeFile(dtsCreator, cssFile);
73
+ }
74
+ const cssFileStat = await statPromise(cssFile);
75
+ if (cssFileStat.mtime.getTime() > typingStat.mtime.getTime()) return writeFile(dtsCreator, cssFile);
58
76
  }
59
- const PLUGIN_NAME = "PluginTypedCssModules";
77
+ const PLUGIN_NAME = 'PluginTypedCssModules';
60
78
  class PluginTypedCssModules {
61
- constructor(options) {
62
- this.useIncremental = false;
63
- this.globPattern = "src/**/*.{css,less,scss}";
64
- this.userOptions = options;
65
- this.dtsCreator = new import_typed_css_modules.default({
66
- camelCase: true,
67
- namedExports: import_constants.CSS_NAMED_EXPORT
68
- });
69
- }
70
- apply(compiler) {
71
- compiler.hooks.run.tapPromise(PLUGIN_NAME, async () => {
72
- await this.generateCssTypings(this.useIncremental);
73
- });
74
- compiler.hooks.watchRun.tapPromise(PLUGIN_NAME, async () => {
75
- try {
76
- await this.generateCssTypings(this.useIncremental);
77
- } catch (err) {
78
- import_logger.logger.error(err.toString());
79
- } finally {
80
- this.useIncremental = true;
81
- }
82
- });
83
- }
84
- async generateCssTypings(incremental) {
85
- const files = await (0, import_tinyglobby.glob)(this.globPattern);
86
- const cssModulesFiles = files.filter((file) => {
87
- return (0, import_utils.isCSSModules)({ resourcePath: file, modules: this.userOptions?.modules });
88
- });
89
- const doTask = incremental ? generateTypingIfNecessary : writeFile;
90
- return Promise.all(cssModulesFiles.map((file) => doTask(this.dtsCreator, file)));
91
- }
79
+ apply(compiler) {
80
+ compiler.hooks.run.tapPromise(PLUGIN_NAME, async ()=>{
81
+ await this.generateCssTypings(this.useIncremental);
82
+ });
83
+ compiler.hooks.watchRun.tapPromise(PLUGIN_NAME, async ()=>{
84
+ try {
85
+ await this.generateCssTypings(this.useIncremental);
86
+ } catch (err) {
87
+ external_logger_cjs_namespaceObject.logger.error(err.toString());
88
+ } finally{
89
+ this.useIncremental = true;
90
+ }
91
+ });
92
+ }
93
+ async generateCssTypings(incremental) {
94
+ const files = await (0, external_tinyglobby_namespaceObject.glob)(this.globPattern);
95
+ const cssModulesFiles = files.filter((file)=>{
96
+ var _this_userOptions;
97
+ return (0, external_utils_cjs_namespaceObject.isCSSModules)({
98
+ resourcePath: file,
99
+ modules: null === (_this_userOptions = this.userOptions) || void 0 === _this_userOptions ? void 0 : _this_userOptions.modules
100
+ });
101
+ });
102
+ const doTask = incremental ? generateTypingIfNecessary : writeFile;
103
+ return Promise.all(cssModulesFiles.map((file)=>doTask(this.dtsCreator, file)));
104
+ }
105
+ constructor(options){
106
+ _define_property(this, "dtsCreator", void 0);
107
+ _define_property(this, "useIncremental", false);
108
+ _define_property(this, "globPattern", 'src/**/*.{css,less,scss}');
109
+ _define_property(this, "userOptions", void 0);
110
+ this.userOptions = options;
111
+ this.dtsCreator = new (external_typed_css_modules_default())({
112
+ camelCase: true,
113
+ namedExports: external_constants_cjs_namespaceObject.CSS_NAMED_EXPORT
114
+ });
115
+ }
92
116
  }
93
- // Annotate the CommonJS export names for ESM import in node:
94
- 0 && (module.exports = {
95
- PluginTypedCssModules
117
+ var __webpack_export_target__ = exports;
118
+ for(var __webpack_i__ in __webpack_exports__)__webpack_export_target__[__webpack_i__] = __webpack_exports__[__webpack_i__];
119
+ if (__webpack_exports__.__esModule) Object.defineProperty(__webpack_export_target__, '__esModule', {
120
+ value: true
96
121
  });
@@ -1,4 +1,4 @@
1
- import type { UnpackConfig } from '../types/index';
1
+ import type { UnpackConfig } from 'src/types/index';
2
2
  import type { Compiler } from 'webpack';
3
3
  type PluginTypedCssModulesOptions = {
4
4
  modules?: UnpackConfig['css']['modules'];