@unpackjs/core 1.5.3 → 1.6.0

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 +168 -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 +167 -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 +81 -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 +56 -0
  97. package/dist/bundler-config/index.cjs +206 -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 +190 -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} +28 -21
  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} +22 -23
  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/createService.cjs +65 -0
  114. package/dist/createService.d.ts +8 -0
  115. package/dist/createService.d.ts.map +1 -0
  116. package/dist/createService.js +41 -0
  117. package/dist/index.cjs +27 -48
  118. package/dist/index.d.ts +7 -7
  119. package/dist/index.d.ts.map +1 -1
  120. package/dist/index.js +8 -51
  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 +8 -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 +293 -0
  234. package/dist/utils.d.ts +39 -0
  235. package/dist/utils.d.ts.map +1 -0
  236. package/dist/utils.js +242 -0
  237. package/package.json +95 -6
  238. package/dist/config/index.d.ts.map +0 -1
@@ -0,0 +1,168 @@
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
+ const { merge } = require("../../compiled/webpack-merge/index.js");
40
+ function addCssSupport({
41
+ config,
42
+ unpackConfig
43
+ }) {
44
+ const MiniCssExtractPlugin = unpackConfig.bundler === "webpack" ? import_mini_css_extract_plugin.default : import_core.rspack.CssExtractRspackPlugin;
45
+ let modules = unpackConfig.css?.modules;
46
+ if (!(0, import_utils.isPlainObject)(modules) && modules !== false)
47
+ modules = {};
48
+ const getAutoOption = () => {
49
+ if (modules === false)
50
+ return false;
51
+ const auto = modules.auto;
52
+ if (auto === false)
53
+ return false;
54
+ return (resourcePath) => {
55
+ if (resourcePath.includes("node_modules"))
56
+ return import_constants.CSS_MODULES_REGEX.test(resourcePath);
57
+ if ((0, import_utils.isRegExp)(auto))
58
+ return auto.test(resourcePath);
59
+ if ((0, import_utils.isFunction)(auto))
60
+ return auto(resourcePath);
61
+ return import_constants.CSS_MODULES_REGEX.test(resourcePath);
62
+ };
63
+ };
64
+ const getCommonRules = ({ importLoaders }) => [
65
+ (0, import_utils.isDevServer)() ? {
66
+ loader: (0, import_utils.getCompiledPkgPath)("style-loader")
67
+ } : {
68
+ loader: MiniCssExtractPlugin.loader,
69
+ options: {
70
+ defaultExport: true
71
+ }
72
+ },
73
+ (0, import_utils.isDev)() && {
74
+ loader: import_node_path.default.resolve(__dirname, "../typed-css-modules/loader.cjs"),
75
+ options: {
76
+ modules
77
+ }
78
+ },
79
+ {
80
+ loader: (0, import_utils.getCompiledPkgPath)("css-loader"),
81
+ options: {
82
+ importLoaders,
83
+ modules: {
84
+ auto: getAutoOption(),
85
+ localIdentName: modules !== false && (modules.localIdentName || import_constants.CSS_MODULES_LOCAL_IDENT_NAME),
86
+ exportLocalsConvention: import_constants.EXPORT_LOCALS_CONVENTION,
87
+ namedExport: import_constants.CSS_NAMED_EXPORT
88
+ },
89
+ sourceMap: unpackConfig.css?.sourceMap
90
+ }
91
+ }
92
+ ].filter(Boolean);
93
+ if (!(0, import_utils.isDevServer)()) {
94
+ config.plugins.push(
95
+ // @ts-expect-error - decide by bundler
96
+ new MiniCssExtractPlugin({
97
+ filename: (0, import_helper.getOutputFilename)({ type: "css", hash: unpackConfig.build?.filenameHash })
98
+ })
99
+ );
100
+ }
101
+ config.module?.rules?.push({
102
+ test: /\.less$/i,
103
+ use: [
104
+ ...getCommonRules({ importLoaders: 1 }),
105
+ unpackConfig.build?.parallel && {
106
+ loader: import_node_path.default.resolve(__dirname, "../thread-loader/index.cjs"),
107
+ options: import_constants.THREAD_OPTIONS
108
+ },
109
+ {
110
+ loader: (0, import_utils.getCompiledPkgPath)("less-loader"),
111
+ options: {
112
+ lessOptions: merge(
113
+ {
114
+ javascriptEnabled: true
115
+ },
116
+ unpackConfig.css?.less || {}
117
+ ),
118
+ implementation: (0, import_utils.getUserDepPath)(unpackConfig.root, "less"),
119
+ sourceMap: unpackConfig.css?.sourceMap
120
+ }
121
+ }
122
+ ].filter(Boolean)
123
+ });
124
+ const getLightningcssLoader = () => {
125
+ return {
126
+ loader: import_node_path.default.resolve(__dirname, "../lightningcss/loader.cjs"),
127
+ options: merge(unpackConfig.css?.lightningcss || {}, {
128
+ sourceMap: unpackConfig.css?.sourceMap
129
+ })
130
+ };
131
+ };
132
+ const getPostcssLoader = () => {
133
+ return {
134
+ loader: (0, import_utils.getCompiledPkgPath)("postcss-loader"),
135
+ options: {
136
+ postcssOptions: unpackConfig.css?.postcss,
137
+ sourceMap: unpackConfig.css?.sourceMap
138
+ }
139
+ };
140
+ };
141
+ const getCssLoader = () => {
142
+ return unpackConfig.css?.transformer === "lightningcss" ? getLightningcssLoader() : getPostcssLoader();
143
+ };
144
+ config.module?.rules?.push({
145
+ test: /\.css$/i,
146
+ use: [...getCommonRules({ importLoaders: 1 }), getCssLoader()]
147
+ });
148
+ config.module?.rules?.push({
149
+ test: /\.s[ac]ss$/i,
150
+ use: [
151
+ ...getCommonRules({ importLoaders: 1 }),
152
+ {
153
+ loader: (0, import_utils.getCompiledPkgPath)("sass-loader"),
154
+ options: {
155
+ api: "modern-compiler",
156
+ implementation: (0, import_utils.getUserDepPath)(unpackConfig.root, ["sass-embedded", "sass"]),
157
+ sassOptions: unpackConfig.css?.sass,
158
+ sourceMap: unpackConfig.css?.sourceMap
159
+ }
160
+ }
161
+ ]
162
+ });
163
+ return config;
164
+ }
165
+ // Annotate the CommonJS export names for ESM import in node:
166
+ 0 && (module.exports = {
167
+ addCssSupport
168
+ });
@@ -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
+ } from "../utils.js";
29
+ import { getOutputFilename } from "./helper.js";
30
+ const { merge } = require("../../compiled/webpack-merge/index.js");
31
+ function addCssSupport({
32
+ config,
33
+ unpackConfig
34
+ }) {
35
+ const MiniCssExtractPlugin = unpackConfig.bundler === "webpack" ? WebpackMiniCssExtractPlugin : rspack.CssExtractRspackPlugin;
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: merge(
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: merge(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,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 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
+ const { merge } = require("../../compiled/webpack-merge/index.js");
39
+ function addExperimentCssSupport({
40
+ config,
41
+ unpackConfig
42
+ }) {
43
+ const CSS_FILENAME = (0, import_helper.getOutputFilename)({ type: "css", hash: unpackConfig.build?.filenameHash });
44
+ config.output.cssFilename = CSS_FILENAME;
45
+ config.output.cssChunkFilename = CSS_FILENAME;
46
+ (0, import_utils.setValueByPath)(config, ["experiments", "css"], true);
47
+ let modules = unpackConfig.css?.modules;
48
+ if (!(0, import_utils.isPlainObject)(modules) && modules !== false)
49
+ modules = {};
50
+ if (modules !== false && modules.auto !== false) {
51
+ (0, import_utils.setValueByPath)(config, ["module", "parser", "css/module"], {
52
+ namedExports: import_constants.CSS_NAMED_EXPORT
53
+ });
54
+ (0, import_utils.setValueByPath)(config, ["module", "generator", "css/module"], {
55
+ localIdentName: modules.localIdentName || import_constants.CSS_MODULES_LOCAL_IDENT_NAME,
56
+ exportsConvention: import_constants.EXPORT_LOCALS_CONVENTION
57
+ });
58
+ }
59
+ const withCssModules = ({ use }) => {
60
+ if (modules === false)
61
+ return false;
62
+ const auto = modules.auto;
63
+ if (auto === false)
64
+ return false;
65
+ return {
66
+ test: (resourcePath) => {
67
+ if (resourcePath.includes("node_modules"))
68
+ return import_constants.CSS_MODULES_REGEX.test(resourcePath);
69
+ if ((0, import_utils.isRegExp)(auto))
70
+ return auto.test(resourcePath);
71
+ if ((0, import_utils.isFunction)(auto))
72
+ return auto(resourcePath);
73
+ return import_constants.CSS_MODULES_REGEX.test(resourcePath);
74
+ },
75
+ use,
76
+ type: "css/module"
77
+ };
78
+ };
79
+ const getThreadLoader = () => {
80
+ return unpackConfig.build?.parallel && {
81
+ loader: import_node_path.default.resolve(__dirname, "../thread-loader/index.cjs"),
82
+ options: import_constants.THREAD_OPTIONS
83
+ };
84
+ };
85
+ const getLessLoader = () => {
86
+ return {
87
+ loader: (0, import_utils.getCompiledPkgPath)("less-loader"),
88
+ options: {
89
+ lessOptions: merge(
90
+ {
91
+ javascriptEnabled: true
92
+ },
93
+ unpackConfig.css?.less || {}
94
+ ),
95
+ implementation: (0, import_utils.getUserDepPath)(unpackConfig.root, "less"),
96
+ sourceMap: unpackConfig.css?.sourceMap
97
+ }
98
+ };
99
+ };
100
+ config.module?.rules?.push({
101
+ test: /\.less$/i,
102
+ oneOf: [
103
+ withCssModules({ use: [getThreadLoader(), getLessLoader()].filter(Boolean) }),
104
+ {
105
+ use: [getThreadLoader(), getLessLoader()].filter(Boolean),
106
+ type: "css"
107
+ }
108
+ ].filter(Boolean)
109
+ });
110
+ const getLightningcssLoader = () => {
111
+ return {
112
+ loader: import_node_path.default.resolve(__dirname, "../lightningcss/loader.cjs"),
113
+ options: merge(unpackConfig.css?.lightningcss || {}, {
114
+ sourceMap: unpackConfig.css?.sourceMap
115
+ })
116
+ };
117
+ };
118
+ const getPostcssLoader = () => {
119
+ return {
120
+ loader: (0, import_utils.getCompiledPkgPath)("postcss-loader"),
121
+ options: {
122
+ postcssOptions: unpackConfig.css?.postcss,
123
+ sourceMap: unpackConfig.css?.sourceMap
124
+ }
125
+ };
126
+ };
127
+ const getCssLoader = () => {
128
+ return unpackConfig.css?.transformer === "lightningcss" ? getLightningcssLoader() : getPostcssLoader();
129
+ };
130
+ config.module?.rules?.push({
131
+ test: /\.css$/i,
132
+ oneOf: [
133
+ withCssModules({ use: [getCssLoader()] }),
134
+ {
135
+ use: [getCssLoader()],
136
+ type: "css"
137
+ }
138
+ ].filter(Boolean)
139
+ });
140
+ const getSassLoader = () => {
141
+ return {
142
+ loader: (0, import_utils.getCompiledPkgPath)("sass-loader"),
143
+ options: {
144
+ api: "modern-compiler",
145
+ implementation: (0, import_utils.getUserDepPath)(unpackConfig.root, ["sass-embedded", "sass"]),
146
+ sassOptions: unpackConfig.css?.sass,
147
+ sourceMap: unpackConfig.css?.sourceMap
148
+ }
149
+ };
150
+ };
151
+ config.module?.rules?.push({
152
+ test: /\.s[ac]ss$/i,
153
+ oneOf: [
154
+ withCssModules({ use: [getSassLoader()] }),
155
+ {
156
+ use: [getSassLoader()],
157
+ type: "css"
158
+ }
159
+ ].filter(Boolean)
160
+ });
161
+ (0, import_utils.isDev)() && config.plugins.push(new import_typed_css_modules.PluginTypedCssModules({ modules }));
162
+ return config;
163
+ }
164
+ // Annotate the CommonJS export names for ESM import in node:
165
+ 0 && (module.exports = {
166
+ addExperimentCssSupport
167
+ });
@@ -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
+ setValueByPath
27
+ } from "../utils.js";
28
+ import { getOutputFilename } from "./helper.js";
29
+ const { merge } = require("../../compiled/webpack-merge/index.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: merge(
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: merge(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
+ };