@unpackjs/core 1.7.5 → 1.7.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (116) hide show
  1. package/compiled/css-loader/index.js +180 -178
  2. package/compiled/less-loader/index.js +11 -11
  3. package/compiled/line-diff/index.js +4 -4
  4. package/compiled/line-diff/license +1 -1
  5. package/compiled/line-diff/package.json +1 -1
  6. package/compiled/portfinder/index.js +37 -37
  7. package/compiled/postcss-loader/index.js +261 -256
  8. package/compiled/sass-loader/index.js +24 -20
  9. package/compiled/sass-loader/package.json +1 -1
  10. package/compiled/semver/index.js +188 -170
  11. package/compiled/semver/package.json +1 -1
  12. package/compiled/style-loader/index.js +13 -13
  13. package/compiled/webpack-bundle-analyzer/index.js +198 -198
  14. package/compiled/webpack-merge/index.js +29 -29
  15. package/dist/bundler-config/chunkSplit.cjs +169 -156
  16. package/dist/bundler-config/chunkSplit.js +125 -134
  17. package/dist/bundler-config/css.cjs +181 -158
  18. package/dist/bundler-config/css.js +139 -151
  19. package/dist/bundler-config/experimentCss.cjs +203 -159
  20. package/dist/bundler-config/experimentCss.js +162 -152
  21. package/dist/bundler-config/helper.cjs +82 -78
  22. package/dist/bundler-config/helper.js +36 -55
  23. package/dist/bundler-config/index.cjs +260 -209
  24. package/dist/bundler-config/index.d.ts.map +1 -1
  25. package/dist/bundler-config/index.js +209 -182
  26. package/dist/bundler-config/jsMinify.cjs +114 -95
  27. package/dist/bundler-config/jsMinify.js +70 -73
  28. package/dist/colors.cjs +83 -56
  29. package/dist/colors.js +38 -37
  30. package/dist/config.cjs +107 -93
  31. package/dist/config.d.ts.map +1 -1
  32. package/dist/config.js +64 -70
  33. package/dist/constants.cjs +65 -62
  34. package/dist/constants.d.ts +1 -0
  35. package/dist/constants.d.ts.map +1 -1
  36. package/dist/constants.js +22 -38
  37. package/dist/createUnpack.cjs +111 -104
  38. package/dist/createUnpack.js +67 -82
  39. package/dist/global.cjs +36 -0
  40. package/dist/global.d.ts +2 -0
  41. package/dist/global.d.ts.map +1 -0
  42. package/dist/global.js +4 -0
  43. package/dist/index.cjs +174 -51
  44. package/dist/index.d.ts +2 -0
  45. package/dist/index.d.ts.map +1 -1
  46. package/dist/index.js +33 -15
  47. package/dist/lightningcss/loader.cjs +56 -53
  48. package/dist/lightningcss/loader.d.ts.map +1 -1
  49. package/dist/lightningcss/loader.js +25 -34
  50. package/dist/lightningcss/minimizer.cjs +90 -109
  51. package/dist/lightningcss/minimizer.d.ts.map +1 -1
  52. package/dist/lightningcss/minimizer.js +59 -87
  53. package/dist/logger.cjs +104 -98
  54. package/dist/logger.js +59 -76
  55. package/dist/openBrowser.cjs +104 -81
  56. package/dist/openBrowser.js +56 -52
  57. package/dist/plugin-progress/rspack.cjs +104 -79
  58. package/dist/plugin-progress/rspack.js +59 -57
  59. package/dist/plugin-progress/webpack.cjs +111 -89
  60. package/dist/plugin-progress/webpack.js +65 -67
  61. package/dist/plugin.cjs +38 -29
  62. package/dist/plugin.js +8 -17
  63. package/dist/prebundleDeps.cjs +327 -337
  64. package/dist/prebundleDeps.d.ts.map +1 -1
  65. package/dist/prebundleDeps.js +278 -324
  66. package/dist/progressBar.cjs +82 -65
  67. package/dist/progressBar.js +38 -43
  68. package/dist/reporter.cjs +149 -124
  69. package/dist/reporter.d.ts.map +1 -1
  70. package/dist/reporter.js +102 -102
  71. package/dist/run/build.cjs +68 -67
  72. package/dist/run/build.js +24 -45
  73. package/dist/run/dev.cjs +96 -83
  74. package/dist/run/dev.d.ts.map +1 -1
  75. package/dist/run/dev.js +50 -61
  76. package/dist/run/index.cjs +74 -21
  77. package/dist/run/index.js +2 -9
  78. package/dist/typed-css-modules/loader.cjs +179 -188
  79. package/dist/typed-css-modules/loader.js +118 -151
  80. package/dist/typed-css-modules/plugin.cjs +113 -88
  81. package/dist/typed-css-modules/plugin.js +68 -66
  82. package/dist/typed-css-modules/utils.cjs +43 -42
  83. package/dist/typed-css-modules/utils.js +13 -30
  84. package/dist/types/chunkSplit.cjs +19 -15
  85. package/dist/types/chunkSplit.d.ts +2 -10
  86. package/dist/types/chunkSplit.d.ts.map +1 -1
  87. package/dist/types/chunkSplit.js +2 -9
  88. package/dist/types/config.cjs +19 -15
  89. package/dist/types/config.js +2 -9
  90. package/dist/types/index.cjs +101 -27
  91. package/dist/types/index.js +2 -9
  92. package/dist/types/lightningcss.cjs +19 -15
  93. package/dist/types/lightningcss.js +2 -9
  94. package/dist/types/logger.cjs +43 -34
  95. package/dist/types/logger.js +13 -22
  96. package/dist/types/plugin.cjs +19 -15
  97. package/dist/types/plugin.js +2 -9
  98. package/dist/utils.cjs +280 -304
  99. package/dist/utils.js +195 -241
  100. package/dist/watchFiles.cjs +73 -0
  101. package/dist/watchFiles.d.ts +3 -0
  102. package/dist/watchFiles.d.ts.map +1 -0
  103. package/dist/watchFiles.js +27 -0
  104. package/package.json +18 -21
  105. package/compiled/commander/index.d.ts +0 -1047
  106. package/compiled/commander/index.js +0 -2428
  107. package/compiled/commander/license +0 -22
  108. package/compiled/commander/package.json +0 -1
  109. package/dist/bundleRequire.cjs +0 -200
  110. package/dist/bundleRequire.d.ts +0 -5
  111. package/dist/bundleRequire.d.ts.map +0 -1
  112. package/dist/bundleRequire.js +0 -173
  113. package/dist/lightningcss/cache.cjs +0 -36
  114. package/dist/lightningcss/cache.d.ts +0 -2
  115. package/dist/lightningcss/cache.d.ts.map +0 -1
  116. package/dist/lightningcss/cache.js +0 -22
package/dist/run/dev.js CHANGED
@@ -1,66 +1,55 @@
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 { rspack } from "@rspack/core";
11
- import colors from "../colors.js";
12
- import { logger } from "../logger.js";
13
- import { openBrowser } from "../openBrowser.js";
14
- import { prebundleDeps } from "../prebundleDeps.js";
15
- import { getAddressUrls, getPort, isString } from "../utils.js";
16
- import webpack from "webpack";
17
- import WebpackDevServer from "webpack-dev-server";
18
- import { getBundlerConfig } from "../bundler-config/index.js";
1
+ import __rslib_shim_module__ from 'module';
2
+ /*#__PURE__*/ import.meta.url;
3
+ import * as __WEBPACK_EXTERNAL_MODULE__rspack_core_e0096ff7__ from "@rspack/core";
4
+ import * as __WEBPACK_EXTERNAL_MODULE__colors_js_1d4535d6__ from "../colors.js";
5
+ import * as __WEBPACK_EXTERNAL_MODULE__global_js_83d0ec5c__ from "../global.js";
6
+ import * as __WEBPACK_EXTERNAL_MODULE__logger_js_ff791b17__ from "../logger.js";
7
+ import * as __WEBPACK_EXTERNAL_MODULE__openBrowser_js_007107e2__ from "../openBrowser.js";
8
+ import * as __WEBPACK_EXTERNAL_MODULE__prebundleDeps_js_142f70dc__ from "../prebundleDeps.js";
9
+ import * as __WEBPACK_EXTERNAL_MODULE__utils_js_db66b9f7__ from "../utils.js";
10
+ import * as __WEBPACK_EXTERNAL_MODULE_webpack__ from "webpack";
11
+ import * as __WEBPACK_EXTERNAL_MODULE_webpack_dev_server_0dd3124e__ from "webpack-dev-server";
12
+ import * as __WEBPACK_EXTERNAL_MODULE__bundler_config_index_js_e76188c2__ from "../bundler-config/index.js";
19
13
  async function bundlerDev(originalUnpackConfig) {
20
- let unpackConfig = originalUnpackConfig;
21
- const bundler = unpackConfig.bundler === "rspack" ? rspack : webpack;
22
- if (unpackConfig.dev?.prebundle) {
23
- unpackConfig = await prebundleDeps({ unpackConfig });
24
- }
25
- const config = await getBundlerConfig(unpackConfig);
26
- const compiler = bundler(config);
27
- const port = await getPort(unpackConfig.server?.port);
28
- const devServerOptions = {
29
- hot: true,
30
- port,
31
- open: false,
32
- client: {
33
- overlay: false
34
- },
35
- proxy: unpackConfig.server?.proxy,
36
- devMiddleware: {
37
- writeToDisk: unpackConfig.dev?.writeToDisk
14
+ var _unpackConfig_dev, _unpackConfig_server, _unpackConfig_server1, _unpackConfig_dev1;
15
+ let unpackConfig = originalUnpackConfig;
16
+ const bundler = 'rspack' === unpackConfig.bundler ? __WEBPACK_EXTERNAL_MODULE__rspack_core_e0096ff7__.rspack : __WEBPACK_EXTERNAL_MODULE_webpack__["default"];
17
+ if (null === (_unpackConfig_dev = unpackConfig.dev) || void 0 === _unpackConfig_dev ? void 0 : _unpackConfig_dev.prebundle) unpackConfig = await (0, __WEBPACK_EXTERNAL_MODULE__prebundleDeps_js_142f70dc__.prebundleDeps)({
18
+ unpackConfig
19
+ });
20
+ const config = await (0, __WEBPACK_EXTERNAL_MODULE__bundler_config_index_js_e76188c2__.getBundlerConfig)(unpackConfig);
21
+ const compiler = bundler(config);
22
+ const port = await (0, __WEBPACK_EXTERNAL_MODULE__utils_js_db66b9f7__.getPort)(null === (_unpackConfig_server = unpackConfig.server) || void 0 === _unpackConfig_server ? void 0 : _unpackConfig_server.port);
23
+ const devServerOptions = {
24
+ hot: true,
25
+ port,
26
+ open: false,
27
+ client: {
28
+ overlay: false
29
+ },
30
+ proxy: null === (_unpackConfig_server1 = unpackConfig.server) || void 0 === _unpackConfig_server1 ? void 0 : _unpackConfig_server1.proxy,
31
+ devMiddleware: {
32
+ writeToDisk: null === (_unpackConfig_dev1 = unpackConfig.dev) || void 0 === _unpackConfig_dev1 ? void 0 : _unpackConfig_dev1.writeToDisk
33
+ }
34
+ };
35
+ const server = new __WEBPACK_EXTERNAL_MODULE_webpack_dev_server_0dd3124e__["default"](devServerOptions, compiler);
36
+ __WEBPACK_EXTERNAL_MODULE__logger_js_ff791b17__.logger.greet(` ${__WEBPACK_EXTERNAL_MODULE__colors_js_1d4535d6__["default"].green(`${__WEBPACK_EXTERNAL_MODULE__colors_js_1d4535d6__["default"].bold('UNPACK')} v1.7.7`)} ${__WEBPACK_EXTERNAL_MODULE__colors_js_1d4535d6__["default"].dim(`ready in ${__WEBPACK_EXTERNAL_MODULE__colors_js_1d4535d6__["default"].reset(__WEBPACK_EXTERNAL_MODULE__colors_js_1d4535d6__["default"].bold(Math.ceil(performance.now() - global.__unpack_start_time)))}ms`)}\n`);
37
+ printAddressUrls(port);
38
+ await server.start();
39
+ __WEBPACK_EXTERNAL_MODULE__global_js_83d0ec5c__.restartCleaners.push(async ()=>await server.stop(), ()=>new Promise((resolve)=>compiler.close(()=>resolve())));
40
+ const { open } = unpackConfig.server;
41
+ if (open) {
42
+ const url = (0, __WEBPACK_EXTERNAL_MODULE__utils_js_db66b9f7__.isString)(open) ? open : `http://localhost:${port}`;
43
+ await (0, __WEBPACK_EXTERNAL_MODULE__openBrowser_js_007107e2__.openBrowser)(url);
38
44
  }
39
- };
40
- const server = new WebpackDevServer(devServerOptions, compiler);
41
- logger.greet(
42
- ` ${colors.green(`${colors.bold("UNPACK")} v${"1.7.5"}`)} ${colors.dim(
43
- `ready in ${colors.reset(
44
- colors.bold(Math.ceil(performance.now() - global.__unpack_start_time))
45
- )}ms`
46
- )}
47
- `
48
- );
49
- printAddressUrls(port);
50
- await server.start();
51
- const { open } = unpackConfig.server;
52
- if (open) {
53
- const url = isString(open) ? open : `http://localhost:${port}`;
54
- await openBrowser(url);
55
- }
56
45
  }
57
46
  function printAddressUrls(port) {
58
- const addressUrls = getAddressUrls({ port });
59
- const colorUrl = (url) => colors.cyan(url.replace(/:(\d+)\//, (_, port2) => `:${colors.bold(port2)}/`));
60
- addressUrls.forEach((addr) => {
61
- console.log(` ${colors.green("")} ${colors.bold(addr.label)}${colorUrl(addr.url)}`);
62
- });
47
+ const addressUrls = (0, __WEBPACK_EXTERNAL_MODULE__utils_js_db66b9f7__.getAddressUrls)({
48
+ port
49
+ });
50
+ const colorUrl = (url)=>__WEBPACK_EXTERNAL_MODULE__colors_js_1d4535d6__["default"].cyan(url.replace(/:(\d+)\//, (_, port)=>`:${__WEBPACK_EXTERNAL_MODULE__colors_js_1d4535d6__["default"].bold(port)}/`));
51
+ addressUrls.forEach((addr)=>{
52
+ console.log(` ${__WEBPACK_EXTERNAL_MODULE__colors_js_1d4535d6__["default"].green('➜')} ${__WEBPACK_EXTERNAL_MODULE__colors_js_1d4535d6__["default"].bold(addr.label)}${colorUrl(addr.url)}`);
53
+ });
63
54
  }
64
- export {
65
- bundlerDev
66
- };
55
+ export { bundlerDev };
@@ -1,23 +1,76 @@
1
- var __defProp = Object.defineProperty;
2
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
- var __getOwnPropNames = Object.getOwnPropertyNames;
4
- var __hasOwnProp = Object.prototype.hasOwnProperty;
5
- var __copyProps = (to, from, except, desc) => {
6
- if (from && typeof from === "object" || typeof from === "function") {
7
- for (let key of __getOwnPropNames(from))
8
- if (!__hasOwnProp.call(to, key) && key !== except)
9
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
10
- }
11
- return to;
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
+ }
12
9
  };
13
- var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
14
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
15
- var run_exports = {};
16
- module.exports = __toCommonJS(run_exports);
17
- __reExport(run_exports, require("./build.cjs"), module.exports);
18
- __reExport(run_exports, require("./dev.cjs"), module.exports);
19
- // Annotate the CommonJS export names for ESM import in node:
20
- 0 && (module.exports = {
21
- ...require("./build.cjs"),
22
- ...require("./dev.cjs")
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 = function(module) {
22
+ var getter = module && module.__esModule ? function() {
23
+ return module['default'];
24
+ } : function() {
25
+ return module;
26
+ };
27
+ __webpack_require__.d(getter, {
28
+ a: getter
29
+ });
30
+ return getter;
31
+ };
32
+ })();
33
+ (()=>{
34
+ __webpack_require__.d = function(exports1, definition) {
35
+ for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
36
+ enumerable: true,
37
+ get: definition[key]
38
+ });
39
+ };
40
+ })();
41
+ (()=>{
42
+ __webpack_require__.o = function(obj, prop) {
43
+ return Object.prototype.hasOwnProperty.call(obj, prop);
44
+ };
45
+ })();
46
+ (()=>{
47
+ __webpack_require__.r = function(exports1) {
48
+ if ('undefined' != typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
49
+ value: 'Module'
50
+ });
51
+ Object.defineProperty(exports1, '__esModule', {
52
+ value: true
53
+ });
54
+ };
55
+ })();
56
+ var __webpack_exports__ = {};
57
+ (()=>{
58
+ __webpack_require__.r(__webpack_exports__);
59
+ var _build__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__("./build");
60
+ var __WEBPACK_REEXPORT_OBJECT__ = {};
61
+ for(var __WEBPACK_IMPORT_KEY__ in _build__WEBPACK_IMPORTED_MODULE_0__)if ("default" !== __WEBPACK_IMPORT_KEY__) __WEBPACK_REEXPORT_OBJECT__[__WEBPACK_IMPORT_KEY__] = (function(key) {
62
+ return _build__WEBPACK_IMPORTED_MODULE_0__[key];
63
+ }).bind(0, __WEBPACK_IMPORT_KEY__);
64
+ __webpack_require__.d(__webpack_exports__, __WEBPACK_REEXPORT_OBJECT__);
65
+ var _dev__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__("./dev");
66
+ var __WEBPACK_REEXPORT_OBJECT__ = {};
67
+ for(var __WEBPACK_IMPORT_KEY__ in _dev__WEBPACK_IMPORTED_MODULE_1__)if ("default" !== __WEBPACK_IMPORT_KEY__) __WEBPACK_REEXPORT_OBJECT__[__WEBPACK_IMPORT_KEY__] = (function(key) {
68
+ return _dev__WEBPACK_IMPORTED_MODULE_1__[key];
69
+ }).bind(0, __WEBPACK_IMPORT_KEY__);
70
+ __webpack_require__.d(__webpack_exports__, __WEBPACK_REEXPORT_OBJECT__);
71
+ })();
72
+ var __webpack_export_target__ = exports;
73
+ for(var __webpack_i__ in __webpack_exports__)__webpack_export_target__[__webpack_i__] = __webpack_exports__[__webpack_i__];
74
+ if (__webpack_exports__.__esModule) Object.defineProperty(__webpack_export_target__, '__esModule', {
75
+ value: true
23
76
  });
package/dist/run/index.js CHANGED
@@ -1,11 +1,4 @@
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();
1
+ import __rslib_shim_module__ from 'module';
2
+ /*#__PURE__*/ import.meta.url;
10
3
  export * from "./build.js";
11
4
  export * from "./dev.js";
@@ -1,195 +1,186 @@
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 loader_exports = {};
29
- __export(loader_exports, {
30
- default: () => loader_default,
31
- isInNodeModules: () => isInNodeModules,
32
- wrapQuotes: () => wrapQuotes
33
- });
34
- module.exports = __toCommonJS(loader_exports);
35
- var import_node_fs = __toESM(require("node:fs"));
36
- var import_node_path = __toESM(require("node:path"));
37
- var import_constants = require("../constants.cjs");
38
- var import_utils = require("./utils.cjs");
39
- const LineDiff = require("../../compiled/line-diff/index.js");
40
- const isInNodeModules = (path2) => import_constants.NODE_MODULES_REGEX.test(path2);
41
- const getNoDeclarationFileError = ({ filename }) => new Error(
42
- `Generated type declaration does not exist. Run Unpack and commit the type declaration for '${filename}'`
43
- );
44
- const getTypeMismatchError = ({
45
- filename,
46
- expected,
47
- actual
48
- }) => {
49
- const diff = new LineDiff(enforceLFLineSeparators(actual), expected).toString();
50
- return new Error(
51
- `Generated type declaration file is outdated. Run Unpack and commit the updated type declaration for '${filename}'
52
-
53
- ${diff}`
54
- );
55
- };
56
- function wrapQuotes(key) {
57
- const isValidIdentifier = /^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(key);
58
- if (isValidIdentifier) {
59
- return key;
60
- }
61
- return `'${key}'`;
62
- }
63
- const cssModuleToNamedExports = (cssModuleKeys) => {
64
- return cssModuleKeys.sort().map((key) => `export const ${key}: string;`).join("\n");
65
- };
66
- const cssModuleToInterface = (cssModulesKeys) => {
67
- const interfaceFields = cssModulesKeys.sort().map((key) => ` ${wrapQuotes(key)}: string;`).join("\n");
68
- return `interface CssExports {
69
- ${interfaceFields}
70
- }`;
71
- };
72
- const filenameToTypingsFilename = (filename) => {
73
- const dirName = import_node_path.default.dirname(filename);
74
- const baseName = import_node_path.default.basename(filename);
75
- return import_node_path.default.join(dirName, `${baseName}.d.ts`);
76
- };
77
- const enforceLFLineSeparators = (text) => {
78
- if (text) {
79
- return text.replace(/\r\n/g, "\n");
80
- }
81
- return text;
82
- };
83
- const compareText = (contentA, contentB) => {
84
- return enforceLFLineSeparators(contentA) === enforceLFLineSeparators(contentB);
85
- };
86
- const validModes = ["emit", "verify"];
87
- const isFileNotFound = (err) => err && err.code === "ENOENT";
88
- const makeDoneHandlers = (callback, content, rest) => ({
89
- failed: (e) => callback(e),
90
- success: () => callback(null, content, ...rest)
91
- });
92
- const makeFileHandlers = (filename) => ({
93
- read: (handler) => import_node_fs.default.readFile(filename, { encoding: "utf-8" }, handler),
94
- write: (content, handler) => import_node_fs.default.writeFile(filename, content, { encoding: "utf-8" }, handler)
95
- });
96
- const extractLocalExports = (content) => {
97
- let localExports = content.split("exports.locals")[1];
98
- if (!localExports) {
99
- localExports = content.split("___CSS_LOADER_EXPORT___.locals")[1];
100
- }
101
- return localExports;
102
- };
103
- const getCSSModulesKeys = (content, namedExport) => {
104
- const keys = /* @__PURE__ */ new Set();
105
- if (namedExport) {
106
- const exportsRegex = /export\s+var\s+(\w+)\s*=/g;
107
- let match2 = exportsRegex.exec(content);
108
- while (match2 !== null) {
109
- keys.add(match2[1]);
110
- match2 = exportsRegex.exec(content);
1
+ "use strict";
2
+ var __webpack_modules__ = {
3
+ "compiled/line-diff/index.js": function(module) {
4
+ module.exports = require("/home/runner/work/unpack/unpack/packages/core/compiled/line-diff/index.js");
111
5
  }
112
- return Array.from(keys);
113
- }
114
- const localExports = extractLocalExports(content);
115
- const keyRegex = /"([^\\"]+)":/g;
116
- let match = keyRegex.exec(localExports);
117
- while (match !== null) {
118
- keys.add(match[1]);
119
- match = keyRegex.exec(localExports);
120
- }
121
- return Array.from(keys);
122
6
  };
123
- function codegen(keys, namedExport) {
124
- const bannerMessage = "// Generated automatically, do not edit";
125
- if (namedExport) {
126
- return `${bannerMessage}
127
- ${cssModuleToNamedExports(keys)}
128
- `;
129
- }
130
- const cssModuleExport = "declare const cssExports: CssExports;\nexport default cssExports;\n";
131
- return `${bannerMessage}
132
- ${cssModuleToInterface(keys)}
133
- ${cssModuleExport}`;
7
+ var __webpack_module_cache__ = {};
8
+ function __webpack_require__(moduleId) {
9
+ var cachedModule = __webpack_module_cache__[moduleId];
10
+ if (void 0 !== cachedModule) return cachedModule.exports;
11
+ var module = __webpack_module_cache__[moduleId] = {
12
+ exports: {}
13
+ };
14
+ __webpack_modules__[moduleId](module, module.exports, __webpack_require__);
15
+ return module.exports;
134
16
  }
135
- function loader_default(content, ...rest) {
136
- const { failed, success } = makeDoneHandlers(this.async(), content, rest);
137
- const { resourcePath } = this;
138
- const { mode = "emit", modules } = this.getOptions() || {};
139
- if (!validModes.includes(mode)) {
140
- failed(new Error(`Invalid mode option: ${mode}`));
141
- return;
142
- }
143
- if (!(0, import_utils.isCSSModules)({ resourcePath, modules }) || isInNodeModules(resourcePath)) {
144
- success();
145
- return;
146
- }
147
- const cssModuleInterfaceFilename = filenameToTypingsFilename(resourcePath);
148
- const { read, write } = makeFileHandlers(cssModuleInterfaceFilename);
149
- const namedExport = import_constants.CSS_NAMED_EXPORT;
150
- const cssModulesKeys = getCSSModulesKeys(content, namedExport);
151
- const cssModulesCode = codegen(cssModulesKeys, namedExport);
152
- if (mode === "verify") {
153
- read((err, fileContents) => {
154
- if (isFileNotFound(err)) {
155
- return failed(
156
- getNoDeclarationFileError({
157
- filename: cssModuleInterfaceFilename
158
- })
159
- );
160
- }
161
- if (err) {
162
- return failed(err);
163
- }
164
- if (!compareText(cssModulesCode, fileContents)) {
165
- return failed(
166
- getTypeMismatchError({
167
- filename: cssModuleInterfaceFilename,
168
- expected: cssModulesCode,
169
- actual: fileContents
170
- })
171
- );
172
- }
173
- return success();
17
+ (()=>{
18
+ __webpack_require__.n = function(module) {
19
+ var getter = module && module.__esModule ? function() {
20
+ return module['default'];
21
+ } : function() {
22
+ return module;
23
+ };
24
+ __webpack_require__.d(getter, {
25
+ a: getter
26
+ });
27
+ return getter;
28
+ };
29
+ })();
30
+ (()=>{
31
+ __webpack_require__.d = function(exports1, definition) {
32
+ for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
33
+ enumerable: true,
34
+ get: definition[key]
35
+ });
36
+ };
37
+ })();
38
+ (()=>{
39
+ __webpack_require__.o = function(obj, prop) {
40
+ return Object.prototype.hasOwnProperty.call(obj, prop);
41
+ };
42
+ })();
43
+ (()=>{
44
+ __webpack_require__.r = function(exports1) {
45
+ if ('undefined' != typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
46
+ value: 'Module'
47
+ });
48
+ Object.defineProperty(exports1, '__esModule', {
49
+ value: true
50
+ });
51
+ };
52
+ })();
53
+ var __webpack_exports__ = {};
54
+ (()=>{
55
+ __webpack_require__.r(__webpack_exports__);
56
+ __webpack_require__.d(__webpack_exports__, {
57
+ isInNodeModules: ()=>isInNodeModules,
58
+ wrapQuotes: ()=>wrapQuotes,
59
+ default: ()=>loader_rslib_entry_
174
60
  });
175
- } else {
176
- read((_, fileContents) => {
177
- if (!compareText(cssModulesCode, fileContents)) {
178
- write(cssModulesCode, (err) => {
179
- if (err) {
180
- failed(err);
181
- } else {
61
+ const external_node_fs_namespaceObject = require("node:fs");
62
+ var external_node_fs_default = /*#__PURE__*/ __webpack_require__.n(external_node_fs_namespaceObject);
63
+ const external_node_path_namespaceObject = require("node:path");
64
+ var external_node_path_default = /*#__PURE__*/ __webpack_require__.n(external_node_path_namespaceObject);
65
+ const external_constants_cjs_namespaceObject = require("../constants.cjs");
66
+ const external_utils_cjs_namespaceObject = require("./utils.cjs");
67
+ const LineDiff = __webpack_require__("compiled/line-diff/index.js");
68
+ const isInNodeModules = (path)=>external_constants_cjs_namespaceObject.NODE_MODULES_REGEX.test(path);
69
+ const getNoDeclarationFileError = ({ filename })=>new Error(`Generated type declaration does not exist. Run Unpack and commit the type declaration for '${filename}'`);
70
+ const getTypeMismatchError = ({ filename, expected, actual })=>{
71
+ const diff = new LineDiff(enforceLFLineSeparators(actual), expected).toString();
72
+ return new Error(`Generated type declaration file is outdated. Run Unpack and commit the updated type declaration for '${filename}'\n\n${diff}`);
73
+ };
74
+ function wrapQuotes(key) {
75
+ const isValidIdentifier = /^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(key);
76
+ if (isValidIdentifier) return key;
77
+ return `'${key}'`;
78
+ }
79
+ const cssModuleToNamedExports = (cssModuleKeys)=>cssModuleKeys.sort().map((key)=>`export const ${key}: string;`).join('\n');
80
+ const cssModuleToInterface = (cssModulesKeys)=>{
81
+ const interfaceFields = cssModulesKeys.sort().map((key)=>` ${wrapQuotes(key)}: string;`).join('\n');
82
+ return `interface CssExports {\n${interfaceFields}\n}`;
83
+ };
84
+ const filenameToTypingsFilename = (filename)=>{
85
+ const dirName = external_node_path_default().dirname(filename);
86
+ const baseName = external_node_path_default().basename(filename);
87
+ return external_node_path_default().join(dirName, `${baseName}.d.ts`);
88
+ };
89
+ const enforceLFLineSeparators = (text)=>{
90
+ if (text) return text.replace(/\r\n/g, '\n');
91
+ return text;
92
+ };
93
+ const compareText = (contentA, contentB)=>enforceLFLineSeparators(contentA) === enforceLFLineSeparators(contentB);
94
+ const validModes = [
95
+ 'emit',
96
+ 'verify'
97
+ ];
98
+ const isFileNotFound = (err)=>err && 'ENOENT' === err.code;
99
+ const makeDoneHandlers = (callback, content, rest)=>({
100
+ failed: (e)=>callback(e),
101
+ success: ()=>callback(null, content, ...rest)
102
+ });
103
+ const makeFileHandlers = (filename)=>({
104
+ read: (handler)=>external_node_fs_default().readFile(filename, {
105
+ encoding: 'utf-8'
106
+ }, handler),
107
+ write: (content, handler)=>external_node_fs_default().writeFile(filename, content, {
108
+ encoding: 'utf-8'
109
+ }, handler)
110
+ });
111
+ const extractLocalExports = (content)=>{
112
+ let localExports = content.split('exports.locals')[1];
113
+ if (!localExports) localExports = content.split('___CSS_LOADER_EXPORT___.locals')[1];
114
+ return localExports;
115
+ };
116
+ const getCSSModulesKeys = (content, namedExport)=>{
117
+ const keys = new Set();
118
+ if (namedExport) {
119
+ const exportsRegex = /export\s+var\s+(\w+)\s*=/g;
120
+ let match = exportsRegex.exec(content);
121
+ while(null !== match){
122
+ keys.add(match[1]);
123
+ match = exportsRegex.exec(content);
124
+ }
125
+ return Array.from(keys);
126
+ }
127
+ const localExports = extractLocalExports(content);
128
+ const keyRegex = /"([^\\"]+)":/g;
129
+ let match = keyRegex.exec(localExports);
130
+ while(null !== match){
131
+ keys.add(match[1]);
132
+ match = keyRegex.exec(localExports);
133
+ }
134
+ return Array.from(keys);
135
+ };
136
+ function codegen(keys, namedExport) {
137
+ const bannerMessage = '// Generated automatically, do not edit';
138
+ if (namedExport) return `${bannerMessage}\n${cssModuleToNamedExports(keys)}\n`;
139
+ const cssModuleExport = 'declare const cssExports: CssExports;\nexport default cssExports;\n';
140
+ return `${bannerMessage}\n${cssModuleToInterface(keys)}\n${cssModuleExport}`;
141
+ }
142
+ function loader_rslib_entry_(content, ...rest) {
143
+ const { failed, success } = makeDoneHandlers(this.async(), content, rest);
144
+ const { resourcePath } = this;
145
+ const { mode = 'emit', modules } = this.getOptions() || {};
146
+ if (!validModes.includes(mode)) {
147
+ failed(new Error(`Invalid mode option: ${mode}`));
148
+ return;
149
+ }
150
+ if (!(0, external_utils_cjs_namespaceObject.isCSSModules)({
151
+ resourcePath,
152
+ modules
153
+ }) || isInNodeModules(resourcePath)) {
182
154
  success();
183
- }
155
+ return;
156
+ }
157
+ const cssModuleInterfaceFilename = filenameToTypingsFilename(resourcePath);
158
+ const { read, write } = makeFileHandlers(cssModuleInterfaceFilename);
159
+ const namedExport = external_constants_cjs_namespaceObject.CSS_NAMED_EXPORT;
160
+ const cssModulesKeys = getCSSModulesKeys(content, namedExport);
161
+ const cssModulesCode = codegen(cssModulesKeys, namedExport);
162
+ read('verify' === mode ? (err, fileContents)=>{
163
+ if (isFileNotFound(err)) return failed(getNoDeclarationFileError({
164
+ filename: cssModuleInterfaceFilename
165
+ }));
166
+ if (err) return failed(err);
167
+ if (!compareText(cssModulesCode, fileContents)) return failed(getTypeMismatchError({
168
+ filename: cssModuleInterfaceFilename,
169
+ expected: cssModulesCode,
170
+ actual: fileContents
171
+ }));
172
+ return success();
173
+ } : (_, fileContents)=>{
174
+ if (compareText(cssModulesCode, fileContents)) success();
175
+ else write(cssModulesCode, (err)=>{
176
+ if (err) failed(err);
177
+ else success();
178
+ });
184
179
  });
185
- } else {
186
- success();
187
- }
188
- });
189
- }
190
- }
191
- // Annotate the CommonJS export names for ESM import in node:
192
- 0 && (module.exports = {
193
- isInNodeModules,
194
- wrapQuotes
180
+ }
181
+ })();
182
+ var __webpack_export_target__ = exports;
183
+ for(var __webpack_i__ in __webpack_exports__)__webpack_export_target__[__webpack_i__] = __webpack_exports__[__webpack_i__];
184
+ if (__webpack_exports__.__esModule) Object.defineProperty(__webpack_export_target__, '__esModule', {
185
+ value: true
195
186
  });