@unpackjs/core 1.5.4 → 1.6.1

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 (238) hide show
  1. package/bin/openChrome.applescript +94 -0
  2. package/compiled/chokidar/index.d.ts +327 -0
  3. package/compiled/chokidar/index.js +1773 -0
  4. package/compiled/chokidar/license +21 -0
  5. package/compiled/chokidar/package.json +1 -0
  6. package/compiled/commander/index.d.ts +971 -0
  7. package/compiled/commander/index.js +2190 -0
  8. package/compiled/commander/license +22 -0
  9. package/compiled/commander/package.json +1 -0
  10. package/compiled/css-loader/api.js +85 -0
  11. package/compiled/css-loader/getUrl.js +26 -0
  12. package/compiled/css-loader/index.d.ts +1 -0
  13. package/compiled/css-loader/index.js +8004 -0
  14. package/compiled/css-loader/license +20 -0
  15. package/compiled/css-loader/noSourceMaps.js +5 -0
  16. package/compiled/css-loader/package.json +1 -0
  17. package/compiled/css-loader/sourceMaps.js +16 -0
  18. package/compiled/fast-glob/index.d.ts +237 -0
  19. package/compiled/fast-glob/index.js +5726 -0
  20. package/compiled/fast-glob/license +21 -0
  21. package/compiled/fast-glob/package.json +1 -0
  22. package/compiled/less-loader/index.d.ts +1 -0
  23. package/compiled/less-loader/index.js +340 -0
  24. package/compiled/less-loader/license +20 -0
  25. package/compiled/less-loader/package.json +1 -0
  26. package/compiled/line-diff/index.d.ts +1 -0
  27. package/compiled/line-diff/index.js +160 -0
  28. package/compiled/line-diff/license +21 -0
  29. package/compiled/line-diff/package.json +1 -0
  30. package/compiled/log-update/index.d.ts +1 -0
  31. package/compiled/log-update/index.js +1970 -0
  32. package/compiled/log-update/package.json +1 -0
  33. package/compiled/portfinder/index.d.ts +64 -0
  34. package/compiled/portfinder/index.js +3401 -0
  35. package/compiled/portfinder/license +22 -0
  36. package/compiled/portfinder/package.json +1 -0
  37. package/compiled/postcss-loader/index.d.ts +1 -0
  38. package/compiled/postcss-loader/index.js +94945 -0
  39. package/compiled/postcss-loader/license +20 -0
  40. package/compiled/postcss-loader/package.json +1 -0
  41. package/compiled/sass-loader/index.d.ts +961 -0
  42. package/compiled/sass-loader/index.js +5610 -0
  43. package/compiled/sass-loader/index1.js +65 -0
  44. package/compiled/sass-loader/license +20 -0
  45. package/compiled/sass-loader/package.json +1 -0
  46. package/compiled/sass-loader/sass.node.js +12 -0
  47. package/compiled/semver/index.d.ts +1 -0
  48. package/compiled/semver/index.js +1940 -0
  49. package/compiled/semver/license +15 -0
  50. package/compiled/semver/package.json +1 -0
  51. package/compiled/style-loader/index.d.ts +1 -0
  52. package/compiled/style-loader/index.js +370 -0
  53. package/compiled/style-loader/license +20 -0
  54. package/compiled/style-loader/package.json +1 -0
  55. package/compiled/style-loader/runtime/injectStylesIntoLinkTag.js +29 -0
  56. package/compiled/style-loader/runtime/injectStylesIntoStyleTag.js +84 -0
  57. package/compiled/style-loader/runtime/insertBySelector.js +34 -0
  58. package/compiled/style-loader/runtime/insertStyleElement.js +10 -0
  59. package/compiled/style-loader/runtime/isEqualLocals.js +28 -0
  60. package/compiled/style-loader/runtime/isOldIE.js +17 -0
  61. package/compiled/style-loader/runtime/setAttributesWithAttributes.js +13 -0
  62. package/compiled/style-loader/runtime/setAttributesWithAttributesAndNonce.js +9 -0
  63. package/compiled/style-loader/runtime/setAttributesWithoutAttributes.js +10 -0
  64. package/compiled/style-loader/runtime/singletonStyleDomAPI.js +86 -0
  65. package/compiled/style-loader/runtime/styleDomAPI.js +61 -0
  66. package/compiled/style-loader/runtime/styleTagTransform.js +14 -0
  67. package/compiled/webpack-bundle-analyzer/index.d.ts +1 -0
  68. package/compiled/webpack-bundle-analyzer/index.js +13276 -0
  69. package/compiled/webpack-bundle-analyzer/license +20 -0
  70. package/compiled/webpack-bundle-analyzer/package.json +1 -0
  71. package/compiled/webpack-bundle-analyzer/public/viewer.js +16 -0
  72. package/compiled/webpack-bundle-analyzer/public/viewer.js.LICENSE.txt +10 -0
  73. package/compiled/webpack-merge/index.d.ts +31 -0
  74. package/compiled/webpack-merge/index.js +1200 -0
  75. package/compiled/webpack-merge/license +20 -0
  76. package/compiled/webpack-merge/package.json +1 -0
  77. package/dist/bundleRequire.cjs +200 -0
  78. package/dist/bundleRequire.d.ts +5 -0
  79. package/dist/bundleRequire.d.ts.map +1 -0
  80. package/dist/bundleRequire.js +173 -0
  81. package/dist/bundler-config/chunkSplit.cjs +151 -0
  82. package/dist/bundler-config/chunkSplit.d.ts +6 -0
  83. package/dist/bundler-config/chunkSplit.d.ts.map +1 -0
  84. package/dist/bundler-config/chunkSplit.js +127 -0
  85. package/dist/bundler-config/css.cjs +167 -0
  86. package/dist/bundler-config/css.d.ts +6 -0
  87. package/dist/bundler-config/css.d.ts.map +1 -0
  88. package/dist/bundler-config/css.js +158 -0
  89. package/dist/bundler-config/experimentCss.cjs +166 -0
  90. package/dist/bundler-config/experimentCss.d.ts +6 -0
  91. package/dist/bundler-config/experimentCss.d.ts.map +1 -0
  92. package/dist/bundler-config/experimentCss.js +157 -0
  93. package/dist/bundler-config/helper.cjs +83 -0
  94. package/dist/bundler-config/helper.d.ts +8 -0
  95. package/dist/bundler-config/helper.d.ts.map +1 -0
  96. package/dist/bundler-config/helper.js +58 -0
  97. package/dist/bundler-config/index.cjs +204 -0
  98. package/dist/bundler-config/index.d.ts +3 -0
  99. package/dist/bundler-config/index.d.ts.map +1 -0
  100. package/dist/bundler-config/index.js +180 -0
  101. package/dist/colors.cjs +60 -0
  102. package/dist/colors.d.ts +6 -0
  103. package/dist/colors.d.ts.map +1 -0
  104. package/dist/colors.js +40 -0
  105. package/dist/{config/index.cjs → config.cjs} +21 -47
  106. package/dist/{config/index.d.ts → config.d.ts} +4 -3
  107. package/dist/config.d.ts.map +1 -0
  108. package/dist/{config/index.js → config.js} +18 -52
  109. package/dist/constants.cjs +86 -0
  110. package/dist/constants.d.ts +25 -0
  111. package/dist/constants.d.ts.map +1 -0
  112. package/dist/constants.js +61 -0
  113. package/dist/createUnpack.cjs +102 -0
  114. package/dist/createUnpack.d.ts +7 -0
  115. package/dist/createUnpack.d.ts.map +1 -0
  116. package/dist/createUnpack.js +78 -0
  117. package/dist/index.cjs +26 -48
  118. package/dist/index.d.ts +7 -7
  119. package/dist/index.d.ts.map +1 -1
  120. package/dist/index.js +8 -52
  121. package/dist/lightningcss/cache.cjs +36 -0
  122. package/dist/lightningcss/cache.d.ts +2 -0
  123. package/dist/lightningcss/cache.d.ts.map +1 -0
  124. package/dist/lightningcss/cache.js +22 -0
  125. package/dist/lightningcss/index.cjs +21 -0
  126. package/dist/lightningcss/index.d.ts +2 -0
  127. package/dist/lightningcss/index.d.ts.map +1 -0
  128. package/dist/lightningcss/index.js +10 -0
  129. package/dist/lightningcss/loader.cjs +56 -0
  130. package/dist/lightningcss/loader.d.ts +5 -0
  131. package/dist/lightningcss/loader.d.ts.map +1 -0
  132. package/dist/lightningcss/loader.js +36 -0
  133. package/dist/lightningcss/minimizer.cjs +114 -0
  134. package/dist/lightningcss/minimizer.d.ts +11 -0
  135. package/dist/lightningcss/minimizer.d.ts.map +1 -0
  136. package/dist/lightningcss/minimizer.js +90 -0
  137. package/dist/logger.cjs +103 -0
  138. package/dist/logger.d.ts +3 -0
  139. package/dist/logger.d.ts.map +1 -0
  140. package/dist/logger.js +79 -0
  141. package/dist/openBrowser.cjs +85 -0
  142. package/dist/openBrowser.d.ts +2 -0
  143. package/dist/openBrowser.d.ts.map +1 -0
  144. package/dist/openBrowser.js +61 -0
  145. package/dist/plugin-progress/rspack.cjs +74 -0
  146. package/dist/plugin-progress/rspack.d.ts +9 -0
  147. package/dist/plugin-progress/rspack.d.ts.map +1 -0
  148. package/dist/plugin-progress/rspack.js +50 -0
  149. package/dist/plugin-progress/webpack.cjs +84 -0
  150. package/dist/plugin-progress/webpack.d.ts +9 -0
  151. package/dist/plugin-progress/webpack.d.ts.map +1 -0
  152. package/dist/plugin-progress/webpack.js +60 -0
  153. package/dist/plugin.cjs +33 -0
  154. package/dist/plugin.d.ts +3 -0
  155. package/dist/plugin.d.ts.map +1 -0
  156. package/dist/plugin.js +19 -0
  157. package/dist/progressBar.cjs +70 -0
  158. package/dist/progressBar.d.ts +14 -0
  159. package/dist/progressBar.d.ts.map +1 -0
  160. package/dist/progressBar.js +46 -0
  161. package/dist/reporter.cjs +133 -0
  162. package/dist/reporter.d.ts +9 -0
  163. package/dist/reporter.d.ts.map +1 -0
  164. package/dist/reporter.js +109 -0
  165. package/dist/run/build.cjs +77 -0
  166. package/dist/run/build.d.ts +3 -0
  167. package/dist/run/build.d.ts.map +1 -0
  168. package/dist/run/build.js +53 -0
  169. package/dist/run/dev.cjs +107 -0
  170. package/dist/run/dev.d.ts +3 -0
  171. package/dist/run/dev.d.ts.map +1 -0
  172. package/dist/run/dev.js +83 -0
  173. package/dist/run/index.cjs +23 -0
  174. package/dist/run/index.d.ts +3 -0
  175. package/dist/run/index.d.ts.map +1 -0
  176. package/dist/run/index.js +11 -0
  177. package/dist/thread-loader/WorkerError.cjs +41 -0
  178. package/dist/thread-loader/WorkerError.js +31 -0
  179. package/dist/thread-loader/WorkerPool.cjs +407 -0
  180. package/dist/thread-loader/WorkerPool.js +387 -0
  181. package/dist/thread-loader/index.cjs +100 -0
  182. package/dist/thread-loader/index.js +85 -0
  183. package/dist/thread-loader/readBuffer.cjs +55 -0
  184. package/dist/thread-loader/readBuffer.js +45 -0
  185. package/dist/thread-loader/serializer.cjs +46 -0
  186. package/dist/thread-loader/serializer.js +31 -0
  187. package/dist/thread-loader/utils.cjs +84 -0
  188. package/dist/thread-loader/utils.js +60 -0
  189. package/dist/thread-loader/worker.cjs +377 -0
  190. package/dist/thread-loader/worker.js +382 -0
  191. package/dist/thread-loader/workerPools.cjs +57 -0
  192. package/dist/thread-loader/workerPools.js +33 -0
  193. package/dist/typed-css-modules/index.cjs +21 -0
  194. package/dist/typed-css-modules/index.d.ts +2 -0
  195. package/dist/typed-css-modules/index.d.ts.map +1 -0
  196. package/dist/typed-css-modules/index.js +10 -0
  197. package/dist/typed-css-modules/loader.cjs +195 -0
  198. package/dist/typed-css-modules/loader.d.ts +10 -0
  199. package/dist/typed-css-modules/loader.d.ts.map +1 -0
  200. package/dist/typed-css-modules/loader.js +170 -0
  201. package/dist/typed-css-modules/plugin.cjs +96 -0
  202. package/dist/typed-css-modules/plugin.d.ts +16 -0
  203. package/dist/typed-css-modules/plugin.d.ts.map +1 -0
  204. package/dist/typed-css-modules/plugin.js +72 -0
  205. package/dist/typed-css-modules/utils.cjs +45 -0
  206. package/dist/typed-css-modules/utils.d.ts +6 -0
  207. package/dist/typed-css-modules/utils.d.ts.map +1 -0
  208. package/dist/typed-css-modules/utils.js +31 -0
  209. package/dist/types/chunkSplit.cjs +15 -0
  210. package/dist/types/chunkSplit.d.ts +35 -0
  211. package/dist/types/chunkSplit.d.ts.map +1 -0
  212. package/dist/types/chunkSplit.js +9 -0
  213. package/dist/types/config.cjs +15 -0
  214. package/dist/types/config.d.ts +176 -0
  215. package/dist/types/config.d.ts.map +1 -0
  216. package/dist/types/config.js +9 -0
  217. package/dist/types/index.cjs +29 -0
  218. package/dist/types/index.d.ts +16 -0
  219. package/dist/types/index.d.ts.map +1 -0
  220. package/dist/types/index.js +14 -0
  221. package/dist/types/lightningcss.cjs +15 -0
  222. package/dist/types/lightningcss.d.ts +11 -0
  223. package/dist/types/lightningcss.d.ts.map +1 -0
  224. package/dist/types/lightningcss.js +9 -0
  225. package/dist/types/logger.cjs +35 -0
  226. package/dist/types/logger.d.ts +16 -0
  227. package/dist/types/logger.d.ts.map +1 -0
  228. package/dist/types/logger.js +21 -0
  229. package/dist/types/plugin.cjs +15 -0
  230. package/dist/types/plugin.d.ts +18 -0
  231. package/dist/types/plugin.d.ts.map +1 -0
  232. package/dist/types/plugin.js +9 -0
  233. package/dist/utils.cjs +286 -0
  234. package/dist/utils.d.ts +43 -0
  235. package/dist/utils.d.ts.map +1 -0
  236. package/dist/utils.js +235 -0
  237. package/package.json +95 -6
  238. package/dist/config/index.d.ts.map +0 -1
@@ -0,0 +1,167 @@
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 css_exports = {};
29
+ __export(css_exports, {
30
+ addCssSupport: () => addCssSupport
31
+ });
32
+ module.exports = __toCommonJS(css_exports);
33
+ var import_node_path = __toESM(require("node:path"));
34
+ var import_core = require("@rspack/core");
35
+ var import_mini_css_extract_plugin = __toESM(require("mini-css-extract-plugin"));
36
+ var import_constants = require("../constants.cjs");
37
+ var import_utils = require("../utils.cjs");
38
+ var import_helper = require("./helper.cjs");
39
+ function addCssSupport({
40
+ config,
41
+ unpackConfig
42
+ }) {
43
+ const MiniCssExtractPlugin = unpackConfig.bundler === "rspack" ? import_core.rspack.CssExtractRspackPlugin : import_mini_css_extract_plugin.default;
44
+ let modules = unpackConfig.css?.modules;
45
+ if (!(0, import_utils.isPlainObject)(modules) && modules !== false)
46
+ modules = {};
47
+ const getAutoOption = () => {
48
+ if (modules === false)
49
+ return false;
50
+ const auto = modules.auto;
51
+ if (auto === false)
52
+ return false;
53
+ return (resourcePath) => {
54
+ if (resourcePath.includes("node_modules"))
55
+ return import_constants.CSS_MODULES_REGEX.test(resourcePath);
56
+ if ((0, import_utils.isRegExp)(auto))
57
+ return auto.test(resourcePath);
58
+ if ((0, import_utils.isFunction)(auto))
59
+ return auto(resourcePath);
60
+ return import_constants.CSS_MODULES_REGEX.test(resourcePath);
61
+ };
62
+ };
63
+ const getCommonRules = ({ importLoaders }) => [
64
+ (0, import_utils.isDevServer)() ? {
65
+ loader: (0, import_utils.getCompiledPkgPath)("style-loader")
66
+ } : {
67
+ loader: MiniCssExtractPlugin.loader,
68
+ options: {
69
+ defaultExport: true
70
+ }
71
+ },
72
+ (0, import_utils.isDev)() && {
73
+ loader: import_node_path.default.resolve(__dirname, "../typed-css-modules/loader.cjs"),
74
+ options: {
75
+ modules
76
+ }
77
+ },
78
+ {
79
+ loader: (0, import_utils.getCompiledPkgPath)("css-loader"),
80
+ options: {
81
+ importLoaders,
82
+ modules: {
83
+ auto: getAutoOption(),
84
+ localIdentName: modules !== false && (modules.localIdentName || import_constants.CSS_MODULES_LOCAL_IDENT_NAME),
85
+ exportLocalsConvention: import_constants.EXPORT_LOCALS_CONVENTION,
86
+ namedExport: import_constants.CSS_NAMED_EXPORT
87
+ },
88
+ sourceMap: unpackConfig.css?.sourceMap
89
+ }
90
+ }
91
+ ].filter(Boolean);
92
+ if (!(0, import_utils.isDevServer)()) {
93
+ config.plugins.push(
94
+ // @ts-expect-error - decide by bundler
95
+ new MiniCssExtractPlugin({
96
+ filename: (0, import_helper.getOutputFilename)({ type: "css", hash: unpackConfig.build?.filenameHash })
97
+ })
98
+ );
99
+ }
100
+ config.module?.rules?.push({
101
+ test: /\.less$/i,
102
+ use: [
103
+ ...getCommonRules({ importLoaders: 1 }),
104
+ unpackConfig.build?.parallel && {
105
+ loader: import_node_path.default.resolve(__dirname, "../thread-loader/index.cjs"),
106
+ options: import_constants.THREAD_OPTIONS
107
+ },
108
+ {
109
+ loader: (0, import_utils.getCompiledPkgPath)("less-loader"),
110
+ options: {
111
+ lessOptions: (0, import_utils.mergeConfig)(
112
+ {
113
+ javascriptEnabled: true
114
+ },
115
+ unpackConfig.css?.less || {}
116
+ ),
117
+ implementation: (0, import_utils.getUserDepPath)(unpackConfig.root, "less"),
118
+ sourceMap: unpackConfig.css?.sourceMap
119
+ }
120
+ }
121
+ ].filter(Boolean)
122
+ });
123
+ const getLightningcssLoader = () => {
124
+ return {
125
+ loader: import_node_path.default.resolve(__dirname, "../lightningcss/loader.cjs"),
126
+ options: (0, import_utils.mergeConfig)(unpackConfig.css?.lightningcss || {}, {
127
+ sourceMap: unpackConfig.css?.sourceMap
128
+ })
129
+ };
130
+ };
131
+ const getPostcssLoader = () => {
132
+ return {
133
+ loader: (0, import_utils.getCompiledPkgPath)("postcss-loader"),
134
+ options: {
135
+ postcssOptions: unpackConfig.css?.postcss,
136
+ sourceMap: unpackConfig.css?.sourceMap
137
+ }
138
+ };
139
+ };
140
+ const getCssLoader = () => {
141
+ return unpackConfig.css?.transformer === "lightningcss" ? getLightningcssLoader() : getPostcssLoader();
142
+ };
143
+ config.module?.rules?.push({
144
+ test: /\.css$/i,
145
+ use: [...getCommonRules({ importLoaders: 1 }), getCssLoader()]
146
+ });
147
+ config.module?.rules?.push({
148
+ test: /\.s[ac]ss$/i,
149
+ use: [
150
+ ...getCommonRules({ importLoaders: 1 }),
151
+ {
152
+ loader: (0, import_utils.getCompiledPkgPath)("sass-loader"),
153
+ options: {
154
+ api: "modern-compiler",
155
+ implementation: (0, import_utils.getUserDepPath)(unpackConfig.root, ["sass-embedded", "sass"]),
156
+ sassOptions: unpackConfig.css?.sass,
157
+ sourceMap: unpackConfig.css?.sourceMap
158
+ }
159
+ }
160
+ ]
161
+ });
162
+ return config;
163
+ }
164
+ // Annotate the CommonJS export names for ESM import in node:
165
+ 0 && (module.exports = {
166
+ addCssSupport
167
+ });
@@ -0,0 +1,6 @@
1
+ import type { BundlerConfiguration, UnpackConfig } from '../types/index';
2
+ export declare function addCssSupport({ config, unpackConfig, }: {
3
+ config: BundlerConfiguration;
4
+ unpackConfig: UnpackConfig;
5
+ }): BundlerConfiguration;
6
+ //# sourceMappingURL=css.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"css.d.ts","sourceRoot":"","sources":["../../src/bundler-config/css.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAAE,oBAAoB,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAA;AAazE,wBAAgB,aAAa,CAAC,EAC5B,MAAM,EACN,YAAY,GACb,EAAE;IACD,MAAM,EAAE,oBAAoB,CAAA;IAC5B,YAAY,EAAE,YAAY,CAAA;CAC3B,GAAG,oBAAoB,CAkIvB"}
@@ -0,0 +1,158 @@
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 path2 from "node:path";
11
+ import { rspack } from "@rspack/core";
12
+ import WebpackMiniCssExtractPlugin from "mini-css-extract-plugin";
13
+ import {
14
+ CSS_MODULES_LOCAL_IDENT_NAME,
15
+ CSS_MODULES_REGEX,
16
+ CSS_NAMED_EXPORT,
17
+ EXPORT_LOCALS_CONVENTION,
18
+ THREAD_OPTIONS
19
+ } from "../constants.js";
20
+ import {
21
+ getCompiledPkgPath,
22
+ getUserDepPath,
23
+ isDev,
24
+ isDevServer,
25
+ isFunction,
26
+ isPlainObject,
27
+ isRegExp,
28
+ mergeConfig
29
+ } from "../utils.js";
30
+ import { getOutputFilename } from "./helper.js";
31
+ function addCssSupport({
32
+ config,
33
+ unpackConfig
34
+ }) {
35
+ const MiniCssExtractPlugin = unpackConfig.bundler === "rspack" ? rspack.CssExtractRspackPlugin : WebpackMiniCssExtractPlugin;
36
+ let modules = unpackConfig.css?.modules;
37
+ if (!isPlainObject(modules) && modules !== false)
38
+ modules = {};
39
+ const getAutoOption = () => {
40
+ if (modules === false)
41
+ return false;
42
+ const auto = modules.auto;
43
+ if (auto === false)
44
+ return false;
45
+ return (resourcePath) => {
46
+ if (resourcePath.includes("node_modules"))
47
+ return CSS_MODULES_REGEX.test(resourcePath);
48
+ if (isRegExp(auto))
49
+ return auto.test(resourcePath);
50
+ if (isFunction(auto))
51
+ return auto(resourcePath);
52
+ return CSS_MODULES_REGEX.test(resourcePath);
53
+ };
54
+ };
55
+ const getCommonRules = ({ importLoaders }) => [
56
+ isDevServer() ? {
57
+ loader: getCompiledPkgPath("style-loader")
58
+ } : {
59
+ loader: MiniCssExtractPlugin.loader,
60
+ options: {
61
+ defaultExport: true
62
+ }
63
+ },
64
+ isDev() && {
65
+ loader: path2.resolve(__dirname, "../typed-css-modules/loader.cjs"),
66
+ options: {
67
+ modules
68
+ }
69
+ },
70
+ {
71
+ loader: getCompiledPkgPath("css-loader"),
72
+ options: {
73
+ importLoaders,
74
+ modules: {
75
+ auto: getAutoOption(),
76
+ localIdentName: modules !== false && (modules.localIdentName || CSS_MODULES_LOCAL_IDENT_NAME),
77
+ exportLocalsConvention: EXPORT_LOCALS_CONVENTION,
78
+ namedExport: CSS_NAMED_EXPORT
79
+ },
80
+ sourceMap: unpackConfig.css?.sourceMap
81
+ }
82
+ }
83
+ ].filter(Boolean);
84
+ if (!isDevServer()) {
85
+ config.plugins.push(
86
+ // @ts-expect-error - decide by bundler
87
+ new MiniCssExtractPlugin({
88
+ filename: getOutputFilename({ type: "css", hash: unpackConfig.build?.filenameHash })
89
+ })
90
+ );
91
+ }
92
+ config.module?.rules?.push({
93
+ test: /\.less$/i,
94
+ use: [
95
+ ...getCommonRules({ importLoaders: 1 }),
96
+ unpackConfig.build?.parallel && {
97
+ loader: path2.resolve(__dirname, "../thread-loader/index.cjs"),
98
+ options: THREAD_OPTIONS
99
+ },
100
+ {
101
+ loader: getCompiledPkgPath("less-loader"),
102
+ options: {
103
+ lessOptions: mergeConfig(
104
+ {
105
+ javascriptEnabled: true
106
+ },
107
+ unpackConfig.css?.less || {}
108
+ ),
109
+ implementation: getUserDepPath(unpackConfig.root, "less"),
110
+ sourceMap: unpackConfig.css?.sourceMap
111
+ }
112
+ }
113
+ ].filter(Boolean)
114
+ });
115
+ const getLightningcssLoader = () => {
116
+ return {
117
+ loader: path2.resolve(__dirname, "../lightningcss/loader.cjs"),
118
+ options: mergeConfig(unpackConfig.css?.lightningcss || {}, {
119
+ sourceMap: unpackConfig.css?.sourceMap
120
+ })
121
+ };
122
+ };
123
+ const getPostcssLoader = () => {
124
+ return {
125
+ loader: getCompiledPkgPath("postcss-loader"),
126
+ options: {
127
+ postcssOptions: unpackConfig.css?.postcss,
128
+ sourceMap: unpackConfig.css?.sourceMap
129
+ }
130
+ };
131
+ };
132
+ const getCssLoader = () => {
133
+ return unpackConfig.css?.transformer === "lightningcss" ? getLightningcssLoader() : getPostcssLoader();
134
+ };
135
+ config.module?.rules?.push({
136
+ test: /\.css$/i,
137
+ use: [...getCommonRules({ importLoaders: 1 }), getCssLoader()]
138
+ });
139
+ config.module?.rules?.push({
140
+ test: /\.s[ac]ss$/i,
141
+ use: [
142
+ ...getCommonRules({ importLoaders: 1 }),
143
+ {
144
+ loader: getCompiledPkgPath("sass-loader"),
145
+ options: {
146
+ api: "modern-compiler",
147
+ implementation: getUserDepPath(unpackConfig.root, ["sass-embedded", "sass"]),
148
+ sassOptions: unpackConfig.css?.sass,
149
+ sourceMap: unpackConfig.css?.sourceMap
150
+ }
151
+ }
152
+ ]
153
+ });
154
+ return config;
155
+ }
156
+ export {
157
+ addCssSupport
158
+ };
@@ -0,0 +1,166 @@
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 experimentCss_exports = {};
29
+ __export(experimentCss_exports, {
30
+ addExperimentCssSupport: () => addExperimentCssSupport
31
+ });
32
+ module.exports = __toCommonJS(experimentCss_exports);
33
+ var import_node_path = __toESM(require("node:path"));
34
+ var import_constants = require("../constants.cjs");
35
+ var import_typed_css_modules = require("../typed-css-modules/index.cjs");
36
+ var import_utils = require("../utils.cjs");
37
+ var import_helper = require("./helper.cjs");
38
+ function addExperimentCssSupport({
39
+ config,
40
+ unpackConfig
41
+ }) {
42
+ const CSS_FILENAME = (0, import_helper.getOutputFilename)({ type: "css", hash: unpackConfig.build?.filenameHash });
43
+ config.output.cssFilename = CSS_FILENAME;
44
+ config.output.cssChunkFilename = CSS_FILENAME;
45
+ (0, import_utils.setValueByPath)(config, ["experiments", "css"], true);
46
+ let modules = unpackConfig.css?.modules;
47
+ if (!(0, import_utils.isPlainObject)(modules) && modules !== false)
48
+ modules = {};
49
+ if (modules !== false && modules.auto !== false) {
50
+ (0, import_utils.setValueByPath)(config, ["module", "parser", "css/module"], {
51
+ namedExports: import_constants.CSS_NAMED_EXPORT
52
+ });
53
+ (0, import_utils.setValueByPath)(config, ["module", "generator", "css/module"], {
54
+ localIdentName: modules.localIdentName || import_constants.CSS_MODULES_LOCAL_IDENT_NAME,
55
+ exportsConvention: import_constants.EXPORT_LOCALS_CONVENTION
56
+ });
57
+ }
58
+ const withCssModules = ({ use }) => {
59
+ if (modules === false)
60
+ return false;
61
+ const auto = modules.auto;
62
+ if (auto === false)
63
+ return false;
64
+ return {
65
+ test: (resourcePath) => {
66
+ if (resourcePath.includes("node_modules"))
67
+ return import_constants.CSS_MODULES_REGEX.test(resourcePath);
68
+ if ((0, import_utils.isRegExp)(auto))
69
+ return auto.test(resourcePath);
70
+ if ((0, import_utils.isFunction)(auto))
71
+ return auto(resourcePath);
72
+ return import_constants.CSS_MODULES_REGEX.test(resourcePath);
73
+ },
74
+ use,
75
+ type: "css/module"
76
+ };
77
+ };
78
+ const getThreadLoader = () => {
79
+ return unpackConfig.build?.parallel && {
80
+ loader: import_node_path.default.resolve(__dirname, "../thread-loader/index.cjs"),
81
+ options: import_constants.THREAD_OPTIONS
82
+ };
83
+ };
84
+ const getLessLoader = () => {
85
+ return {
86
+ loader: (0, import_utils.getCompiledPkgPath)("less-loader"),
87
+ options: {
88
+ lessOptions: (0, import_utils.mergeConfig)(
89
+ {
90
+ javascriptEnabled: true
91
+ },
92
+ unpackConfig.css?.less || {}
93
+ ),
94
+ implementation: (0, import_utils.getUserDepPath)(unpackConfig.root, "less"),
95
+ sourceMap: unpackConfig.css?.sourceMap
96
+ }
97
+ };
98
+ };
99
+ config.module?.rules?.push({
100
+ test: /\.less$/i,
101
+ oneOf: [
102
+ withCssModules({ use: [getThreadLoader(), getLessLoader()].filter(Boolean) }),
103
+ {
104
+ use: [getThreadLoader(), getLessLoader()].filter(Boolean),
105
+ type: "css"
106
+ }
107
+ ].filter(Boolean)
108
+ });
109
+ const getLightningcssLoader = () => {
110
+ return {
111
+ loader: import_node_path.default.resolve(__dirname, "../lightningcss/loader.cjs"),
112
+ options: (0, import_utils.mergeConfig)(unpackConfig.css?.lightningcss || {}, {
113
+ sourceMap: unpackConfig.css?.sourceMap
114
+ })
115
+ };
116
+ };
117
+ const getPostcssLoader = () => {
118
+ return {
119
+ loader: (0, import_utils.getCompiledPkgPath)("postcss-loader"),
120
+ options: {
121
+ postcssOptions: unpackConfig.css?.postcss,
122
+ sourceMap: unpackConfig.css?.sourceMap
123
+ }
124
+ };
125
+ };
126
+ const getCssLoader = () => {
127
+ return unpackConfig.css?.transformer === "lightningcss" ? getLightningcssLoader() : getPostcssLoader();
128
+ };
129
+ config.module?.rules?.push({
130
+ test: /\.css$/i,
131
+ oneOf: [
132
+ withCssModules({ use: [getCssLoader()] }),
133
+ {
134
+ use: [getCssLoader()],
135
+ type: "css"
136
+ }
137
+ ].filter(Boolean)
138
+ });
139
+ const getSassLoader = () => {
140
+ return {
141
+ loader: (0, import_utils.getCompiledPkgPath)("sass-loader"),
142
+ options: {
143
+ api: "modern-compiler",
144
+ implementation: (0, import_utils.getUserDepPath)(unpackConfig.root, ["sass-embedded", "sass"]),
145
+ sassOptions: unpackConfig.css?.sass,
146
+ sourceMap: unpackConfig.css?.sourceMap
147
+ }
148
+ };
149
+ };
150
+ config.module?.rules?.push({
151
+ test: /\.s[ac]ss$/i,
152
+ oneOf: [
153
+ withCssModules({ use: [getSassLoader()] }),
154
+ {
155
+ use: [getSassLoader()],
156
+ type: "css"
157
+ }
158
+ ].filter(Boolean)
159
+ });
160
+ (0, import_utils.isDev)() && config.plugins.push(new import_typed_css_modules.PluginTypedCssModules({ modules }));
161
+ return config;
162
+ }
163
+ // Annotate the CommonJS export names for ESM import in node:
164
+ 0 && (module.exports = {
165
+ addExperimentCssSupport
166
+ });
@@ -0,0 +1,6 @@
1
+ import type { BundlerConfiguration, UnpackConfig } from '../types/index';
2
+ export declare function addExperimentCssSupport({ config, unpackConfig, }: {
3
+ config: BundlerConfiguration;
4
+ unpackConfig: UnpackConfig;
5
+ }): BundlerConfiguration;
6
+ //# sourceMappingURL=experimentCss.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"experimentCss.d.ts","sourceRoot":"","sources":["../../src/bundler-config/experimentCss.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAE,oBAAoB,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAA;AAazE,wBAAgB,uBAAuB,CAAC,EACtC,MAAM,EACN,YAAY,GACb,EAAE;IACD,MAAM,EAAE,oBAAoB,CAAA;IAC5B,YAAY,EAAE,YAAY,CAAA;CAC3B,GAAG,oBAAoB,CA6HvB"}
@@ -0,0 +1,157 @@
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 path2 from "node:path";
11
+ import {
12
+ CSS_MODULES_LOCAL_IDENT_NAME,
13
+ CSS_MODULES_REGEX,
14
+ CSS_NAMED_EXPORT,
15
+ EXPORT_LOCALS_CONVENTION,
16
+ THREAD_OPTIONS
17
+ } from "../constants.js";
18
+ import { PluginTypedCssModules } from "../typed-css-modules/index.js";
19
+ import {
20
+ getCompiledPkgPath,
21
+ getUserDepPath,
22
+ isDev,
23
+ isFunction,
24
+ isPlainObject,
25
+ isRegExp,
26
+ mergeConfig,
27
+ setValueByPath
28
+ } from "../utils.js";
29
+ import { getOutputFilename } from "./helper.js";
30
+ function addExperimentCssSupport({
31
+ config,
32
+ unpackConfig
33
+ }) {
34
+ const CSS_FILENAME = getOutputFilename({ type: "css", hash: unpackConfig.build?.filenameHash });
35
+ config.output.cssFilename = CSS_FILENAME;
36
+ config.output.cssChunkFilename = CSS_FILENAME;
37
+ setValueByPath(config, ["experiments", "css"], true);
38
+ let modules = unpackConfig.css?.modules;
39
+ if (!isPlainObject(modules) && modules !== false)
40
+ modules = {};
41
+ if (modules !== false && modules.auto !== false) {
42
+ setValueByPath(config, ["module", "parser", "css/module"], {
43
+ namedExports: CSS_NAMED_EXPORT
44
+ });
45
+ setValueByPath(config, ["module", "generator", "css/module"], {
46
+ localIdentName: modules.localIdentName || CSS_MODULES_LOCAL_IDENT_NAME,
47
+ exportsConvention: EXPORT_LOCALS_CONVENTION
48
+ });
49
+ }
50
+ const withCssModules = ({ use }) => {
51
+ if (modules === false)
52
+ return false;
53
+ const auto = modules.auto;
54
+ if (auto === false)
55
+ return false;
56
+ return {
57
+ test: (resourcePath) => {
58
+ if (resourcePath.includes("node_modules"))
59
+ return CSS_MODULES_REGEX.test(resourcePath);
60
+ if (isRegExp(auto))
61
+ return auto.test(resourcePath);
62
+ if (isFunction(auto))
63
+ return auto(resourcePath);
64
+ return CSS_MODULES_REGEX.test(resourcePath);
65
+ },
66
+ use,
67
+ type: "css/module"
68
+ };
69
+ };
70
+ const getThreadLoader = () => {
71
+ return unpackConfig.build?.parallel && {
72
+ loader: path2.resolve(__dirname, "../thread-loader/index.cjs"),
73
+ options: THREAD_OPTIONS
74
+ };
75
+ };
76
+ const getLessLoader = () => {
77
+ return {
78
+ loader: getCompiledPkgPath("less-loader"),
79
+ options: {
80
+ lessOptions: mergeConfig(
81
+ {
82
+ javascriptEnabled: true
83
+ },
84
+ unpackConfig.css?.less || {}
85
+ ),
86
+ implementation: getUserDepPath(unpackConfig.root, "less"),
87
+ sourceMap: unpackConfig.css?.sourceMap
88
+ }
89
+ };
90
+ };
91
+ config.module?.rules?.push({
92
+ test: /\.less$/i,
93
+ oneOf: [
94
+ withCssModules({ use: [getThreadLoader(), getLessLoader()].filter(Boolean) }),
95
+ {
96
+ use: [getThreadLoader(), getLessLoader()].filter(Boolean),
97
+ type: "css"
98
+ }
99
+ ].filter(Boolean)
100
+ });
101
+ const getLightningcssLoader = () => {
102
+ return {
103
+ loader: path2.resolve(__dirname, "../lightningcss/loader.cjs"),
104
+ options: mergeConfig(unpackConfig.css?.lightningcss || {}, {
105
+ sourceMap: unpackConfig.css?.sourceMap
106
+ })
107
+ };
108
+ };
109
+ const getPostcssLoader = () => {
110
+ return {
111
+ loader: getCompiledPkgPath("postcss-loader"),
112
+ options: {
113
+ postcssOptions: unpackConfig.css?.postcss,
114
+ sourceMap: unpackConfig.css?.sourceMap
115
+ }
116
+ };
117
+ };
118
+ const getCssLoader = () => {
119
+ return unpackConfig.css?.transformer === "lightningcss" ? getLightningcssLoader() : getPostcssLoader();
120
+ };
121
+ config.module?.rules?.push({
122
+ test: /\.css$/i,
123
+ oneOf: [
124
+ withCssModules({ use: [getCssLoader()] }),
125
+ {
126
+ use: [getCssLoader()],
127
+ type: "css"
128
+ }
129
+ ].filter(Boolean)
130
+ });
131
+ const getSassLoader = () => {
132
+ return {
133
+ loader: getCompiledPkgPath("sass-loader"),
134
+ options: {
135
+ api: "modern-compiler",
136
+ implementation: getUserDepPath(unpackConfig.root, ["sass-embedded", "sass"]),
137
+ sassOptions: unpackConfig.css?.sass,
138
+ sourceMap: unpackConfig.css?.sourceMap
139
+ }
140
+ };
141
+ };
142
+ config.module?.rules?.push({
143
+ test: /\.s[ac]ss$/i,
144
+ oneOf: [
145
+ withCssModules({ use: [getSassLoader()] }),
146
+ {
147
+ use: [getSassLoader()],
148
+ type: "css"
149
+ }
150
+ ].filter(Boolean)
151
+ });
152
+ isDev() && config.plugins.push(new PluginTypedCssModules({ modules }));
153
+ return config;
154
+ }
155
+ export {
156
+ addExperimentCssSupport
157
+ };