@unpackjs/core 2.4.0 → 2.4.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.
Files changed (195) hide show
  1. package/dist/index.cjs +2028 -196
  2. package/dist/index.js +1876 -39
  3. package/dist/lightningcssLoader.mjs +18 -0
  4. package/dist/typedCssModulesLoader.mjs +139 -0
  5. package/{dist → dist-types}/bundler-config/cache.d.ts +1 -1
  6. package/dist-types/bundler-config/cache.d.ts.map +1 -0
  7. package/{dist → dist-types}/bundler-config/chunkSplit.d.ts +1 -1
  8. package/dist-types/bundler-config/chunkSplit.d.ts.map +1 -0
  9. package/{dist → dist-types}/bundler-config/css.d.ts +1 -1
  10. package/dist-types/bundler-config/css.d.ts.map +1 -0
  11. package/{dist → dist-types}/bundler-config/experimentCss.d.ts +1 -1
  12. package/dist-types/bundler-config/experimentCss.d.ts.map +1 -0
  13. package/{dist → dist-types}/bundler-config/index.d.ts +1 -1
  14. package/dist-types/bundler-config/index.d.ts.map +1 -0
  15. package/{dist/lightningcss/loader.d.ts → dist-types/bundler-config/loaders/lightningcssLoader.d.ts} +2 -2
  16. package/dist-types/bundler-config/loaders/lightningcssLoader.d.ts.map +1 -0
  17. package/dist-types/bundler-config/loaders/typedCssModulesLoader.d.ts +6 -0
  18. package/dist-types/bundler-config/loaders/typedCssModulesLoader.d.ts.map +1 -0
  19. package/{dist/bundler-config → dist-types/bundler-config/plugins}/jsMinify.d.ts +1 -1
  20. package/dist-types/bundler-config/plugins/jsMinify.d.ts.map +1 -0
  21. package/{dist/lightningcss/minimizer.d.ts → dist-types/bundler-config/plugins/lightningcssMinify.d.ts} +2 -3
  22. package/dist-types/bundler-config/plugins/lightningcssMinify.d.ts.map +1 -0
  23. package/{dist/bundler-config/oxlint/plugin.d.ts → dist-types/bundler-config/plugins/oxlint/index.d.ts} +1 -1
  24. package/dist-types/bundler-config/plugins/oxlint/index.d.ts.map +1 -0
  25. package/dist-types/bundler-config/plugins/progress/helpers.d.ts.map +1 -0
  26. package/{dist/bundler-config → dist-types/bundler-config/plugins}/progress/rspack.d.ts +1 -1
  27. package/dist-types/bundler-config/plugins/progress/rspack.d.ts.map +1 -0
  28. package/{dist/bundler-config → dist-types/bundler-config/plugins}/progress/webpack.d.ts +1 -1
  29. package/dist-types/bundler-config/plugins/progress/webpack.d.ts.map +1 -0
  30. package/{dist/typed-css-modules/plugin.d.ts → dist-types/bundler-config/plugins/typedCssModules.d.ts} +2 -2
  31. package/dist-types/bundler-config/plugins/typedCssModules.d.ts.map +1 -0
  32. package/{dist → dist-types}/config.d.ts +1 -1
  33. package/dist-types/config.d.ts.map +1 -0
  34. package/{dist → dist-types}/createUnpack.d.ts +1 -1
  35. package/{dist → dist-types}/createUnpack.d.ts.map +1 -1
  36. package/{dist → dist-types}/index.d.ts +1 -1
  37. package/{dist → dist-types}/index.d.ts.map +1 -1
  38. package/dist-types/logger.d.ts +3 -0
  39. package/{dist → dist-types}/logger.d.ts.map +1 -1
  40. package/{dist → dist-types}/plugin.d.ts +1 -1
  41. package/{dist → dist-types}/plugin.d.ts.map +1 -1
  42. package/dist-types/run/build.d.ts +3 -0
  43. package/{dist → dist-types}/run/build.d.ts.map +1 -1
  44. package/{dist → dist-types}/run/dev.d.ts +1 -1
  45. package/{dist → dist-types}/run/dev.d.ts.map +1 -1
  46. package/{dist → dist-types}/types/config.d.ts +1 -1
  47. package/{dist → dist-types}/types/config.d.ts.map +1 -1
  48. package/{dist → dist-types}/types/index.d.ts +1 -0
  49. package/{dist → dist-types}/types/index.d.ts.map +1 -1
  50. package/{dist → dist-types}/utils.d.ts +5 -1
  51. package/dist-types/utils.d.ts.map +1 -0
  52. package/package.json +6 -37
  53. package/dist/bundler-config/cache.cjs +0 -114
  54. package/dist/bundler-config/cache.d.ts.map +0 -1
  55. package/dist/bundler-config/cache.js +0 -72
  56. package/dist/bundler-config/chunkSplit.cjs +0 -192
  57. package/dist/bundler-config/chunkSplit.d.ts.map +0 -1
  58. package/dist/bundler-config/chunkSplit.js +0 -150
  59. package/dist/bundler-config/css.cjs +0 -189
  60. package/dist/bundler-config/css.d.ts.map +0 -1
  61. package/dist/bundler-config/css.js +0 -149
  62. package/dist/bundler-config/experimentCss.cjs +0 -214
  63. package/dist/bundler-config/experimentCss.d.ts.map +0 -1
  64. package/dist/bundler-config/experimentCss.js +0 -175
  65. package/dist/bundler-config/helpers.cjs +0 -77
  66. package/dist/bundler-config/helpers.js +0 -31
  67. package/dist/bundler-config/index.cjs +0 -309
  68. package/dist/bundler-config/index.d.ts.map +0 -1
  69. package/dist/bundler-config/index.js +0 -262
  70. package/dist/bundler-config/jsMinify.cjs +0 -113
  71. package/dist/bundler-config/jsMinify.d.ts.map +0 -1
  72. package/dist/bundler-config/jsMinify.js +0 -71
  73. package/dist/bundler-config/oxlint/plugin.cjs +0 -143
  74. package/dist/bundler-config/oxlint/plugin.d.ts.map +0 -1
  75. package/dist/bundler-config/oxlint/plugin.js +0 -104
  76. package/dist/bundler-config/progress/helpers.cjs +0 -126
  77. package/dist/bundler-config/progress/helpers.d.ts.map +0 -1
  78. package/dist/bundler-config/progress/helpers.js +0 -81
  79. package/dist/bundler-config/progress/rspack.cjs +0 -70
  80. package/dist/bundler-config/progress/rspack.d.ts.map +0 -1
  81. package/dist/bundler-config/progress/rspack.js +0 -38
  82. package/dist/bundler-config/progress/webpack.cjs +0 -87
  83. package/dist/bundler-config/progress/webpack.d.ts.map +0 -1
  84. package/dist/bundler-config/progress/webpack.js +0 -45
  85. package/dist/colors.cjs +0 -82
  86. package/dist/colors.js +0 -40
  87. package/dist/config.cjs +0 -148
  88. package/dist/config.d.ts.map +0 -1
  89. package/dist/config.js +0 -101
  90. package/dist/constants.cjs +0 -122
  91. package/dist/constants.js +0 -51
  92. package/dist/createUnpack.cjs +0 -107
  93. package/dist/createUnpack.js +0 -75
  94. package/dist/fs.cjs +0 -91
  95. package/dist/fs.js +0 -34
  96. package/dist/global.cjs +0 -36
  97. package/dist/global.js +0 -4
  98. package/dist/lightningcss/loader.cjs +0 -57
  99. package/dist/lightningcss/loader.d.ts.map +0 -1
  100. package/dist/lightningcss/loader.js +0 -25
  101. package/dist/lightningcss/minimizer.cjs +0 -94
  102. package/dist/lightningcss/minimizer.d.ts.map +0 -1
  103. package/dist/lightningcss/minimizer.js +0 -59
  104. package/dist/loadEnv.cjs +0 -122
  105. package/dist/loadEnv.js +0 -80
  106. package/dist/loadingAnimation.cjs +0 -76
  107. package/dist/loadingAnimation.js +0 -44
  108. package/dist/logger.cjs +0 -116
  109. package/dist/logger.d.ts +0 -3
  110. package/dist/logger.js +0 -74
  111. package/dist/openBrowser.cjs +0 -89
  112. package/dist/openBrowser.js +0 -49
  113. package/dist/plugin.cjs +0 -42
  114. package/dist/plugin.js +0 -10
  115. package/dist/prebundleDeps.cjs +0 -349
  116. package/dist/prebundleDeps.js +0 -303
  117. package/dist/progressBar.cjs +0 -66
  118. package/dist/progressBar.js +0 -34
  119. package/dist/reporter.cjs +0 -164
  120. package/dist/reporter.js +0 -120
  121. package/dist/run/build.cjs +0 -68
  122. package/dist/run/build.d.ts +0 -3
  123. package/dist/run/build.js +0 -26
  124. package/dist/run/dev.cjs +0 -118
  125. package/dist/run/dev.js +0 -75
  126. package/dist/run/index.cjs +0 -69
  127. package/dist/run/index.js +0 -4
  128. package/dist/typed-css-modules/loader.cjs +0 -141
  129. package/dist/typed-css-modules/loader.d.ts +0 -8
  130. package/dist/typed-css-modules/loader.d.ts.map +0 -1
  131. package/dist/typed-css-modules/loader.js +0 -92
  132. package/dist/typed-css-modules/plugin.cjs +0 -117
  133. package/dist/typed-css-modules/plugin.d.ts.map +0 -1
  134. package/dist/typed-css-modules/plugin.js +0 -74
  135. package/dist/typed-css-modules/utils.cjs +0 -46
  136. package/dist/typed-css-modules/utils.d.ts +0 -6
  137. package/dist/typed-css-modules/utils.d.ts.map +0 -1
  138. package/dist/typed-css-modules/utils.js +0 -14
  139. package/dist/types/chunkSplit.cjs +0 -18
  140. package/dist/types/chunkSplit.js +0 -2
  141. package/dist/types/config.cjs +0 -18
  142. package/dist/types/config.js +0 -2
  143. package/dist/types/index.cjs +0 -96
  144. package/dist/types/index.js +0 -7
  145. package/dist/types/lightningcss.cjs +0 -18
  146. package/dist/types/lightningcss.js +0 -2
  147. package/dist/types/logger.cjs +0 -45
  148. package/dist/types/logger.js +0 -13
  149. package/dist/types/oxc.cjs +0 -18
  150. package/dist/types/oxc.js +0 -2
  151. package/dist/types/plugin.cjs +0 -18
  152. package/dist/types/plugin.js +0 -2
  153. package/dist/utils.cjs +0 -346
  154. package/dist/utils.d.ts.map +0 -1
  155. package/dist/utils.js +0 -204
  156. package/dist/watchFiles.cjs +0 -69
  157. package/dist/watchFiles.js +0 -27
  158. /package/dist/{bundler-config/oxlint/.oxlintrc.json → .oxlintrc.json} +0 -0
  159. /package/{dist → dist-types}/bundler-config/helpers.d.ts +0 -0
  160. /package/{dist → dist-types}/bundler-config/helpers.d.ts.map +0 -0
  161. /package/{dist/bundler-config → dist-types/bundler-config/plugins}/progress/helpers.d.ts +0 -0
  162. /package/{dist → dist-types}/colors.d.ts +0 -0
  163. /package/{dist → dist-types}/colors.d.ts.map +0 -0
  164. /package/{dist → dist-types}/constants.d.ts +0 -0
  165. /package/{dist → dist-types}/constants.d.ts.map +0 -0
  166. /package/{dist → dist-types}/fs.d.ts +0 -0
  167. /package/{dist → dist-types}/fs.d.ts.map +0 -0
  168. /package/{dist → dist-types}/global.d.ts +0 -0
  169. /package/{dist → dist-types}/global.d.ts.map +0 -0
  170. /package/{dist → dist-types}/loadEnv.d.ts +0 -0
  171. /package/{dist → dist-types}/loadEnv.d.ts.map +0 -0
  172. /package/{dist → dist-types}/loadingAnimation.d.ts +0 -0
  173. /package/{dist → dist-types}/loadingAnimation.d.ts.map +0 -0
  174. /package/{dist → dist-types}/openBrowser.d.ts +0 -0
  175. /package/{dist → dist-types}/openBrowser.d.ts.map +0 -0
  176. /package/{dist → dist-types}/prebundleDeps.d.ts +0 -0
  177. /package/{dist → dist-types}/prebundleDeps.d.ts.map +0 -0
  178. /package/{dist → dist-types}/progressBar.d.ts +0 -0
  179. /package/{dist → dist-types}/progressBar.d.ts.map +0 -0
  180. /package/{dist → dist-types}/reporter.d.ts +0 -0
  181. /package/{dist → dist-types}/reporter.d.ts.map +0 -0
  182. /package/{dist → dist-types}/run/index.d.ts +0 -0
  183. /package/{dist → dist-types}/run/index.d.ts.map +0 -0
  184. /package/{dist → dist-types}/types/chunkSplit.d.ts +0 -0
  185. /package/{dist → dist-types}/types/chunkSplit.d.ts.map +0 -0
  186. /package/{dist → dist-types}/types/lightningcss.d.ts +0 -0
  187. /package/{dist → dist-types}/types/lightningcss.d.ts.map +0 -0
  188. /package/{dist → dist-types}/types/logger.d.ts +0 -0
  189. /package/{dist → dist-types}/types/logger.d.ts.map +0 -0
  190. /package/{dist → dist-types}/types/oxc.d.ts +0 -0
  191. /package/{dist → dist-types}/types/oxc.d.ts.map +0 -0
  192. /package/{dist → dist-types}/types/plugin.d.ts +0 -0
  193. /package/{dist → dist-types}/types/plugin.d.ts.map +0 -0
  194. /package/{dist → dist-types}/watchFiles.d.ts +0 -0
  195. /package/{dist → dist-types}/watchFiles.d.ts.map +0 -0
@@ -1,69 +0,0 @@
1
- "use strict";
2
- var __webpack_modules__ = {
3
- "./build": function(module) {
4
- module.exports = require("./build.cjs");
5
- },
6
- "./dev": function(module) {
7
- module.exports = require("./dev.cjs");
8
- }
9
- };
10
- var __webpack_module_cache__ = {};
11
- function __webpack_require__(moduleId) {
12
- var cachedModule = __webpack_module_cache__[moduleId];
13
- if (void 0 !== cachedModule) return cachedModule.exports;
14
- var module = __webpack_module_cache__[moduleId] = {
15
- exports: {}
16
- };
17
- __webpack_modules__[moduleId](module, module.exports, __webpack_require__);
18
- return module.exports;
19
- }
20
- (()=>{
21
- __webpack_require__.n = (module)=>{
22
- var getter = module && module.__esModule ? ()=>module['default'] : ()=>module;
23
- __webpack_require__.d(getter, {
24
- a: getter
25
- });
26
- return getter;
27
- };
28
- })();
29
- (()=>{
30
- __webpack_require__.d = (exports1, definition)=>{
31
- for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
32
- enumerable: true,
33
- get: definition[key]
34
- });
35
- };
36
- })();
37
- (()=>{
38
- __webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
39
- })();
40
- (()=>{
41
- __webpack_require__.r = (exports1)=>{
42
- if ('undefined' != typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
43
- value: 'Module'
44
- });
45
- Object.defineProperty(exports1, '__esModule', {
46
- value: true
47
- });
48
- };
49
- })();
50
- var __webpack_exports__ = {};
51
- (()=>{
52
- __webpack_require__.r(__webpack_exports__);
53
- var _build__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__("./build");
54
- var __WEBPACK_REEXPORT_OBJECT__ = {};
55
- for(var __WEBPACK_IMPORT_KEY__ in _build__WEBPACK_IMPORTED_MODULE_0__)if ("default" !== __WEBPACK_IMPORT_KEY__) __WEBPACK_REEXPORT_OBJECT__[__WEBPACK_IMPORT_KEY__] = (function(key) {
56
- return _build__WEBPACK_IMPORTED_MODULE_0__[key];
57
- }).bind(0, __WEBPACK_IMPORT_KEY__);
58
- __webpack_require__.d(__webpack_exports__, __WEBPACK_REEXPORT_OBJECT__);
59
- var _dev__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__("./dev");
60
- var __WEBPACK_REEXPORT_OBJECT__ = {};
61
- for(var __WEBPACK_IMPORT_KEY__ in _dev__WEBPACK_IMPORTED_MODULE_1__)if ("default" !== __WEBPACK_IMPORT_KEY__) __WEBPACK_REEXPORT_OBJECT__[__WEBPACK_IMPORT_KEY__] = (function(key) {
62
- return _dev__WEBPACK_IMPORTED_MODULE_1__[key];
63
- }).bind(0, __WEBPACK_IMPORT_KEY__);
64
- __webpack_require__.d(__webpack_exports__, __WEBPACK_REEXPORT_OBJECT__);
65
- })();
66
- for(var __webpack_i__ in __webpack_exports__)exports[__webpack_i__] = __webpack_exports__[__webpack_i__];
67
- Object.defineProperty(exports, '__esModule', {
68
- value: true
69
- });
package/dist/run/index.js DELETED
@@ -1,4 +0,0 @@
1
- import 'module';
2
- /*#__PURE__*/ import.meta.url;
3
- export * from "./build.js";
4
- export * from "./dev.js";
@@ -1,141 +0,0 @@
1
- "use strict";
2
- var __webpack_require__ = {};
3
- (()=>{
4
- __webpack_require__.n = (module)=>{
5
- var getter = module && module.__esModule ? ()=>module['default'] : ()=>module;
6
- __webpack_require__.d(getter, {
7
- a: getter
8
- });
9
- return getter;
10
- };
11
- })();
12
- (()=>{
13
- __webpack_require__.d = (exports1, definition)=>{
14
- for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
15
- enumerable: true,
16
- get: definition[key]
17
- });
18
- };
19
- })();
20
- (()=>{
21
- __webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
22
- })();
23
- (()=>{
24
- __webpack_require__.r = (exports1)=>{
25
- if ('undefined' != typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
26
- value: 'Module'
27
- });
28
- Object.defineProperty(exports1, '__esModule', {
29
- value: true
30
- });
31
- };
32
- })();
33
- var __webpack_exports__ = {};
34
- __webpack_require__.r(__webpack_exports__);
35
- __webpack_require__.d(__webpack_exports__, {
36
- wrapQuotes: ()=>wrapQuotes,
37
- default: ()=>loader,
38
- isInNodeModules: ()=>isInNodeModules
39
- });
40
- const external_node_fs_namespaceObject = require("node:fs");
41
- var external_node_fs_default = /*#__PURE__*/ __webpack_require__.n(external_node_fs_namespaceObject);
42
- const external_node_path_namespaceObject = require("node:path");
43
- var external_node_path_default = /*#__PURE__*/ __webpack_require__.n(external_node_path_namespaceObject);
44
- const external_constants_cjs_namespaceObject = require("../constants.cjs");
45
- const external_utils_cjs_namespaceObject = require("./utils.cjs");
46
- const isInNodeModules = (path)=>external_constants_cjs_namespaceObject.NODE_MODULES_REGEX.test(path);
47
- function wrapQuotes(key) {
48
- const isValidIdentifier = /^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(key);
49
- if (isValidIdentifier) return key;
50
- return `'${key}'`;
51
- }
52
- const cssModuleToNamedExports = (cssModuleKeys)=>cssModuleKeys.sort().map((key)=>`export const ${key}: string;`).join('\n');
53
- const cssModuleToInterface = (cssModulesKeys)=>{
54
- const interfaceFields = cssModulesKeys.sort().map((key)=>` ${wrapQuotes(key)}: string;`).join('\n');
55
- return `interface CssExports {\n${interfaceFields}\n}`;
56
- };
57
- const filenameToTypingsFilename = (filename)=>{
58
- const dirName = external_node_path_default().dirname(filename);
59
- const baseName = external_node_path_default().basename(filename);
60
- return external_node_path_default().join(dirName, `${baseName}.d.ts`);
61
- };
62
- const enforceLFLineSeparators = (text)=>{
63
- if (text) return text.replace(/\r\n/g, '\n');
64
- return text;
65
- };
66
- const compareText = (contentA, contentB)=>enforceLFLineSeparators(contentA) === enforceLFLineSeparators(contentB);
67
- const makeDoneHandlers = (callback, content, rest)=>({
68
- failed: (e)=>callback(e),
69
- success: ()=>callback(null, content, ...rest)
70
- });
71
- const makeFileHandlers = (filename)=>({
72
- read: (handler)=>external_node_fs_default().readFile(filename, {
73
- encoding: 'utf-8'
74
- }, handler),
75
- write: (content, handler)=>external_node_fs_default().writeFile(filename, content, {
76
- encoding: 'utf-8'
77
- }, handler)
78
- });
79
- const extractLocalExports = (content)=>{
80
- let localExports = content.split('exports.locals')[1];
81
- if (!localExports) localExports = content.split('___CSS_LOADER_EXPORT___.locals')[1];
82
- return localExports;
83
- };
84
- const getCSSModulesKeys = (content, namedExport)=>{
85
- const keys = new Set();
86
- if (namedExport) {
87
- const exportsRegex = /export\s+var\s+(\w+)\s*=/g;
88
- let match = exportsRegex.exec(content);
89
- while(null !== match){
90
- keys.add(match[1]);
91
- match = exportsRegex.exec(content);
92
- }
93
- return Array.from(keys);
94
- }
95
- const localExports = extractLocalExports(content);
96
- const keyRegex = /"([^\\"]+)":/g;
97
- let match = keyRegex.exec(localExports);
98
- while(null !== match){
99
- keys.add(match[1]);
100
- match = keyRegex.exec(localExports);
101
- }
102
- return Array.from(keys);
103
- };
104
- function codegen(keys, namedExport) {
105
- const bannerMessage = '// Generated automatically, do not edit';
106
- if (namedExport) return `${bannerMessage}\n${cssModuleToNamedExports(keys)}\n`;
107
- const cssModuleExport = 'declare const cssExports: CssExports;\nexport default cssExports;\n';
108
- return `${bannerMessage}\n${cssModuleToInterface(keys)}\n${cssModuleExport}`;
109
- }
110
- function loader(content, ...rest) {
111
- const { failed, success } = makeDoneHandlers(this.async(), content, rest);
112
- const { resourcePath } = this;
113
- const { modules } = this.getOptions() || {};
114
- if (!(0, external_utils_cjs_namespaceObject.isCSSModules)({
115
- resourcePath,
116
- modules
117
- }) || isInNodeModules(resourcePath)) return void success();
118
- const cssModuleInterfaceFilename = filenameToTypingsFilename(resourcePath);
119
- const { read, write } = makeFileHandlers(cssModuleInterfaceFilename);
120
- const namedExport = external_constants_cjs_namespaceObject.CSS_NAMED_EXPORT;
121
- const cssModulesKeys = getCSSModulesKeys(content, namedExport);
122
- const cssModulesCode = codegen(cssModulesKeys, namedExport);
123
- read((_, fileContents)=>{
124
- if (compareText(cssModulesCode, fileContents)) success();
125
- else write(cssModulesCode, (err)=>{
126
- if (err) failed(err);
127
- else success();
128
- });
129
- });
130
- }
131
- exports["default"] = __webpack_exports__["default"];
132
- exports.isInNodeModules = __webpack_exports__.isInNodeModules;
133
- exports.wrapQuotes = __webpack_exports__.wrapQuotes;
134
- for(var __webpack_i__ in __webpack_exports__)if (-1 === [
135
- "default",
136
- "isInNodeModules",
137
- "wrapQuotes"
138
- ].indexOf(__webpack_i__)) exports[__webpack_i__] = __webpack_exports__[__webpack_i__];
139
- Object.defineProperty(exports, '__esModule', {
140
- value: true
141
- });
@@ -1,8 +0,0 @@
1
- import type * as Rspack from '@rspack/core';
2
- import type { UnpackConfig } from '../types/index';
3
- export declare const isInNodeModules: (path: string) => boolean;
4
- export declare function wrapQuotes(key: string): string;
5
- export default function (this: Rspack.LoaderContext<{
6
- modules: NonNullable<UnpackConfig['css']>['modules'];
7
- }>, content: string, ...rest: any[]): void;
8
- //# sourceMappingURL=loader.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"loader.d.ts","sourceRoot":"","sources":["../../src/typed-css-modules/loader.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,KAAK,MAAM,MAAM,cAAc,CAAA;AAE3C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAA;AAGnD,eAAO,MAAM,eAAe,GAAI,MAAM,MAAM,YAAkC,CAAA;AAE9E,wBAAgB,UAAU,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAQ9C;AA+FD,MAAM,CAAC,OAAO,WACZ,IAAI,EAAE,MAAM,CAAC,aAAa,CAAC;IACzB,OAAO,EAAE,WAAW,CAAC,YAAY,CAAC,KAAK,CAAC,CAAC,CAAC,SAAS,CAAC,CAAA;CACrD,CAAC,EACF,OAAO,EAAE,MAAM,EACf,GAAG,IAAI,EAAE,GAAG,EAAE,GACb,IAAI,CA+BN"}
@@ -1,92 +0,0 @@
1
- import 'module';
2
- /*#__PURE__*/ import.meta.url;
3
- import node_fs from "node:fs";
4
- import node_path from "node:path";
5
- import { CSS_NAMED_EXPORT, NODE_MODULES_REGEX } from "../constants.js";
6
- import { isCSSModules } from "./utils.js";
7
- const isInNodeModules = (path)=>NODE_MODULES_REGEX.test(path);
8
- function wrapQuotes(key) {
9
- const isValidIdentifier = /^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(key);
10
- if (isValidIdentifier) return key;
11
- return `'${key}'`;
12
- }
13
- const cssModuleToNamedExports = (cssModuleKeys)=>cssModuleKeys.sort().map((key)=>`export const ${key}: string;`).join('\n');
14
- const cssModuleToInterface = (cssModulesKeys)=>{
15
- const interfaceFields = cssModulesKeys.sort().map((key)=>` ${wrapQuotes(key)}: string;`).join('\n');
16
- return `interface CssExports {\n${interfaceFields}\n}`;
17
- };
18
- const filenameToTypingsFilename = (filename)=>{
19
- const dirName = node_path.dirname(filename);
20
- const baseName = node_path.basename(filename);
21
- return node_path.join(dirName, `${baseName}.d.ts`);
22
- };
23
- const enforceLFLineSeparators = (text)=>{
24
- if (text) return text.replace(/\r\n/g, '\n');
25
- return text;
26
- };
27
- const compareText = (contentA, contentB)=>enforceLFLineSeparators(contentA) === enforceLFLineSeparators(contentB);
28
- const makeDoneHandlers = (callback, content, rest)=>({
29
- failed: (e)=>callback(e),
30
- success: ()=>callback(null, content, ...rest)
31
- });
32
- const makeFileHandlers = (filename)=>({
33
- read: (handler)=>node_fs.readFile(filename, {
34
- encoding: 'utf-8'
35
- }, handler),
36
- write: (content, handler)=>node_fs.writeFile(filename, content, {
37
- encoding: 'utf-8'
38
- }, handler)
39
- });
40
- const extractLocalExports = (content)=>{
41
- let localExports = content.split('exports.locals')[1];
42
- if (!localExports) localExports = content.split('___CSS_LOADER_EXPORT___.locals')[1];
43
- return localExports;
44
- };
45
- const getCSSModulesKeys = (content, namedExport)=>{
46
- const keys = new Set();
47
- if (namedExport) {
48
- const exportsRegex = /export\s+var\s+(\w+)\s*=/g;
49
- let match = exportsRegex.exec(content);
50
- while(null !== match){
51
- keys.add(match[1]);
52
- match = exportsRegex.exec(content);
53
- }
54
- return Array.from(keys);
55
- }
56
- const localExports = extractLocalExports(content);
57
- const keyRegex = /"([^\\"]+)":/g;
58
- let match = keyRegex.exec(localExports);
59
- while(null !== match){
60
- keys.add(match[1]);
61
- match = keyRegex.exec(localExports);
62
- }
63
- return Array.from(keys);
64
- };
65
- function codegen(keys, namedExport) {
66
- const bannerMessage = '// Generated automatically, do not edit';
67
- if (namedExport) return `${bannerMessage}\n${cssModuleToNamedExports(keys)}\n`;
68
- const cssModuleExport = 'declare const cssExports: CssExports;\nexport default cssExports;\n';
69
- return `${bannerMessage}\n${cssModuleToInterface(keys)}\n${cssModuleExport}`;
70
- }
71
- function loader(content, ...rest) {
72
- const { failed, success } = makeDoneHandlers(this.async(), content, rest);
73
- const { resourcePath } = this;
74
- const { modules } = this.getOptions() || {};
75
- if (!isCSSModules({
76
- resourcePath,
77
- modules
78
- }) || isInNodeModules(resourcePath)) return void success();
79
- const cssModuleInterfaceFilename = filenameToTypingsFilename(resourcePath);
80
- const { read, write } = makeFileHandlers(cssModuleInterfaceFilename);
81
- const namedExport = CSS_NAMED_EXPORT;
82
- const cssModulesKeys = getCSSModulesKeys(content, namedExport);
83
- const cssModulesCode = codegen(cssModulesKeys, namedExport);
84
- read((_, fileContents)=>{
85
- if (compareText(cssModulesCode, fileContents)) success();
86
- else write(cssModulesCode, (err)=>{
87
- if (err) failed(err);
88
- else success();
89
- });
90
- });
91
- }
92
- export { loader as default, isInNodeModules, wrapQuotes };
@@ -1,117 +0,0 @@
1
- "use strict";
2
- var __webpack_require__ = {};
3
- (()=>{
4
- __webpack_require__.n = (module)=>{
5
- var getter = module && module.__esModule ? ()=>module['default'] : ()=>module;
6
- __webpack_require__.d(getter, {
7
- a: getter
8
- });
9
- return getter;
10
- };
11
- })();
12
- (()=>{
13
- __webpack_require__.d = (exports1, definition)=>{
14
- for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
15
- enumerable: true,
16
- get: definition[key]
17
- });
18
- };
19
- })();
20
- (()=>{
21
- __webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
22
- })();
23
- (()=>{
24
- __webpack_require__.r = (exports1)=>{
25
- if ('undefined' != typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
26
- value: 'Module'
27
- });
28
- Object.defineProperty(exports1, '__esModule', {
29
- value: true
30
- });
31
- };
32
- })();
33
- var __webpack_exports__ = {};
34
- __webpack_require__.r(__webpack_exports__);
35
- __webpack_require__.d(__webpack_exports__, {
36
- TypedCssModulesPlugin: ()=>TypedCssModulesPlugin
37
- });
38
- const external_node_fs_namespaceObject = require("node:fs");
39
- var external_node_fs_default = /*#__PURE__*/ __webpack_require__.n(external_node_fs_namespaceObject);
40
- const external_constants_cjs_namespaceObject = require("../constants.cjs");
41
- const external_logger_cjs_namespaceObject = require("../logger.cjs");
42
- const external_tinyglobby_namespaceObject = require("tinyglobby");
43
- const external_typed_css_modules_namespaceObject = require("typed-css-modules");
44
- var external_typed_css_modules_default = /*#__PURE__*/ __webpack_require__.n(external_typed_css_modules_namespaceObject);
45
- const external_utils_cjs_namespaceObject = require("./utils.cjs");
46
- function _define_property(obj, key, value) {
47
- if (key in obj) Object.defineProperty(obj, key, {
48
- value: value,
49
- enumerable: true,
50
- configurable: true,
51
- writable: true
52
- });
53
- else obj[key] = value;
54
- return obj;
55
- }
56
- const statPromise = external_node_fs_default().promises.stat;
57
- async function writeFile(dtsCreator, cssFile) {
58
- const content = await dtsCreator.create(cssFile, void 0, true);
59
- await content.writeFile((definition)=>`// Generated automatically, do not edit\n${definition}`);
60
- }
61
- async function generateTypingIfNecessary(dtsCreator, cssFile) {
62
- let typingStat;
63
- try {
64
- typingStat = await statPromise(`${cssFile}.d.ts`);
65
- } catch {
66
- return writeFile(dtsCreator, cssFile);
67
- }
68
- const cssFileStat = await statPromise(cssFile);
69
- if (cssFileStat.mtime.getTime() > typingStat.mtime.getTime()) return writeFile(dtsCreator, cssFile);
70
- }
71
- const PLUGIN_NAME = 'TypedCssModulesPlugin';
72
- class TypedCssModulesPlugin {
73
- apply(compiler) {
74
- compiler.hooks.run.tapPromise(PLUGIN_NAME, async ()=>{
75
- await this.generateCssTypings(this.useIncremental);
76
- });
77
- compiler.hooks.watchRun.tap(PLUGIN_NAME, ()=>{
78
- setTimeout(()=>{
79
- this.generateCssTypings(this.useIncremental).catch((err)=>{
80
- external_logger_cjs_namespaceObject.logger.error(err.toString());
81
- }).finally(()=>{
82
- this.useIncremental = true;
83
- });
84
- }, 100);
85
- });
86
- }
87
- async generateCssTypings(incremental) {
88
- const files = await (0, external_tinyglobby_namespaceObject.glob)(this.globPattern);
89
- const cssModulesFiles = files.filter((file)=>{
90
- var _this_userOptions;
91
- return (0, external_utils_cjs_namespaceObject.isCSSModules)({
92
- resourcePath: file,
93
- modules: null == (_this_userOptions = this.userOptions) ? void 0 : _this_userOptions.modules
94
- });
95
- });
96
- const doTask = incremental ? generateTypingIfNecessary : writeFile;
97
- return Promise.all(cssModulesFiles.map((file)=>doTask(this.dtsCreator, file)));
98
- }
99
- constructor(options){
100
- _define_property(this, "dtsCreator", void 0);
101
- _define_property(this, "useIncremental", false);
102
- _define_property(this, "globPattern", 'src/**/*.{css,less,scss}');
103
- _define_property(this, "userOptions", void 0);
104
- this.userOptions = options;
105
- this.dtsCreator = new (external_typed_css_modules_default())({
106
- camelCase: true,
107
- namedExports: external_constants_cjs_namespaceObject.CSS_NAMED_EXPORT
108
- });
109
- }
110
- }
111
- exports.TypedCssModulesPlugin = __webpack_exports__.TypedCssModulesPlugin;
112
- for(var __webpack_i__ in __webpack_exports__)if (-1 === [
113
- "TypedCssModulesPlugin"
114
- ].indexOf(__webpack_i__)) exports[__webpack_i__] = __webpack_exports__[__webpack_i__];
115
- Object.defineProperty(exports, '__esModule', {
116
- value: true
117
- });
@@ -1 +0,0 @@
1
- {"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../../src/typed-css-modules/plugin.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAA;AAGnD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAA;AA2BvC,KAAK,4BAA4B,GAAG;IAClC,OAAO,CAAC,EAAE,WAAW,CAAC,YAAY,CAAC,KAAK,CAAC,CAAC,CAAC,SAAS,CAAC,CAAA;CACtD,CAAA;AAED,qBAAa,qBAAqB;IAChC,OAAO,CAAC,UAAU,CAAY;IAC9B,OAAO,CAAC,cAAc,CAAQ;IAC9B,OAAO,CAAC,WAAW,CAA6B;IAChD,WAAW,EAAE,4BAA4B,CAAA;gBAE7B,OAAO,EAAE,4BAA4B;IAQjD,KAAK,CAAC,QAAQ,EAAE,QAAQ;YAqBV,kBAAkB;CAQjC"}
@@ -1,74 +0,0 @@
1
- import 'module';
2
- /*#__PURE__*/ import.meta.url;
3
- import node_fs from "node:fs";
4
- import { CSS_NAMED_EXPORT } from "../constants.js";
5
- import { logger } from "../logger.js";
6
- import { glob } from "tinyglobby";
7
- import typed_css_modules from "typed-css-modules";
8
- import { isCSSModules } from "./utils.js";
9
- function _define_property(obj, key, value) {
10
- if (key in obj) Object.defineProperty(obj, key, {
11
- value: value,
12
- enumerable: true,
13
- configurable: true,
14
- writable: true
15
- });
16
- else obj[key] = value;
17
- return obj;
18
- }
19
- const statPromise = node_fs.promises.stat;
20
- async function writeFile(dtsCreator, cssFile) {
21
- const content = await dtsCreator.create(cssFile, void 0, true);
22
- await content.writeFile((definition)=>`// Generated automatically, do not edit\n${definition}`);
23
- }
24
- async function generateTypingIfNecessary(dtsCreator, cssFile) {
25
- let typingStat;
26
- try {
27
- typingStat = await statPromise(`${cssFile}.d.ts`);
28
- } catch {
29
- return writeFile(dtsCreator, cssFile);
30
- }
31
- const cssFileStat = await statPromise(cssFile);
32
- if (cssFileStat.mtime.getTime() > typingStat.mtime.getTime()) return writeFile(dtsCreator, cssFile);
33
- }
34
- const PLUGIN_NAME = 'TypedCssModulesPlugin';
35
- class TypedCssModulesPlugin {
36
- apply(compiler) {
37
- compiler.hooks.run.tapPromise(PLUGIN_NAME, async ()=>{
38
- await this.generateCssTypings(this.useIncremental);
39
- });
40
- compiler.hooks.watchRun.tap(PLUGIN_NAME, ()=>{
41
- setTimeout(()=>{
42
- this.generateCssTypings(this.useIncremental).catch((err)=>{
43
- logger.error(err.toString());
44
- }).finally(()=>{
45
- this.useIncremental = true;
46
- });
47
- }, 100);
48
- });
49
- }
50
- async generateCssTypings(incremental) {
51
- const files = await glob(this.globPattern);
52
- const cssModulesFiles = files.filter((file)=>{
53
- var _this_userOptions;
54
- return isCSSModules({
55
- resourcePath: file,
56
- modules: null == (_this_userOptions = this.userOptions) ? void 0 : _this_userOptions.modules
57
- });
58
- });
59
- const doTask = incremental ? generateTypingIfNecessary : writeFile;
60
- return Promise.all(cssModulesFiles.map((file)=>doTask(this.dtsCreator, file)));
61
- }
62
- constructor(options){
63
- _define_property(this, "dtsCreator", void 0);
64
- _define_property(this, "useIncremental", false);
65
- _define_property(this, "globPattern", 'src/**/*.{css,less,scss}');
66
- _define_property(this, "userOptions", void 0);
67
- this.userOptions = options;
68
- this.dtsCreator = new typed_css_modules({
69
- camelCase: true,
70
- namedExports: CSS_NAMED_EXPORT
71
- });
72
- }
73
- }
74
- export { TypedCssModulesPlugin };
@@ -1,46 +0,0 @@
1
- "use strict";
2
- var __webpack_require__ = {};
3
- (()=>{
4
- __webpack_require__.d = (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 = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
13
- })();
14
- (()=>{
15
- __webpack_require__.r = (exports1)=>{
16
- if ('undefined' != typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
17
- value: 'Module'
18
- });
19
- Object.defineProperty(exports1, '__esModule', {
20
- value: true
21
- });
22
- };
23
- })();
24
- var __webpack_exports__ = {};
25
- __webpack_require__.r(__webpack_exports__);
26
- __webpack_require__.d(__webpack_exports__, {
27
- isCSSModules: ()=>isCSSModules
28
- });
29
- const external_constants_cjs_namespaceObject = require("../constants.cjs");
30
- const external_utils_cjs_namespaceObject = require("../utils.cjs");
31
- const isCSSModules = ({ resourcePath, modules })=>{
32
- if (false === modules) return false;
33
- if (!(0, external_utils_cjs_namespaceObject.isPlainObject)(modules)) modules = {};
34
- const auto = modules.auto;
35
- if (false === auto) return false;
36
- if ((0, external_utils_cjs_namespaceObject.isRegExp)(auto)) return auto.test(resourcePath);
37
- if ((0, external_utils_cjs_namespaceObject.isFunction)(auto)) return auto(resourcePath);
38
- return external_constants_cjs_namespaceObject.CSS_MODULES_REGEX.test(resourcePath);
39
- };
40
- exports.isCSSModules = __webpack_exports__.isCSSModules;
41
- for(var __webpack_i__ in __webpack_exports__)if (-1 === [
42
- "isCSSModules"
43
- ].indexOf(__webpack_i__)) exports[__webpack_i__] = __webpack_exports__[__webpack_i__];
44
- Object.defineProperty(exports, '__esModule', {
45
- value: true
46
- });
@@ -1,6 +0,0 @@
1
- import type { UnpackConfig } from '../types/index';
2
- export declare const isCSSModules: ({ resourcePath, modules, }: {
3
- resourcePath: string;
4
- modules: NonNullable<UnpackConfig["css"]>["modules"];
5
- }) => boolean;
6
- //# sourceMappingURL=utils.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/typed-css-modules/utils.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAA;AAGnD,eAAO,MAAM,YAAY,GAAI,4BAG1B;IACD,YAAY,EAAE,MAAM,CAAA;IACpB,OAAO,EAAE,WAAW,CAAC,YAAY,CAAC,KAAK,CAAC,CAAC,CAAC,SAAS,CAAC,CAAA;CACrD,KAAG,OAQH,CAAA"}
@@ -1,14 +0,0 @@
1
- import 'module';
2
- /*#__PURE__*/ import.meta.url;
3
- import { CSS_MODULES_REGEX } from "../constants.js";
4
- import { isFunction, isPlainObject, isRegExp } from "../utils.js";
5
- const isCSSModules = ({ resourcePath, modules })=>{
6
- if (false === modules) return false;
7
- if (!isPlainObject(modules)) modules = {};
8
- const auto = modules.auto;
9
- if (false === auto) return false;
10
- if (isRegExp(auto)) return auto.test(resourcePath);
11
- if (isFunction(auto)) return auto(resourcePath);
12
- return CSS_MODULES_REGEX.test(resourcePath);
13
- };
14
- export { isCSSModules };
@@ -1,18 +0,0 @@
1
- "use strict";
2
- var __webpack_require__ = {};
3
- (()=>{
4
- __webpack_require__.r = (exports1)=>{
5
- if ('undefined' != typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
6
- value: 'Module'
7
- });
8
- Object.defineProperty(exports1, '__esModule', {
9
- value: true
10
- });
11
- };
12
- })();
13
- var __webpack_exports__ = {};
14
- __webpack_require__.r(__webpack_exports__);
15
- for(var __webpack_i__ in __webpack_exports__)exports[__webpack_i__] = __webpack_exports__[__webpack_i__];
16
- Object.defineProperty(exports, '__esModule', {
17
- value: true
18
- });
@@ -1,2 +0,0 @@
1
- import 'module';
2
- /*#__PURE__*/ import.meta.url;
@@ -1,18 +0,0 @@
1
- "use strict";
2
- var __webpack_require__ = {};
3
- (()=>{
4
- __webpack_require__.r = (exports1)=>{
5
- if ('undefined' != typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
6
- value: 'Module'
7
- });
8
- Object.defineProperty(exports1, '__esModule', {
9
- value: true
10
- });
11
- };
12
- })();
13
- var __webpack_exports__ = {};
14
- __webpack_require__.r(__webpack_exports__);
15
- for(var __webpack_i__ in __webpack_exports__)exports[__webpack_i__] = __webpack_exports__[__webpack_i__];
16
- Object.defineProperty(exports, '__esModule', {
17
- value: true
18
- });
@@ -1,2 +0,0 @@
1
- import 'module';
2
- /*#__PURE__*/ import.meta.url;