@unpackjs/core 1.5.4 → 1.6.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (238) hide show
  1. package/bin/openChrome.applescript +94 -0
  2. package/compiled/chokidar/index.d.ts +327 -0
  3. package/compiled/chokidar/index.js +1773 -0
  4. package/compiled/chokidar/license +21 -0
  5. package/compiled/chokidar/package.json +1 -0
  6. package/compiled/commander/index.d.ts +971 -0
  7. package/compiled/commander/index.js +2190 -0
  8. package/compiled/commander/license +22 -0
  9. package/compiled/commander/package.json +1 -0
  10. package/compiled/css-loader/api.js +85 -0
  11. package/compiled/css-loader/getUrl.js +26 -0
  12. package/compiled/css-loader/index.d.ts +1 -0
  13. package/compiled/css-loader/index.js +8004 -0
  14. package/compiled/css-loader/license +20 -0
  15. package/compiled/css-loader/noSourceMaps.js +5 -0
  16. package/compiled/css-loader/package.json +1 -0
  17. package/compiled/css-loader/sourceMaps.js +16 -0
  18. package/compiled/fast-glob/index.d.ts +237 -0
  19. package/compiled/fast-glob/index.js +5726 -0
  20. package/compiled/fast-glob/license +21 -0
  21. package/compiled/fast-glob/package.json +1 -0
  22. package/compiled/less-loader/index.d.ts +1 -0
  23. package/compiled/less-loader/index.js +340 -0
  24. package/compiled/less-loader/license +20 -0
  25. package/compiled/less-loader/package.json +1 -0
  26. package/compiled/line-diff/index.d.ts +1 -0
  27. package/compiled/line-diff/index.js +160 -0
  28. package/compiled/line-diff/license +21 -0
  29. package/compiled/line-diff/package.json +1 -0
  30. package/compiled/log-update/index.d.ts +1 -0
  31. package/compiled/log-update/index.js +1970 -0
  32. package/compiled/log-update/package.json +1 -0
  33. package/compiled/portfinder/index.d.ts +64 -0
  34. package/compiled/portfinder/index.js +3401 -0
  35. package/compiled/portfinder/license +22 -0
  36. package/compiled/portfinder/package.json +1 -0
  37. package/compiled/postcss-loader/index.d.ts +1 -0
  38. package/compiled/postcss-loader/index.js +94945 -0
  39. package/compiled/postcss-loader/license +20 -0
  40. package/compiled/postcss-loader/package.json +1 -0
  41. package/compiled/sass-loader/index.d.ts +961 -0
  42. package/compiled/sass-loader/index.js +5610 -0
  43. package/compiled/sass-loader/index1.js +65 -0
  44. package/compiled/sass-loader/license +20 -0
  45. package/compiled/sass-loader/package.json +1 -0
  46. package/compiled/sass-loader/sass.node.js +12 -0
  47. package/compiled/semver/index.d.ts +1 -0
  48. package/compiled/semver/index.js +1940 -0
  49. package/compiled/semver/license +15 -0
  50. package/compiled/semver/package.json +1 -0
  51. package/compiled/style-loader/index.d.ts +1 -0
  52. package/compiled/style-loader/index.js +370 -0
  53. package/compiled/style-loader/license +20 -0
  54. package/compiled/style-loader/package.json +1 -0
  55. package/compiled/style-loader/runtime/injectStylesIntoLinkTag.js +29 -0
  56. package/compiled/style-loader/runtime/injectStylesIntoStyleTag.js +84 -0
  57. package/compiled/style-loader/runtime/insertBySelector.js +34 -0
  58. package/compiled/style-loader/runtime/insertStyleElement.js +10 -0
  59. package/compiled/style-loader/runtime/isEqualLocals.js +28 -0
  60. package/compiled/style-loader/runtime/isOldIE.js +17 -0
  61. package/compiled/style-loader/runtime/setAttributesWithAttributes.js +13 -0
  62. package/compiled/style-loader/runtime/setAttributesWithAttributesAndNonce.js +9 -0
  63. package/compiled/style-loader/runtime/setAttributesWithoutAttributes.js +10 -0
  64. package/compiled/style-loader/runtime/singletonStyleDomAPI.js +86 -0
  65. package/compiled/style-loader/runtime/styleDomAPI.js +61 -0
  66. package/compiled/style-loader/runtime/styleTagTransform.js +14 -0
  67. package/compiled/webpack-bundle-analyzer/index.d.ts +1 -0
  68. package/compiled/webpack-bundle-analyzer/index.js +13276 -0
  69. package/compiled/webpack-bundle-analyzer/license +20 -0
  70. package/compiled/webpack-bundle-analyzer/package.json +1 -0
  71. package/compiled/webpack-bundle-analyzer/public/viewer.js +16 -0
  72. package/compiled/webpack-bundle-analyzer/public/viewer.js.LICENSE.txt +10 -0
  73. package/compiled/webpack-merge/index.d.ts +31 -0
  74. package/compiled/webpack-merge/index.js +1200 -0
  75. package/compiled/webpack-merge/license +20 -0
  76. package/compiled/webpack-merge/package.json +1 -0
  77. package/dist/bundleRequire.cjs +200 -0
  78. package/dist/bundleRequire.d.ts +5 -0
  79. package/dist/bundleRequire.d.ts.map +1 -0
  80. package/dist/bundleRequire.js +173 -0
  81. package/dist/bundler-config/chunkSplit.cjs +151 -0
  82. package/dist/bundler-config/chunkSplit.d.ts +6 -0
  83. package/dist/bundler-config/chunkSplit.d.ts.map +1 -0
  84. package/dist/bundler-config/chunkSplit.js +127 -0
  85. package/dist/bundler-config/css.cjs +167 -0
  86. package/dist/bundler-config/css.d.ts +6 -0
  87. package/dist/bundler-config/css.d.ts.map +1 -0
  88. package/dist/bundler-config/css.js +158 -0
  89. package/dist/bundler-config/experimentCss.cjs +166 -0
  90. package/dist/bundler-config/experimentCss.d.ts +6 -0
  91. package/dist/bundler-config/experimentCss.d.ts.map +1 -0
  92. package/dist/bundler-config/experimentCss.js +157 -0
  93. package/dist/bundler-config/helper.cjs +83 -0
  94. package/dist/bundler-config/helper.d.ts +8 -0
  95. package/dist/bundler-config/helper.d.ts.map +1 -0
  96. package/dist/bundler-config/helper.js +58 -0
  97. package/dist/bundler-config/index.cjs +204 -0
  98. package/dist/bundler-config/index.d.ts +3 -0
  99. package/dist/bundler-config/index.d.ts.map +1 -0
  100. package/dist/bundler-config/index.js +180 -0
  101. package/dist/colors.cjs +60 -0
  102. package/dist/colors.d.ts +6 -0
  103. package/dist/colors.d.ts.map +1 -0
  104. package/dist/colors.js +40 -0
  105. package/dist/{config/index.cjs → config.cjs} +21 -47
  106. package/dist/{config/index.d.ts → config.d.ts} +4 -3
  107. package/dist/config.d.ts.map +1 -0
  108. package/dist/{config/index.js → config.js} +18 -52
  109. package/dist/constants.cjs +86 -0
  110. package/dist/constants.d.ts +25 -0
  111. package/dist/constants.d.ts.map +1 -0
  112. package/dist/constants.js +61 -0
  113. package/dist/createUnpack.cjs +102 -0
  114. package/dist/createUnpack.d.ts +7 -0
  115. package/dist/createUnpack.d.ts.map +1 -0
  116. package/dist/createUnpack.js +78 -0
  117. package/dist/index.cjs +26 -48
  118. package/dist/index.d.ts +7 -7
  119. package/dist/index.d.ts.map +1 -1
  120. package/dist/index.js +8 -52
  121. package/dist/lightningcss/cache.cjs +36 -0
  122. package/dist/lightningcss/cache.d.ts +2 -0
  123. package/dist/lightningcss/cache.d.ts.map +1 -0
  124. package/dist/lightningcss/cache.js +22 -0
  125. package/dist/lightningcss/index.cjs +21 -0
  126. package/dist/lightningcss/index.d.ts +2 -0
  127. package/dist/lightningcss/index.d.ts.map +1 -0
  128. package/dist/lightningcss/index.js +10 -0
  129. package/dist/lightningcss/loader.cjs +56 -0
  130. package/dist/lightningcss/loader.d.ts +5 -0
  131. package/dist/lightningcss/loader.d.ts.map +1 -0
  132. package/dist/lightningcss/loader.js +36 -0
  133. package/dist/lightningcss/minimizer.cjs +114 -0
  134. package/dist/lightningcss/minimizer.d.ts +11 -0
  135. package/dist/lightningcss/minimizer.d.ts.map +1 -0
  136. package/dist/lightningcss/minimizer.js +90 -0
  137. package/dist/logger.cjs +103 -0
  138. package/dist/logger.d.ts +3 -0
  139. package/dist/logger.d.ts.map +1 -0
  140. package/dist/logger.js +79 -0
  141. package/dist/openBrowser.cjs +85 -0
  142. package/dist/openBrowser.d.ts +2 -0
  143. package/dist/openBrowser.d.ts.map +1 -0
  144. package/dist/openBrowser.js +61 -0
  145. package/dist/plugin-progress/rspack.cjs +74 -0
  146. package/dist/plugin-progress/rspack.d.ts +9 -0
  147. package/dist/plugin-progress/rspack.d.ts.map +1 -0
  148. package/dist/plugin-progress/rspack.js +50 -0
  149. package/dist/plugin-progress/webpack.cjs +84 -0
  150. package/dist/plugin-progress/webpack.d.ts +9 -0
  151. package/dist/plugin-progress/webpack.d.ts.map +1 -0
  152. package/dist/plugin-progress/webpack.js +60 -0
  153. package/dist/plugin.cjs +33 -0
  154. package/dist/plugin.d.ts +3 -0
  155. package/dist/plugin.d.ts.map +1 -0
  156. package/dist/plugin.js +19 -0
  157. package/dist/progressBar.cjs +70 -0
  158. package/dist/progressBar.d.ts +14 -0
  159. package/dist/progressBar.d.ts.map +1 -0
  160. package/dist/progressBar.js +46 -0
  161. package/dist/reporter.cjs +133 -0
  162. package/dist/reporter.d.ts +9 -0
  163. package/dist/reporter.d.ts.map +1 -0
  164. package/dist/reporter.js +109 -0
  165. package/dist/run/build.cjs +77 -0
  166. package/dist/run/build.d.ts +3 -0
  167. package/dist/run/build.d.ts.map +1 -0
  168. package/dist/run/build.js +53 -0
  169. package/dist/run/dev.cjs +107 -0
  170. package/dist/run/dev.d.ts +3 -0
  171. package/dist/run/dev.d.ts.map +1 -0
  172. package/dist/run/dev.js +83 -0
  173. package/dist/run/index.cjs +23 -0
  174. package/dist/run/index.d.ts +3 -0
  175. package/dist/run/index.d.ts.map +1 -0
  176. package/dist/run/index.js +11 -0
  177. package/dist/thread-loader/WorkerError.cjs +41 -0
  178. package/dist/thread-loader/WorkerError.js +31 -0
  179. package/dist/thread-loader/WorkerPool.cjs +407 -0
  180. package/dist/thread-loader/WorkerPool.js +387 -0
  181. package/dist/thread-loader/index.cjs +100 -0
  182. package/dist/thread-loader/index.js +85 -0
  183. package/dist/thread-loader/readBuffer.cjs +55 -0
  184. package/dist/thread-loader/readBuffer.js +45 -0
  185. package/dist/thread-loader/serializer.cjs +46 -0
  186. package/dist/thread-loader/serializer.js +31 -0
  187. package/dist/thread-loader/utils.cjs +84 -0
  188. package/dist/thread-loader/utils.js +60 -0
  189. package/dist/thread-loader/worker.cjs +377 -0
  190. package/dist/thread-loader/worker.js +382 -0
  191. package/dist/thread-loader/workerPools.cjs +57 -0
  192. package/dist/thread-loader/workerPools.js +33 -0
  193. package/dist/typed-css-modules/index.cjs +21 -0
  194. package/dist/typed-css-modules/index.d.ts +2 -0
  195. package/dist/typed-css-modules/index.d.ts.map +1 -0
  196. package/dist/typed-css-modules/index.js +10 -0
  197. package/dist/typed-css-modules/loader.cjs +195 -0
  198. package/dist/typed-css-modules/loader.d.ts +10 -0
  199. package/dist/typed-css-modules/loader.d.ts.map +1 -0
  200. package/dist/typed-css-modules/loader.js +170 -0
  201. package/dist/typed-css-modules/plugin.cjs +96 -0
  202. package/dist/typed-css-modules/plugin.d.ts +16 -0
  203. package/dist/typed-css-modules/plugin.d.ts.map +1 -0
  204. package/dist/typed-css-modules/plugin.js +72 -0
  205. package/dist/typed-css-modules/utils.cjs +45 -0
  206. package/dist/typed-css-modules/utils.d.ts +6 -0
  207. package/dist/typed-css-modules/utils.d.ts.map +1 -0
  208. package/dist/typed-css-modules/utils.js +31 -0
  209. package/dist/types/chunkSplit.cjs +15 -0
  210. package/dist/types/chunkSplit.d.ts +35 -0
  211. package/dist/types/chunkSplit.d.ts.map +1 -0
  212. package/dist/types/chunkSplit.js +9 -0
  213. package/dist/types/config.cjs +15 -0
  214. package/dist/types/config.d.ts +176 -0
  215. package/dist/types/config.d.ts.map +1 -0
  216. package/dist/types/config.js +9 -0
  217. package/dist/types/index.cjs +29 -0
  218. package/dist/types/index.d.ts +16 -0
  219. package/dist/types/index.d.ts.map +1 -0
  220. package/dist/types/index.js +14 -0
  221. package/dist/types/lightningcss.cjs +15 -0
  222. package/dist/types/lightningcss.d.ts +11 -0
  223. package/dist/types/lightningcss.d.ts.map +1 -0
  224. package/dist/types/lightningcss.js +9 -0
  225. package/dist/types/logger.cjs +35 -0
  226. package/dist/types/logger.d.ts +16 -0
  227. package/dist/types/logger.d.ts.map +1 -0
  228. package/dist/types/logger.js +21 -0
  229. package/dist/types/plugin.cjs +15 -0
  230. package/dist/types/plugin.d.ts +18 -0
  231. package/dist/types/plugin.d.ts.map +1 -0
  232. package/dist/types/plugin.js +9 -0
  233. package/dist/utils.cjs +286 -0
  234. package/dist/utils.d.ts +43 -0
  235. package/dist/utils.d.ts.map +1 -0
  236. package/dist/utils.js +235 -0
  237. package/package.json +95 -6
  238. package/dist/config/index.d.ts.map +0 -1
@@ -33,19 +33,26 @@ __export(config_exports, {
33
33
  module.exports = __toCommonJS(config_exports);
34
34
  var import_node_fs = __toESM(require("node:fs"));
35
35
  var import_node_path = require("node:path");
36
- var import_shared = require("@unpackjs/shared");
37
- var import_plugin_react = require("@unpackjs/plugin-react");
38
- const { merge } = require("@unpackjs/shared/webpack-merge");
36
+ var import_bundleRequire = require("./bundleRequire.cjs");
37
+ var import_logger = require("./logger.cjs");
38
+ var import_utils = require("./utils.cjs");
39
39
  async function loadConfig({
40
- cliOptions
40
+ cliOptions,
41
+ command
41
42
  }) {
43
+ if (command === "build") {
44
+ (0, import_utils.setNodeEnv)(cliOptions?.watch ? "development" : "production");
45
+ } else {
46
+ (0, import_utils.setNodeEnv)("development");
47
+ (0, import_utils.setDevServer)(true);
48
+ }
42
49
  const configPath = resolveConfigPath(process.cwd(), cliOptions?.config);
43
50
  let userConfig = {};
44
51
  if (configPath) {
45
- userConfig = await (0, import_shared.bundleRequire)(configPath);
52
+ userConfig = await (0, import_bundleRequire.bundleRequire)(configPath);
46
53
  if (typeof userConfig === "function") {
47
54
  const params = {
48
- env: (0, import_shared.getNodeEnv)(),
55
+ env: (0, import_utils.getNodeEnv)(),
49
56
  command: process.argv[2]
50
57
  };
51
58
  userConfig = await userConfig(params);
@@ -54,46 +61,13 @@ async function loadConfig({
54
61
  }
55
62
  }
56
63
  }
57
- const parsedUserConfig = userConfig;
58
- const defaultConfig = {
59
- bundler: "rspack",
60
- root: process.cwd(),
61
- build: {
62
- outDir: "dist",
63
- minify: (0, import_shared.isProd)(),
64
- sourceMap: (0, import_shared.isProd)() ? false : "cheap-module-source-map",
65
- parallel: true,
66
- filenameHash: true,
67
- cache: (0, import_shared.isDev)()
68
- },
69
- server: {
70
- port: 3e3
71
- },
72
- html: {
73
- mountId: "root"
74
- },
75
- css: {
76
- modules: true,
77
- transformer: "postcss",
78
- sourceMap: false
79
- },
80
- plugins: [(0, import_plugin_react.pluginReact)({ clickToComponent: true })]
81
- };
82
- if (cliOptions.port)
83
- (0, import_shared.setValueByPath)(parsedUserConfig, ["server", "port"], cliOptions.port);
84
- if (cliOptions.open)
85
- (0, import_shared.setValueByPath)(parsedUserConfig, ["server", "open"], cliOptions.open);
86
- if (cliOptions.analyze)
87
- (0, import_shared.setValueByPath)(parsedUserConfig, ["performance", "bundleAnalyze"], cliOptions.analyze);
88
- let { plugins, bundlerConfig, ...rest } = merge(defaultConfig, parsedUserConfig);
89
- for (const plugin of (0, import_shared.getNormalizedPluginsByHook)("config", plugins)) {
90
- rest = await plugin.config(rest, { mergeConfig: merge });
91
- }
92
- return {
93
- ...rest,
94
- plugins,
95
- bundlerConfig
96
- };
64
+ if (cliOptions?.port)
65
+ (0, import_utils.setValueByPath)(userConfig, ["server", "port"], cliOptions.port);
66
+ if (cliOptions?.open)
67
+ (0, import_utils.setValueByPath)(userConfig, ["server", "open"], cliOptions.open);
68
+ if (cliOptions?.analyze)
69
+ (0, import_utils.setValueByPath)(userConfig, ["performance", "bundleAnalyze"], cliOptions.analyze);
70
+ return userConfig;
97
71
  }
98
72
  function defineConfig(config) {
99
73
  return config;
@@ -104,7 +78,7 @@ function resolveConfigPath(root, customConfig) {
104
78
  if (import_node_fs.default.existsSync(customConfigPath)) {
105
79
  return customConfigPath;
106
80
  }
107
- import_shared.logger.warn(`Could not find config file: ${customConfigPath}`);
81
+ import_logger.logger.warn(`Could not find config file: ${customConfigPath}`);
108
82
  }
109
83
  const CONFIG_FILES = [
110
84
  "unpack.config.ts",
@@ -1,6 +1,7 @@
1
- import { type CliOptions, type Command, type NodeEnv, type UnpackConfig } from '@unpackjs/shared';
2
- export declare function loadConfig({ cliOptions, }: {
1
+ import type { CliOptions, Command, NodeEnv, UnpackConfig } from './types/index';
2
+ export declare function loadConfig({ cliOptions, command, }: {
3
3
  cliOptions?: CliOptions;
4
+ command: Command;
4
5
  }): Promise<UnpackConfig>;
5
6
  export type ConfigParams = {
6
7
  env: NodeEnv;
@@ -13,4 +14,4 @@ export declare function defineConfig(config: UnpackConfig): UnpackConfig;
13
14
  export declare function defineConfig(config: UnpackConfigSyncFn): UnpackConfigSyncFn;
14
15
  export declare function defineConfig(config: UnpackConfigAsyncFn): UnpackConfigAsyncFn;
15
16
  export declare function defineConfig(config: UnpackConfigExport): UnpackConfigExport;
16
- //# sourceMappingURL=index.d.ts.map
17
+ //# sourceMappingURL=config.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,UAAU,EAAE,OAAO,EAAE,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAA;AAKjF,wBAAsB,UAAU,CAAC,EAC/B,UAAU,EACV,OAAO,GACR,EAAE;IACD,UAAU,CAAC,EAAE,UAAU,CAAA;IACvB,OAAO,EAAE,OAAO,CAAA;CACjB,GAAG,OAAO,CAAC,YAAY,CAAC,CA2BxB;AAED,MAAM,MAAM,YAAY,GAAG;IACzB,GAAG,EAAE,OAAO,CAAA;IACZ,OAAO,EAAE,OAAO,CAAA;CACjB,CAAA;AAED,MAAM,MAAM,mBAAmB,GAAG,CAAC,MAAM,EAAE,YAAY,KAAK,OAAO,CAAC,YAAY,CAAC,CAAA;AACjF,MAAM,MAAM,kBAAkB,GAAG,CAAC,MAAM,EAAE,YAAY,KAAK,YAAY,CAAA;AACvE,MAAM,MAAM,kBAAkB,GAAG,YAAY,GAAG,kBAAkB,GAAG,mBAAmB,CAAA;AACxF,wBAAgB,YAAY,CAAC,MAAM,EAAE,YAAY,GAAG,YAAY,CAAA;AAChE,wBAAgB,YAAY,CAAC,MAAM,EAAE,kBAAkB,GAAG,kBAAkB,CAAA;AAC5E,wBAAgB,YAAY,CAAC,MAAM,EAAE,mBAAmB,GAAG,mBAAmB,CAAA;AAC9E,wBAAgB,YAAY,CAAC,MAAM,EAAE,kBAAkB,GAAG,kBAAkB,CAAA"}
@@ -9,20 +9,19 @@ var __dirname = /* @__PURE__ */ getDirname();
9
9
  var __filename = /* @__PURE__ */ getFilename();
10
10
  import fs from "node:fs";
11
11
  import { isAbsolute, join } from "node:path";
12
- import {
13
- bundleRequire,
14
- getNodeEnv,
15
- getNormalizedPluginsByHook,
16
- isDev,
17
- isProd,
18
- logger,
19
- setValueByPath
20
- } from "@unpackjs/shared";
21
- const { merge } = require("@unpackjs/shared/webpack-merge");
22
- import { pluginReact } from "@unpackjs/plugin-react";
12
+ import { bundleRequire } from "./bundleRequire.js";
13
+ import { logger } from "./logger.js";
14
+ import { getNodeEnv, setDevServer, setNodeEnv, setValueByPath } from "./utils.js";
23
15
  async function loadConfig({
24
- cliOptions
16
+ cliOptions,
17
+ command
25
18
  }) {
19
+ if (command === "build") {
20
+ setNodeEnv(cliOptions?.watch ? "development" : "production");
21
+ } else {
22
+ setNodeEnv("development");
23
+ setDevServer(true);
24
+ }
26
25
  const configPath = resolveConfigPath(process.cwd(), cliOptions?.config);
27
26
  let userConfig = {};
28
27
  if (configPath) {
@@ -38,46 +37,13 @@ async function loadConfig({
38
37
  }
39
38
  }
40
39
  }
41
- const parsedUserConfig = userConfig;
42
- const defaultConfig = {
43
- bundler: "rspack",
44
- root: process.cwd(),
45
- build: {
46
- outDir: "dist",
47
- minify: isProd(),
48
- sourceMap: isProd() ? false : "cheap-module-source-map",
49
- parallel: true,
50
- filenameHash: true,
51
- cache: isDev()
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
- plugins: [pluginReact({ clickToComponent: true })]
65
- };
66
- if (cliOptions.port)
67
- setValueByPath(parsedUserConfig, ["server", "port"], cliOptions.port);
68
- if (cliOptions.open)
69
- setValueByPath(parsedUserConfig, ["server", "open"], cliOptions.open);
70
- if (cliOptions.analyze)
71
- setValueByPath(parsedUserConfig, ["performance", "bundleAnalyze"], cliOptions.analyze);
72
- let { plugins, bundlerConfig, ...rest } = merge(defaultConfig, parsedUserConfig);
73
- for (const plugin of getNormalizedPluginsByHook("config", plugins)) {
74
- rest = await plugin.config(rest, { mergeConfig: merge });
75
- }
76
- return {
77
- ...rest,
78
- plugins,
79
- bundlerConfig
80
- };
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;
81
47
  }
82
48
  function defineConfig(config) {
83
49
  return config;
@@ -0,0 +1,86 @@
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
+ EXPORT_LOCALS_CONVENTION: () => EXPORT_LOCALS_CONVENTION,
27
+ NODE_MODULES_REGEX: () => NODE_MODULES_REGEX,
28
+ PROD_DEFAULT_FILENAME: () => PROD_DEFAULT_FILENAME,
29
+ TEMPLATE_CONTENT: () => TEMPLATE_CONTENT,
30
+ TEMP_DIR: () => TEMP_DIR,
31
+ THREAD_OPTIONS: () => THREAD_OPTIONS
32
+ });
33
+ module.exports = __toCommonJS(constants_exports);
34
+ const CSS_MODULES_LOCAL_IDENT_NAME = "[path][name]__[local]--[hash:5]";
35
+ const CSS_MODULES_REGEX = /\.module\.\w+$/i;
36
+ const DEV_DEFAULT_FILENAME = {
37
+ js: "js/[name].js",
38
+ css: "css/[name].css"
39
+ };
40
+ const PROD_DEFAULT_FILENAME = {
41
+ js: "js/[name]_[contenthash:8].js",
42
+ css: "css/[name]_[contenthash:8].css"
43
+ };
44
+ const EXPORT_LOCALS_CONVENTION = "camel-case-only";
45
+ const TEMP_DIR = "node_modules/.unpack";
46
+ const NODE_MODULES_REGEX = /node_modules[\\/]/;
47
+ const CSS_NAMED_EXPORT = false;
48
+ const THREAD_OPTIONS = {
49
+ workers: 2
50
+ };
51
+ const DEFAULT_DEV_HOST = "0.0.0.0";
52
+ const DEFAULT_BROWSERSLIST = ["chrome 87", "edge 88", "firefox 78", "safari 14"];
53
+ const TEMPLATE_CONTENT = ({ title = "", headTag = "", mountId }) => {
54
+ return `<!DOCTYPE html>
55
+ <html lang="en">
56
+
57
+ <head>
58
+ <meta charset="UTF-8" />
59
+ <meta name="viewport" content="width=device-width, initial-scale=1.0" />
60
+ <title>
61
+ ${title}
62
+ </title>
63
+ ${headTag}
64
+ </head>
65
+
66
+ <body>
67
+ <div id="${mountId}"></div>
68
+ </body>
69
+
70
+ </html>`;
71
+ };
72
+ // Annotate the CommonJS export names for ESM import in node:
73
+ 0 && (module.exports = {
74
+ CSS_MODULES_LOCAL_IDENT_NAME,
75
+ CSS_MODULES_REGEX,
76
+ CSS_NAMED_EXPORT,
77
+ DEFAULT_BROWSERSLIST,
78
+ DEFAULT_DEV_HOST,
79
+ DEV_DEFAULT_FILENAME,
80
+ EXPORT_LOCALS_CONVENTION,
81
+ NODE_MODULES_REGEX,
82
+ PROD_DEFAULT_FILENAME,
83
+ TEMPLATE_CONTENT,
84
+ TEMP_DIR,
85
+ THREAD_OPTIONS
86
+ });
@@ -0,0 +1,25 @@
1
+ export declare const CSS_MODULES_LOCAL_IDENT_NAME = "[path][name]__[local]--[hash:5]";
2
+ export declare const CSS_MODULES_REGEX: RegExp;
3
+ export declare const DEV_DEFAULT_FILENAME: {
4
+ js: string;
5
+ css: string;
6
+ };
7
+ export declare const PROD_DEFAULT_FILENAME: {
8
+ js: string;
9
+ css: string;
10
+ };
11
+ export declare const EXPORT_LOCALS_CONVENTION = "camel-case-only";
12
+ export declare const TEMP_DIR = "node_modules/.unpack";
13
+ export declare const NODE_MODULES_REGEX: RegExp;
14
+ export declare const CSS_NAMED_EXPORT = false;
15
+ export declare const THREAD_OPTIONS: {
16
+ workers: number;
17
+ };
18
+ export declare const DEFAULT_DEV_HOST = "0.0.0.0";
19
+ export declare const DEFAULT_BROWSERSLIST: string[];
20
+ export declare const TEMPLATE_CONTENT: ({ title, headTag, mountId }: {
21
+ title?: string;
22
+ headTag?: string;
23
+ mountId: any;
24
+ }) => string;
25
+ //# sourceMappingURL=constants.d.ts.map
@@ -0,0 +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,QAAsB,CAAA;AACrD,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,gBAAgB;;;;YAkB5B,CAAA"}
@@ -0,0 +1,61 @@
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]";
11
+ const CSS_MODULES_REGEX = /\.module\.\w+$/i;
12
+ const DEV_DEFAULT_FILENAME = {
13
+ js: "js/[name].js",
14
+ css: "css/[name].css"
15
+ };
16
+ const PROD_DEFAULT_FILENAME = {
17
+ js: "js/[name]_[contenthash:8].js",
18
+ css: "css/[name]_[contenthash:8].css"
19
+ };
20
+ const EXPORT_LOCALS_CONVENTION = "camel-case-only";
21
+ const TEMP_DIR = "node_modules/.unpack";
22
+ const NODE_MODULES_REGEX = /node_modules[\\/]/;
23
+ const CSS_NAMED_EXPORT = false;
24
+ const THREAD_OPTIONS = {
25
+ workers: 2
26
+ };
27
+ const DEFAULT_DEV_HOST = "0.0.0.0";
28
+ const DEFAULT_BROWSERSLIST = ["chrome 87", "edge 88", "firefox 78", "safari 14"];
29
+ const TEMPLATE_CONTENT = ({ title = "", headTag = "", mountId }) => {
30
+ return `<!DOCTYPE html>
31
+ <html lang="en">
32
+
33
+ <head>
34
+ <meta charset="UTF-8" />
35
+ <meta name="viewport" content="width=device-width, initial-scale=1.0" />
36
+ <title>
37
+ ${title}
38
+ </title>
39
+ ${headTag}
40
+ </head>
41
+
42
+ <body>
43
+ <div id="${mountId}"></div>
44
+ </body>
45
+
46
+ </html>`;
47
+ };
48
+ export {
49
+ CSS_MODULES_LOCAL_IDENT_NAME,
50
+ CSS_MODULES_REGEX,
51
+ CSS_NAMED_EXPORT,
52
+ DEFAULT_BROWSERSLIST,
53
+ DEFAULT_DEV_HOST,
54
+ DEV_DEFAULT_FILENAME,
55
+ EXPORT_LOCALS_CONVENTION,
56
+ NODE_MODULES_REGEX,
57
+ PROD_DEFAULT_FILENAME,
58
+ TEMPLATE_CONTENT,
59
+ TEMP_DIR,
60
+ THREAD_OPTIONS
61
+ };
@@ -0,0 +1,102 @@
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
31
+ });
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");
37
+ 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: true,
47
+ filenameHash: true,
48
+ cache: (0, import_utils.isDev)()
49
+ },
50
+ server: {
51
+ port: 3e3
52
+ },
53
+ html: {
54
+ mountId: "root"
55
+ },
56
+ css: {
57
+ modules: true,
58
+ transformer: "postcss",
59
+ sourceMap: false
60
+ }
61
+ };
62
+ let { plugins, bundlerConfig, ...rest } = (0, import_utils.mergeConfig)(defaultConfig, unpackConfig);
63
+ for (const plugin of (0, import_plugin.getNormalizedPluginsByHook)("config", plugins)) {
64
+ rest = await plugin.config(rest, { mergeConfig: import_utils.mergeConfig });
65
+ }
66
+ return {
67
+ ...rest,
68
+ plugins,
69
+ bundlerConfig
70
+ };
71
+ };
72
+ return {
73
+ build: async (unpackConfig) => {
74
+ (0, import_utils.setNodeEnv)("production");
75
+ console.log(
76
+ import_colors.default.rainbow(`unpack v${"1.6.1"}`),
77
+ import_colors.default.green("building for production...")
78
+ );
79
+ const config = await resolveConfig(unpackConfig);
80
+ (0, import_run.bundlerBuild)(config);
81
+ },
82
+ serve: async (unpackConfig) => {
83
+ (0, import_utils.setNodeEnv)("development");
84
+ (0, import_utils.setDevServer)(true);
85
+ const config = await resolveConfig(unpackConfig);
86
+ (0, import_run.bundlerDev)(config);
87
+ },
88
+ watch: async (unpackConfig) => {
89
+ (0, import_utils.setNodeEnv)("development");
90
+ console.log(
91
+ import_colors.default.rainbow(`unpack v${"1.6.1"}`),
92
+ import_colors.default.green("building for development...")
93
+ );
94
+ const config = await resolveConfig(unpackConfig);
95
+ (0, import_run.bundlerBuild)(config);
96
+ }
97
+ };
98
+ }
99
+ // Annotate the CommonJS export names for ESM import in node:
100
+ 0 && (module.exports = {
101
+ createUnpack
102
+ });
@@ -0,0 +1,7 @@
1
+ import type { UnpackConfig } from './types/index';
2
+ export declare function createUnpack(): {
3
+ build: (unpackConfig: UnpackConfig) => Promise<void>;
4
+ serve: (unpackConfig: UnpackConfig) => Promise<void>;
5
+ watch: (unpackConfig: UnpackConfig) => Promise<void>;
6
+ };
7
+ //# sourceMappingURL=createUnpack.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"createUnpack.d.ts","sourceRoot":"","sources":["../src/createUnpack.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,eAAe,CAAA;AAGjD,wBAAgB,YAAY;0BAoCI,YAAY;0BASZ,YAAY;0BAMZ,YAAY;EAU3C"}
@@ -0,0 +1,78 @@
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 colors from "./colors.js";
11
+ import { getNormalizedPluginsByHook } from "./plugin.js";
12
+ import { bundlerBuild, bundlerDev } from "./run/index.js";
13
+ import { isDev, isProd, mergeConfig, setDevServer, setNodeEnv } from "./utils.js";
14
+ function createUnpack() {
15
+ const resolveConfig = async (unpackConfig) => {
16
+ const defaultConfig = {
17
+ bundler: "rspack",
18
+ root: process.cwd(),
19
+ build: {
20
+ outDir: "dist",
21
+ minify: isProd(),
22
+ sourceMap: isProd() ? false : "cheap-module-source-map",
23
+ parallel: true,
24
+ filenameHash: true,
25
+ cache: isDev()
26
+ },
27
+ server: {
28
+ port: 3e3
29
+ },
30
+ html: {
31
+ mountId: "root"
32
+ },
33
+ css: {
34
+ modules: true,
35
+ transformer: "postcss",
36
+ sourceMap: false
37
+ }
38
+ };
39
+ let { plugins, bundlerConfig, ...rest } = mergeConfig(defaultConfig, unpackConfig);
40
+ for (const plugin of getNormalizedPluginsByHook("config", plugins)) {
41
+ rest = await plugin.config(rest, { mergeConfig });
42
+ }
43
+ return {
44
+ ...rest,
45
+ plugins,
46
+ bundlerConfig
47
+ };
48
+ };
49
+ return {
50
+ build: async (unpackConfig) => {
51
+ setNodeEnv("production");
52
+ console.log(
53
+ colors.rainbow(`unpack v${"1.6.1"}`),
54
+ colors.green("building for production...")
55
+ );
56
+ const config = await resolveConfig(unpackConfig);
57
+ bundlerBuild(config);
58
+ },
59
+ serve: async (unpackConfig) => {
60
+ setNodeEnv("development");
61
+ setDevServer(true);
62
+ const config = await resolveConfig(unpackConfig);
63
+ bundlerDev(config);
64
+ },
65
+ watch: async (unpackConfig) => {
66
+ setNodeEnv("development");
67
+ console.log(
68
+ colors.rainbow(`unpack v${"1.6.1"}`),
69
+ colors.green("building for development...")
70
+ );
71
+ const config = await resolveConfig(unpackConfig);
72
+ bundlerBuild(config);
73
+ }
74
+ };
75
+ }
76
+ export {
77
+ createUnpack
78
+ };
package/dist/index.cjs CHANGED
@@ -1,6 +1,8 @@
1
+ var __create = Object.create;
1
2
  var __defProp = Object.defineProperty;
2
3
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
4
  var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __getProtoOf = Object.getPrototypeOf;
4
6
  var __hasOwnProp = Object.prototype.hasOwnProperty;
5
7
  var __export = (target, all) => {
6
8
  for (var name in all)
@@ -14,59 +16,35 @@ var __copyProps = (to, from, except, desc) => {
14
16
  }
15
17
  return to;
16
18
  };
19
+ var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
17
28
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
29
  var src_exports = {};
19
30
  __export(src_exports, {
20
- createService: () => createService,
21
- defineConfig: () => import_config2.defineConfig
31
+ colors: () => import_colors.default
22
32
  });
23
33
  module.exports = __toCommonJS(src_exports);
24
- var import_bundler_rspack = require("@unpackjs/bundler-rspack");
25
- var import_bundler_webpack = require("@unpackjs/bundler-webpack");
26
- var import_shared = require("@unpackjs/shared");
27
- var import_config = require("./config/index.cjs");
28
- var import_config2 = require("./config/index.cjs");
29
- async function createService({ command, cliOptions }) {
30
- if (command === "build") {
31
- (0, import_shared.setNodeEnv)(cliOptions.watch ? "development" : "production");
32
- (0, import_shared.setDevServer)(false);
33
- } else {
34
- (0, import_shared.setNodeEnv)("development");
35
- (0, import_shared.setDevServer)(true);
36
- }
37
- if (!(0, import_shared.isDevServer)()) {
38
- console.log(
39
- import_shared.colors.rainbow(`unpack v${"1.5.4"}`),
40
- import_shared.colors.green(`building for ${(0, import_shared.isDev)() ? "development" : "production"}...`)
41
- );
42
- }
43
- const unpackConfig = await (0, import_config.loadConfig)({ cliOptions });
44
- const bundlerMap = {
45
- webpack: () => {
46
- return {
47
- build: () => {
48
- (0, import_bundler_webpack.build)(unpackConfig);
49
- },
50
- dev: () => {
51
- (0, import_bundler_webpack.dev)(unpackConfig);
52
- }
53
- };
54
- },
55
- rspack: () => {
56
- return {
57
- build: () => {
58
- (0, import_bundler_rspack.build)(unpackConfig);
59
- },
60
- dev: () => {
61
- (0, import_bundler_rspack.dev)(unpackConfig);
62
- }
63
- };
64
- }
65
- };
66
- bundlerMap[unpackConfig.bundler]()[command]();
67
- }
34
+ __reExport(src_exports, require("./logger.cjs"), module.exports);
35
+ __reExport(src_exports, require("./types/index.cjs"), module.exports);
36
+ __reExport(src_exports, require("./utils.cjs"), module.exports);
37
+ __reExport(src_exports, require("./constants.cjs"), module.exports);
38
+ __reExport(src_exports, require("./createUnpack.cjs"), module.exports);
39
+ __reExport(src_exports, require("./config.cjs"), module.exports);
40
+ var import_colors = __toESM(require("./colors.cjs"));
68
41
  // Annotate the CommonJS export names for ESM import in node:
69
42
  0 && (module.exports = {
70
- createService,
71
- defineConfig
43
+ colors,
44
+ ...require("./logger.cjs"),
45
+ ...require("./types/index.cjs"),
46
+ ...require("./utils.cjs"),
47
+ ...require("./constants.cjs"),
48
+ ...require("./createUnpack.cjs"),
49
+ ...require("./config.cjs")
72
50
  });