@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/config.js CHANGED
@@ -1,78 +1,72 @@
1
- import { createRequire } from 'node:module';
2
- var require = createRequire(import.meta['url']);
3
-
4
- import path from "path";
5
- import { fileURLToPath } from "url";
6
- var getFilename = () => fileURLToPath(import.meta.url);
7
- var getDirname = () => path.dirname(getFilename());
8
- var __dirname = /* @__PURE__ */ getDirname();
9
- var __filename = /* @__PURE__ */ getFilename();
10
- import fs from "node:fs";
11
- import { isAbsolute, join } from "node:path";
12
- import { bundleRequire } from "./bundleRequire.js";
13
- import { logger } from "./logger.js";
14
- import { getNodeEnv, setDevServer, setNodeEnv, setValueByPath } from "./utils.js";
15
- async function loadConfig({
16
- cliOptions,
17
- command
18
- }) {
19
- if (command === "build") {
20
- setNodeEnv(cliOptions?.watch ? "development" : "production");
21
- } else {
22
- setNodeEnv("development");
23
- setDevServer(true);
24
- }
25
- const configPath = resolveConfigPath(process.cwd(), cliOptions?.config);
26
- let userConfig = {};
27
- if (configPath) {
28
- userConfig = await bundleRequire(configPath);
29
- if (typeof userConfig === "function") {
30
- const params = {
31
- env: getNodeEnv(),
32
- command: process.argv[2]
33
- };
34
- userConfig = await userConfig(params);
35
- if (userConfig === void 0) {
36
- throw new Error("Unpack config function must return a config object.");
37
- }
1
+ import __rslib_shim_module__ from 'module';
2
+ /*#__PURE__*/ import.meta.url;
3
+ import { fileURLToPath as __webpack_fileURLToPath__ } from "node:url";
4
+ import * as __WEBPACK_EXTERNAL_MODULE_node_fs_5ea92f0c__ from "node:fs";
5
+ import * as __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__ from "node:path";
6
+ import * as __WEBPACK_EXTERNAL_MODULE_jiti__ from "jiti";
7
+ import * as __WEBPACK_EXTERNAL_MODULE__logger_js_c2be5186__ from "./logger.js";
8
+ import * as __WEBPACK_EXTERNAL_MODULE__utils_js_d88b7fe1__ from "./utils.js";
9
+ var config_rslib_entry_filename = __webpack_fileURLToPath__(import.meta.url);
10
+ async function loadConfig({ cliOptions, command }) {
11
+ if ('build' === command) (0, __WEBPACK_EXTERNAL_MODULE__utils_js_d88b7fe1__.setNodeEnv)((null == cliOptions ? void 0 : cliOptions.watch) ? 'development' : 'production');
12
+ else {
13
+ (0, __WEBPACK_EXTERNAL_MODULE__utils_js_d88b7fe1__.setNodeEnv)('development');
14
+ (0, __WEBPACK_EXTERNAL_MODULE__utils_js_d88b7fe1__.setDevServer)(true);
38
15
  }
39
- }
40
- if (cliOptions?.port)
41
- setValueByPath(userConfig, ["server", "port"], cliOptions.port);
42
- if (cliOptions?.open)
43
- setValueByPath(userConfig, ["server", "open"], cliOptions.open);
44
- if (cliOptions?.analyze)
45
- setValueByPath(userConfig, ["performance", "bundleAnalyze"], cliOptions.analyze);
46
- return userConfig;
16
+ const configPath = resolveConfigPath(process.cwd(), null == cliOptions ? void 0 : cliOptions.config);
17
+ let userConfig = {};
18
+ if (configPath) {
19
+ const jiti = (0, __WEBPACK_EXTERNAL_MODULE_jiti__.createJiti)(config_rslib_entry_filename, {
20
+ moduleCache: false,
21
+ interopDefault: true
22
+ });
23
+ userConfig = await jiti.import(configPath, {
24
+ default: true
25
+ });
26
+ if ('function' == typeof userConfig) {
27
+ const params = {
28
+ env: (0, __WEBPACK_EXTERNAL_MODULE__utils_js_d88b7fe1__.getNodeEnv)(),
29
+ command: process.argv[2]
30
+ };
31
+ userConfig = await userConfig(params);
32
+ if (void 0 === userConfig) throw new Error('Unpack config function must return a config object.');
33
+ }
34
+ }
35
+ if (null == cliOptions ? void 0 : cliOptions.port) (0, __WEBPACK_EXTERNAL_MODULE__utils_js_d88b7fe1__.setValueByPath)(userConfig, [
36
+ 'server',
37
+ 'port'
38
+ ], cliOptions.port);
39
+ if (null == cliOptions ? void 0 : cliOptions.open) (0, __WEBPACK_EXTERNAL_MODULE__utils_js_d88b7fe1__.setValueByPath)(userConfig, [
40
+ 'server',
41
+ 'open'
42
+ ], cliOptions.open);
43
+ if (null == cliOptions ? void 0 : cliOptions.analyze) (0, __WEBPACK_EXTERNAL_MODULE__utils_js_d88b7fe1__.setValueByPath)(userConfig, [
44
+ 'performance',
45
+ 'bundleAnalyze'
46
+ ], cliOptions.analyze);
47
+ return userConfig;
47
48
  }
48
49
  function defineConfig(config) {
49
- return config;
50
+ return config;
50
51
  }
51
52
  function resolveConfigPath(root, customConfig) {
52
- if (customConfig) {
53
- const customConfigPath = isAbsolute(customConfig) ? customConfig : join(root, customConfig);
54
- if (fs.existsSync(customConfigPath)) {
55
- return customConfigPath;
53
+ if (customConfig) {
54
+ const customConfigPath = (0, __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__.isAbsolute)(customConfig) ? customConfig : (0, __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__.join)(root, customConfig);
55
+ if (__WEBPACK_EXTERNAL_MODULE_node_fs_5ea92f0c__["default"].existsSync(customConfigPath)) return customConfigPath;
56
+ __WEBPACK_EXTERNAL_MODULE__logger_js_c2be5186__.logger.warn(`Could not find config file: ${customConfigPath}`);
56
57
  }
57
- logger.warn(`Could not find config file: ${customConfigPath}`);
58
- }
59
- const CONFIG_FILES = [
60
- "unpack.config.ts",
61
- "unpack.config.js",
62
- "unpack.config.mjs",
63
- "unpack.config.cjs",
64
- "unpack.config.mts",
65
- "unpack.config.cts"
66
- ];
67
- for (const file of CONFIG_FILES) {
68
- const configFile = join(root, file);
69
- if (fs.existsSync(configFile)) {
70
- return configFile;
58
+ const CONFIG_FILES = [
59
+ 'unpack.config.ts',
60
+ 'unpack.config.js',
61
+ 'unpack.config.mjs',
62
+ 'unpack.config.cjs',
63
+ 'unpack.config.mts',
64
+ 'unpack.config.cts'
65
+ ];
66
+ for (const file of CONFIG_FILES){
67
+ const configFile = (0, __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__.join)(root, file);
68
+ if (__WEBPACK_EXTERNAL_MODULE_node_fs_5ea92f0c__["default"].existsSync(configFile)) return configFile;
71
69
  }
72
- }
73
- return null;
70
+ return null;
74
71
  }
75
- export {
76
- defineConfig,
77
- loadConfig
78
- };
72
+ export { defineConfig, loadConfig };
@@ -1,59 +1,74 @@
1
- var __defProp = Object.defineProperty;
2
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
- var __getOwnPropNames = Object.getOwnPropertyNames;
4
- var __hasOwnProp = Object.prototype.hasOwnProperty;
5
- var __export = (target, all) => {
6
- for (var name in all)
7
- __defProp(target, name, { get: all[name], enumerable: true });
8
- };
9
- var __copyProps = (to, from, except, desc) => {
10
- if (from && typeof from === "object" || typeof from === "function") {
11
- for (let key of __getOwnPropNames(from))
12
- if (!__hasOwnProp.call(to, key) && key !== except)
13
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
- }
15
- return to;
16
- };
17
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
- var constants_exports = {};
19
- __export(constants_exports, {
20
- CSS_MODULES_LOCAL_IDENT_NAME: () => CSS_MODULES_LOCAL_IDENT_NAME,
21
- CSS_MODULES_REGEX: () => CSS_MODULES_REGEX,
22
- CSS_NAMED_EXPORT: () => CSS_NAMED_EXPORT,
23
- DEFAULT_BROWSERSLIST: () => DEFAULT_BROWSERSLIST,
24
- DEFAULT_DEV_HOST: () => DEFAULT_DEV_HOST,
25
- DEV_DEFAULT_FILENAME: () => DEV_DEFAULT_FILENAME,
26
- ESBUILD_TARGET: () => ESBUILD_TARGET,
27
- EXPORT_LOCALS_CONVENTION: () => EXPORT_LOCALS_CONVENTION,
28
- NODE_MODULES_REGEX: () => NODE_MODULES_REGEX,
29
- PROD_DEFAULT_FILENAME: () => PROD_DEFAULT_FILENAME,
30
- TEMPLATE_CONTENT: () => TEMPLATE_CONTENT,
31
- TEMP_DIR: () => TEMP_DIR,
32
- THREAD_OPTIONS: () => THREAD_OPTIONS
1
+ "use strict";
2
+ var __webpack_require__ = {};
3
+ (()=>{
4
+ __webpack_require__.d = function(exports1, definition) {
5
+ for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
6
+ enumerable: true,
7
+ get: definition[key]
8
+ });
9
+ };
10
+ })();
11
+ (()=>{
12
+ __webpack_require__.o = function(obj, prop) {
13
+ return Object.prototype.hasOwnProperty.call(obj, prop);
14
+ };
15
+ })();
16
+ (()=>{
17
+ __webpack_require__.r = function(exports1) {
18
+ if ('undefined' != typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
19
+ value: 'Module'
20
+ });
21
+ Object.defineProperty(exports1, '__esModule', {
22
+ value: true
23
+ });
24
+ };
25
+ })();
26
+ var __webpack_exports__ = {};
27
+ __webpack_require__.r(__webpack_exports__);
28
+ __webpack_require__.d(__webpack_exports__, {
29
+ CSS_NAMED_EXPORT: ()=>CSS_NAMED_EXPORT,
30
+ PROD_DEFAULT_FILENAME: ()=>PROD_DEFAULT_FILENAME,
31
+ CSS_MODULES_LOCAL_IDENT_NAME: ()=>CSS_MODULES_LOCAL_IDENT_NAME,
32
+ DEFAULT_BROWSERSLIST: ()=>DEFAULT_BROWSERSLIST,
33
+ ESBUILD_TARGET: ()=>ESBUILD_TARGET,
34
+ NODE_MODULES_REGEX: ()=>NODE_MODULES_REGEX,
35
+ DEV_DEFAULT_FILENAME: ()=>DEV_DEFAULT_FILENAME,
36
+ TEMPLATE_CONTENT: ()=>TEMPLATE_CONTENT,
37
+ CSS_MODULES_REGEX: ()=>CSS_MODULES_REGEX,
38
+ TEMP_DIR: ()=>TEMP_DIR,
39
+ THREAD_OPTIONS: ()=>THREAD_OPTIONS,
40
+ DEFAULT_DEV_HOST: ()=>DEFAULT_DEV_HOST,
41
+ EXPORT_LOCALS_CONVENTION: ()=>EXPORT_LOCALS_CONVENTION,
42
+ LIGHTNINGCSS_TARGET: ()=>LIGHTNINGCSS_TARGET
33
43
  });
34
- module.exports = __toCommonJS(constants_exports);
35
- const CSS_MODULES_LOCAL_IDENT_NAME = "[path][name]__[local]--[hash:5]";
44
+ const external_lightningcss_namespaceObject = require("lightningcss");
45
+ const CSS_MODULES_LOCAL_IDENT_NAME = '[path][name]__[local]--[hash:5]';
36
46
  const CSS_MODULES_REGEX = /\.module\.\w+$/i;
37
47
  const DEV_DEFAULT_FILENAME = {
38
- js: "js/[name].js",
39
- css: "css/[name].css"
48
+ js: 'js/[name].js',
49
+ css: 'css/[name].css'
40
50
  };
41
51
  const PROD_DEFAULT_FILENAME = {
42
- js: "js/[name]_[contenthash:8].js",
43
- css: "css/[name]_[contenthash:8].css"
52
+ js: 'js/[name]_[contenthash:8].js',
53
+ css: 'css/[name]_[contenthash:8].css'
44
54
  };
45
- const EXPORT_LOCALS_CONVENTION = "camel-case-only";
46
- const TEMP_DIR = "node_modules/.unpack";
55
+ const EXPORT_LOCALS_CONVENTION = 'camel-case-only';
56
+ const TEMP_DIR = 'node_modules/.unpack';
47
57
  const NODE_MODULES_REGEX = /[\\/]node_modules[\\/]/;
48
58
  const CSS_NAMED_EXPORT = false;
49
59
  const THREAD_OPTIONS = {
50
- workers: 2
60
+ workers: 2
51
61
  };
52
- const DEFAULT_DEV_HOST = "0.0.0.0";
53
- const DEFAULT_BROWSERSLIST = ["chrome 87", "edge 88", "firefox 78", "safari 14"];
54
- const ESBUILD_TARGET = DEFAULT_BROWSERSLIST.map((item) => item.replace(" ", ""));
55
- const TEMPLATE_CONTENT = ({ title = "", headTag = "", mountId }) => {
56
- return `<!DOCTYPE html>
62
+ const DEFAULT_DEV_HOST = '0.0.0.0';
63
+ const DEFAULT_BROWSERSLIST = [
64
+ 'chrome >= 87',
65
+ 'edge >= 88',
66
+ 'firefox >= 78',
67
+ 'safari >= 14'
68
+ ];
69
+ const ESBUILD_TARGET = DEFAULT_BROWSERSLIST.map((item)=>item.replace(' >= ', ''));
70
+ const LIGHTNINGCSS_TARGET = (0, external_lightningcss_namespaceObject.browserslistToTargets)(DEFAULT_BROWSERSLIST.map((item)=>item.replace(' >= ', ' ')));
71
+ const TEMPLATE_CONTENT = ({ title = '', headTag = '', mountId })=>`<!DOCTYPE html>
57
72
  <html lang="en">
58
73
 
59
74
  <head>
@@ -70,20 +85,8 @@ const TEMPLATE_CONTENT = ({ title = "", headTag = "", mountId }) => {
70
85
  </body>
71
86
 
72
87
  </html>`;
73
- };
74
- // Annotate the CommonJS export names for ESM import in node:
75
- 0 && (module.exports = {
76
- CSS_MODULES_LOCAL_IDENT_NAME,
77
- CSS_MODULES_REGEX,
78
- CSS_NAMED_EXPORT,
79
- DEFAULT_BROWSERSLIST,
80
- DEFAULT_DEV_HOST,
81
- DEV_DEFAULT_FILENAME,
82
- ESBUILD_TARGET,
83
- EXPORT_LOCALS_CONVENTION,
84
- NODE_MODULES_REGEX,
85
- PROD_DEFAULT_FILENAME,
86
- TEMPLATE_CONTENT,
87
- TEMP_DIR,
88
- THREAD_OPTIONS
88
+ var __webpack_export_target__ = exports;
89
+ for(var __webpack_i__ in __webpack_exports__)__webpack_export_target__[__webpack_i__] = __webpack_exports__[__webpack_i__];
90
+ if (__webpack_exports__.__esModule) Object.defineProperty(__webpack_export_target__, '__esModule', {
91
+ value: true
89
92
  });
@@ -18,6 +18,7 @@ export declare const THREAD_OPTIONS: {
18
18
  export declare const DEFAULT_DEV_HOST = "0.0.0.0";
19
19
  export declare const DEFAULT_BROWSERSLIST: string[];
20
20
  export declare const ESBUILD_TARGET: string[];
21
+ export declare const LIGHTNINGCSS_TARGET: import("lightningcss").Targets;
21
22
  export declare const TEMPLATE_CONTENT: ({ title, headTag, mountId }: {
22
23
  title?: string;
23
24
  headTag?: string;
@@ -1 +1 @@
1
- {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,4BAA4B,oCAAoC,CAAA;AAC7E,eAAO,MAAM,iBAAiB,QAAoB,CAAA;AAClD,eAAO,MAAM,oBAAoB;;;CAGhC,CAAA;AACD,eAAO,MAAM,qBAAqB;;;CAGjC,CAAA;AACD,eAAO,MAAM,wBAAwB,oBAAoB,CAAA;AACzD,eAAO,MAAM,QAAQ,yBAAyB,CAAA;AAC9C,eAAO,MAAM,kBAAkB,QAA2B,CAAA;AAC1D,eAAO,MAAM,gBAAgB,QAAQ,CAAA;AACrC,eAAO,MAAM,cAAc;;CAE1B,CAAA;AACD,eAAO,MAAM,gBAAgB,YAAY,CAAA;AACzC,eAAO,MAAM,oBAAoB,EAAE,MAAM,EAAwD,CAAA;AACjG,eAAO,MAAM,cAAc,EAAE,MAAM,EAA8D,CAAA;AACjG,eAAO,MAAM,gBAAgB;;;;YAkB5B,CAAA"}
1
+ {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,4BAA4B,oCAAoC,CAAA;AAC7E,eAAO,MAAM,iBAAiB,QAAoB,CAAA;AAClD,eAAO,MAAM,oBAAoB;;;CAGhC,CAAA;AACD,eAAO,MAAM,qBAAqB;;;CAGjC,CAAA;AACD,eAAO,MAAM,wBAAwB,oBAAoB,CAAA;AACzD,eAAO,MAAM,QAAQ,yBAAyB,CAAA;AAC9C,eAAO,MAAM,kBAAkB,QAA2B,CAAA;AAC1D,eAAO,MAAM,gBAAgB,QAAQ,CAAA;AACrC,eAAO,MAAM,cAAc;;CAE1B,CAAA;AACD,eAAO,MAAM,gBAAgB,YAAY,CAAA;AACzC,eAAO,MAAM,oBAAoB,EAAE,MAAM,EAKxC,CAAA;AACD,eAAO,MAAM,cAAc,EAAE,MAAM,EAAiE,CAAA;AAEpG,eAAO,MAAM,mBAAmB,gCAE/B,CAAA;AAED,eAAO,MAAM,gBAAgB;;;;YAkB5B,CAAA"}
package/dist/constants.js CHANGED
@@ -1,34 +1,33 @@
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
- const CSS_MODULES_LOCAL_IDENT_NAME = "[path][name]__[local]--[hash:5]";
1
+ import __rslib_shim_module__ from 'module';
2
+ /*#__PURE__*/ import.meta.url;
3
+ import * as __WEBPACK_EXTERNAL_MODULE_lightningcss__ from "lightningcss";
4
+ const CSS_MODULES_LOCAL_IDENT_NAME = '[path][name]__[local]--[hash:5]';
11
5
  const CSS_MODULES_REGEX = /\.module\.\w+$/i;
12
6
  const DEV_DEFAULT_FILENAME = {
13
- js: "js/[name].js",
14
- css: "css/[name].css"
7
+ js: 'js/[name].js',
8
+ css: 'css/[name].css'
15
9
  };
16
10
  const PROD_DEFAULT_FILENAME = {
17
- js: "js/[name]_[contenthash:8].js",
18
- css: "css/[name]_[contenthash:8].css"
11
+ js: 'js/[name]_[contenthash:8].js',
12
+ css: 'css/[name]_[contenthash:8].css'
19
13
  };
20
- const EXPORT_LOCALS_CONVENTION = "camel-case-only";
21
- const TEMP_DIR = "node_modules/.unpack";
14
+ const EXPORT_LOCALS_CONVENTION = 'camel-case-only';
15
+ const TEMP_DIR = 'node_modules/.unpack';
22
16
  const NODE_MODULES_REGEX = /[\\/]node_modules[\\/]/;
23
17
  const CSS_NAMED_EXPORT = false;
24
18
  const THREAD_OPTIONS = {
25
- workers: 2
19
+ workers: 2
26
20
  };
27
- const DEFAULT_DEV_HOST = "0.0.0.0";
28
- const DEFAULT_BROWSERSLIST = ["chrome 87", "edge 88", "firefox 78", "safari 14"];
29
- const ESBUILD_TARGET = DEFAULT_BROWSERSLIST.map((item) => item.replace(" ", ""));
30
- const TEMPLATE_CONTENT = ({ title = "", headTag = "", mountId }) => {
31
- return `<!DOCTYPE html>
21
+ const DEFAULT_DEV_HOST = '0.0.0.0';
22
+ const DEFAULT_BROWSERSLIST = [
23
+ 'chrome >= 87',
24
+ 'edge >= 88',
25
+ 'firefox >= 78',
26
+ 'safari >= 14'
27
+ ];
28
+ const ESBUILD_TARGET = DEFAULT_BROWSERSLIST.map((item)=>item.replace(' >= ', ''));
29
+ const LIGHTNINGCSS_TARGET = (0, __WEBPACK_EXTERNAL_MODULE_lightningcss__.browserslistToTargets)(DEFAULT_BROWSERSLIST.map((item)=>item.replace(' >= ', ' ')));
30
+ const TEMPLATE_CONTENT = ({ title = '', headTag = '', mountId })=>`<!DOCTYPE html>
32
31
  <html lang="en">
33
32
 
34
33
  <head>
@@ -45,19 +44,4 @@ const TEMPLATE_CONTENT = ({ title = "", headTag = "", mountId }) => {
45
44
  </body>
46
45
 
47
46
  </html>`;
48
- };
49
- export {
50
- CSS_MODULES_LOCAL_IDENT_NAME,
51
- CSS_MODULES_REGEX,
52
- CSS_NAMED_EXPORT,
53
- DEFAULT_BROWSERSLIST,
54
- DEFAULT_DEV_HOST,
55
- DEV_DEFAULT_FILENAME,
56
- ESBUILD_TARGET,
57
- EXPORT_LOCALS_CONVENTION,
58
- NODE_MODULES_REGEX,
59
- PROD_DEFAULT_FILENAME,
60
- TEMPLATE_CONTENT,
61
- TEMP_DIR,
62
- THREAD_OPTIONS
63
- };
47
+ export { CSS_MODULES_LOCAL_IDENT_NAME, CSS_MODULES_REGEX, CSS_NAMED_EXPORT, DEFAULT_BROWSERSLIST, DEFAULT_DEV_HOST, DEV_DEFAULT_FILENAME, ESBUILD_TARGET, EXPORT_LOCALS_CONVENTION, LIGHTNINGCSS_TARGET, NODE_MODULES_REGEX, PROD_DEFAULT_FILENAME, TEMPLATE_CONTENT, TEMP_DIR, THREAD_OPTIONS };
@@ -1,111 +1,118 @@
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 createUnpack_exports = {};
29
- __export(createUnpack_exports, {
30
- createUnpack: () => createUnpack
1
+ "use strict";
2
+ var __webpack_require__ = {};
3
+ (()=>{
4
+ __webpack_require__.n = function(module) {
5
+ var getter = module && module.__esModule ? function() {
6
+ return module['default'];
7
+ } : function() {
8
+ return module;
9
+ };
10
+ __webpack_require__.d(getter, {
11
+ a: getter
12
+ });
13
+ return getter;
14
+ };
15
+ })();
16
+ (()=>{
17
+ __webpack_require__.d = function(exports1, definition) {
18
+ for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
19
+ enumerable: true,
20
+ get: definition[key]
21
+ });
22
+ };
23
+ })();
24
+ (()=>{
25
+ __webpack_require__.o = function(obj, prop) {
26
+ return Object.prototype.hasOwnProperty.call(obj, prop);
27
+ };
28
+ })();
29
+ (()=>{
30
+ __webpack_require__.r = function(exports1) {
31
+ if ('undefined' != typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
32
+ value: 'Module'
33
+ });
34
+ Object.defineProperty(exports1, '__esModule', {
35
+ value: true
36
+ });
37
+ };
38
+ })();
39
+ var __webpack_exports__ = {};
40
+ __webpack_require__.r(__webpack_exports__);
41
+ __webpack_require__.d(__webpack_exports__, {
42
+ createUnpack: ()=>createUnpack
31
43
  });
32
- module.exports = __toCommonJS(createUnpack_exports);
33
- var import_colors = __toESM(require("./colors.cjs"));
34
- var import_plugin = require("./plugin.cjs");
35
- var import_run = require("./run/index.cjs");
36
- var import_utils = require("./utils.cjs");
44
+ const external_colors_cjs_namespaceObject = require("./colors.cjs");
45
+ var external_colors_cjs_default = /*#__PURE__*/ __webpack_require__.n(external_colors_cjs_namespaceObject);
46
+ const external_plugin_cjs_namespaceObject = require("./plugin.cjs");
47
+ const index_cjs_namespaceObject = require("./run/index.cjs");
48
+ const external_utils_cjs_namespaceObject = require("./utils.cjs");
37
49
  function createUnpack() {
38
- const resolveConfig = async (unpackConfig) => {
39
- const defaultConfig = {
40
- bundler: "rspack",
41
- root: process.cwd(),
42
- build: {
43
- outDir: "dist",
44
- minify: (0, import_utils.isProd)(),
45
- sourceMap: (0, import_utils.isProd)() ? false : "cheap-module-source-map",
46
- parallel: !(0, import_utils.isDevServer)(),
47
- filenameHash: true,
48
- typeCheck: true
49
- },
50
- dev: {
51
- lazyCompilation: true
52
- },
53
- server: {
54
- port: 3e3
55
- },
56
- html: {
57
- mountId: "root"
58
- },
59
- css: {
60
- modules: true,
61
- transformer: "postcss",
62
- sourceMap: false
63
- },
64
- performance: {
65
- chunkSplit: {
66
- strategy: "split-by-experience"
67
- }
68
- }
50
+ const resolveConfig = async (unpackConfig)=>{
51
+ const defaultConfig = {
52
+ bundler: 'rspack',
53
+ root: process.cwd(),
54
+ build: {
55
+ outDir: 'dist',
56
+ minify: (0, external_utils_cjs_namespaceObject.isProd)(),
57
+ sourceMap: (0, external_utils_cjs_namespaceObject.isProd)() ? false : 'cheap-module-source-map',
58
+ parallel: !(0, external_utils_cjs_namespaceObject.isDevServer)(),
59
+ filenameHash: true,
60
+ typeCheck: true
61
+ },
62
+ dev: {
63
+ lazyCompilation: true
64
+ },
65
+ server: {
66
+ port: 3000
67
+ },
68
+ html: {
69
+ mountId: 'root'
70
+ },
71
+ css: {
72
+ modules: true,
73
+ transformer: 'postcss',
74
+ sourceMap: false
75
+ },
76
+ performance: {
77
+ chunkSplit: {
78
+ strategy: 'split-by-experience'
79
+ }
80
+ }
81
+ };
82
+ let { plugins, bundlerConfig, ...rest } = (0, external_utils_cjs_namespaceObject.mergeConfig)(defaultConfig, unpackConfig);
83
+ for (const plugin of (0, external_plugin_cjs_namespaceObject.getNormalizedPluginsByHook)('config', plugins))rest = await plugin.config(rest, {
84
+ mergeConfig: external_utils_cjs_namespaceObject.mergeConfig
85
+ });
86
+ return {
87
+ ...rest,
88
+ plugins,
89
+ bundlerConfig
90
+ };
69
91
  };
70
- let { plugins, bundlerConfig, ...rest } = (0, import_utils.mergeConfig)(defaultConfig, unpackConfig);
71
- for (const plugin of (0, import_plugin.getNormalizedPluginsByHook)("config", plugins)) {
72
- rest = await plugin.config(rest, { mergeConfig: import_utils.mergeConfig });
73
- }
74
92
  return {
75
- ...rest,
76
- plugins,
77
- bundlerConfig
93
+ build: async (unpackConfig)=>{
94
+ (0, external_utils_cjs_namespaceObject.setNodeEnv)('production');
95
+ console.log(external_colors_cjs_default().rainbow("unpack v1.7.7"), external_colors_cjs_default().green('building for production...'));
96
+ const config = await resolveConfig(unpackConfig);
97
+ (0, index_cjs_namespaceObject.bundlerBuild)(config);
98
+ },
99
+ serve: async (unpackConfig)=>{
100
+ global.__unpack_start_time = performance.now();
101
+ (0, external_utils_cjs_namespaceObject.setNodeEnv)('development');
102
+ (0, external_utils_cjs_namespaceObject.setDevServer)(true);
103
+ const config = await resolveConfig(unpackConfig);
104
+ (0, index_cjs_namespaceObject.bundlerDev)(config);
105
+ },
106
+ watch: async (unpackConfig)=>{
107
+ (0, external_utils_cjs_namespaceObject.setNodeEnv)('development');
108
+ console.log(external_colors_cjs_default().rainbow("unpack v1.7.7"), external_colors_cjs_default().green('building for development...'));
109
+ const config = await resolveConfig(unpackConfig);
110
+ (0, index_cjs_namespaceObject.bundlerBuild)(config);
111
+ }
78
112
  };
79
- };
80
- return {
81
- build: async (unpackConfig) => {
82
- (0, import_utils.setNodeEnv)("production");
83
- console.log(
84
- import_colors.default.rainbow(`unpack v${"1.7.5"}`),
85
- import_colors.default.green("building for production...")
86
- );
87
- const config = await resolveConfig(unpackConfig);
88
- (0, import_run.bundlerBuild)(config);
89
- },
90
- serve: async (unpackConfig) => {
91
- global.__unpack_start_time = performance.now();
92
- (0, import_utils.setNodeEnv)("development");
93
- (0, import_utils.setDevServer)(true);
94
- const config = await resolveConfig(unpackConfig);
95
- (0, import_run.bundlerDev)(config);
96
- },
97
- watch: async (unpackConfig) => {
98
- (0, import_utils.setNodeEnv)("development");
99
- console.log(
100
- import_colors.default.rainbow(`unpack v${"1.7.5"}`),
101
- import_colors.default.green("building for development...")
102
- );
103
- const config = await resolveConfig(unpackConfig);
104
- (0, import_run.bundlerBuild)(config);
105
- }
106
- };
107
113
  }
108
- // Annotate the CommonJS export names for ESM import in node:
109
- 0 && (module.exports = {
110
- createUnpack
114
+ var __webpack_export_target__ = exports;
115
+ for(var __webpack_i__ in __webpack_exports__)__webpack_export_target__[__webpack_i__] = __webpack_exports__[__webpack_i__];
116
+ if (__webpack_exports__.__esModule) Object.defineProperty(__webpack_export_target__, '__esModule', {
117
+ value: true
111
118
  });