@unpackjs/core 1.6.0 → 1.6.2

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 (43) hide show
  1. package/compiled/postcss-loader/index.js +58 -55
  2. package/dist/bundler-config/css.cjs +3 -4
  3. package/dist/bundler-config/css.js +5 -5
  4. package/dist/bundler-config/experimentCss.cjs +2 -3
  5. package/dist/bundler-config/experimentCss.js +3 -3
  6. package/dist/bundler-config/helper.cjs +4 -2
  7. package/dist/bundler-config/helper.d.ts.map +1 -1
  8. package/dist/bundler-config/helper.js +4 -2
  9. package/dist/bundler-config/index.cjs +18 -20
  10. package/dist/bundler-config/index.d.ts.map +1 -1
  11. package/dist/bundler-config/index.js +19 -29
  12. package/dist/config.cjs +14 -46
  13. package/dist/config.d.ts +2 -2
  14. package/dist/config.d.ts.map +1 -1
  15. package/dist/config.js +15 -47
  16. package/dist/createUnpack.cjs +103 -0
  17. package/dist/createUnpack.d.ts +7 -0
  18. package/dist/createUnpack.d.ts.map +1 -0
  19. package/dist/createUnpack.js +79 -0
  20. package/dist/index.cjs +5 -6
  21. package/dist/index.d.ts +2 -2
  22. package/dist/index.d.ts.map +1 -1
  23. package/dist/index.js +3 -4
  24. package/dist/plugin-progress/rspack.cjs +1 -1
  25. package/dist/plugin-progress/rspack.js +1 -1
  26. package/dist/plugin-progress/webpack.cjs +1 -1
  27. package/dist/plugin-progress/webpack.js +1 -1
  28. package/dist/reporter.cjs +2 -2
  29. package/dist/reporter.d.ts +2 -1
  30. package/dist/reporter.d.ts.map +1 -1
  31. package/dist/reporter.js +2 -2
  32. package/dist/run/dev.cjs +1 -1
  33. package/dist/run/dev.js +1 -1
  34. package/dist/thread-loader/worker.js +1 -1
  35. package/dist/utils.cjs +26 -24
  36. package/dist/utils.d.ts +7 -2
  37. package/dist/utils.d.ts.map +1 -1
  38. package/dist/utils.js +23 -22
  39. package/package.json +2 -2
  40. package/dist/createService.cjs +0 -65
  41. package/dist/createService.d.ts +0 -8
  42. package/dist/createService.d.ts.map +0 -1
  43. package/dist/createService.js +0 -41
package/dist/utils.cjs CHANGED
@@ -31,10 +31,11 @@ __export(utils_exports, {
31
31
  getAddressUrls: () => getAddressUrls,
32
32
  getCompiledPkgPath: () => getCompiledPkgPath,
33
33
  getNodeEnv: () => getNodeEnv,
34
+ getPathInJs: () => getPathInJs,
34
35
  getPort: () => getPort,
35
36
  getTime: () => getTime,
36
37
  getUserDepPath: () => getUserDepPath,
37
- getValidPath: () => getValidPath,
38
+ getUserDepVersion: () => getUserDepVersion,
38
39
  getValueByPath: () => getValueByPath,
39
40
  isBoolean: () => isBoolean,
40
41
  isDev: () => isDev,
@@ -45,10 +46,10 @@ __export(utils_exports, {
45
46
  isProd: () => isProd,
46
47
  isRegExp: () => isRegExp,
47
48
  isString: () => isString,
48
- isTs: () => isTs,
49
49
  isUndefined: () => isUndefined,
50
50
  isWatch: () => isWatch,
51
51
  isWin: () => isWin,
52
+ mergeConfig: () => mergeConfig,
52
53
  prettyTime: () => prettyTime,
53
54
  setDevServer: () => setDevServer,
54
55
  setNodeEnv: () => setNodeEnv,
@@ -64,8 +65,8 @@ var import_node_os = __toESM(require("node:os"));
64
65
  var import_node_path = __toESM(require("node:path"));
65
66
  var import_constants = require("./constants.cjs");
66
67
  var import_logger = require("./logger.cjs");
67
- const glob = require("../compiled/fast-glob/index.js");
68
68
  const portfinder = require("../compiled/portfinder/index.js");
69
+ const { merge } = require("../compiled/webpack-merge/index.js");
69
70
  const getNodeEnv = () => process.env.NODE_ENV;
70
71
  const setNodeEnv = (env) => {
71
72
  process.env.NODE_ENV = env;
@@ -138,13 +139,13 @@ const getPort = (startPort) => {
138
139
  };
139
140
  const getCompiledPkgPath = (packageName) => import_node_path.default.join(__dirname, "../compiled", packageName);
140
141
  const getUserDepPath = (root, deps) => {
141
- const paths = glob.sync(deps, {
142
- cwd: import_node_path.default.resolve(root, "node_modules"),
143
- absolute: true,
144
- onlyDirectories: true,
145
- deep: 1
146
- });
147
- return paths?.[0];
142
+ const dependencies = Array.isArray(deps) ? deps : [deps];
143
+ for (const dep of dependencies) {
144
+ const absPath = import_node_path.default.resolve(root, "node_modules", dep);
145
+ if (import_node_fs.default.existsSync(absPath)) {
146
+ return absPath;
147
+ }
148
+ }
148
149
  };
149
150
  const uniqueId = (length) => {
150
151
  const generateId = () => Date.now().toString(36);
@@ -167,17 +168,6 @@ const debounce = (fn, delay) => {
167
168
  }, delay);
168
169
  };
169
170
  };
170
- const getValidPath = (filePath) => {
171
- const absPath = import_node_path.default.isAbsolute(filePath) ? filePath : import_node_path.default.resolve(process.cwd(), filePath);
172
- if (import_node_fs.default.existsSync(absPath)) {
173
- return absPath;
174
- }
175
- return void 0;
176
- };
177
- const isTs = () => {
178
- const tsconfigPath = import_node_path.default.resolve(process.cwd(), "tsconfig.json");
179
- return import_node_fs.default.existsSync(tsconfigPath);
180
- };
181
171
  const getIpv4Interfaces = () => {
182
172
  const interfaces = import_node_os.default.networkInterfaces();
183
173
  const ipv4Interfaces = /* @__PURE__ */ new Map();
@@ -255,21 +245,33 @@ const trackPerformance = (msg) => {
255
245
  }
256
246
  if (msg) {
257
247
  import_logger.logger.wait(
258
- `${msg} ${import_colors.default.dim("for")} ${import_colors.default.bold(import_colors.default.yellow(`${Math.ceil(performance.now() - global[k])}ms`))}`
248
+ `${msg} ${import_colors.default.dim("for")} ${import_colors.default.bold(import_colors.default.yellow(`${(performance.now() - global[k]).toFixed(2)}ms`))}`
259
249
  );
260
250
  }
261
251
  global[k] = performance.now();
262
252
  };
253
+ const getPathInJs = (absPath) => {
254
+ return JSON.stringify(absPath).slice(1, -1);
255
+ };
256
+ const mergeConfig = merge;
257
+ const getUserDepVersion = (root, dep) => {
258
+ const depPath = getUserDepPath(root, dep);
259
+ if (!depPath)
260
+ return;
261
+ const packageInfo = JSON.parse(import_node_fs.default.readFileSync(import_node_path.default.resolve(depPath, "package.json"), "utf-8"));
262
+ return packageInfo.version;
263
+ };
263
264
  // Annotate the CommonJS export names for ESM import in node:
264
265
  0 && (module.exports = {
265
266
  debounce,
266
267
  getAddressUrls,
267
268
  getCompiledPkgPath,
268
269
  getNodeEnv,
270
+ getPathInJs,
269
271
  getPort,
270
272
  getTime,
271
273
  getUserDepPath,
272
- getValidPath,
274
+ getUserDepVersion,
273
275
  getValueByPath,
274
276
  isBoolean,
275
277
  isDev,
@@ -280,10 +282,10 @@ const trackPerformance = (msg) => {
280
282
  isProd,
281
283
  isRegExp,
282
284
  isString,
283
- isTs,
284
285
  isUndefined,
285
286
  isWatch,
286
287
  isWin,
288
+ mergeConfig,
287
289
  prettyTime,
288
290
  setDevServer,
289
291
  setNodeEnv,
package/dist/utils.d.ts CHANGED
@@ -23,8 +23,6 @@ export declare const getUserDepPath: (root: string, deps: string | string[]) =>
23
23
  export declare const uniqueId: (length: number) => string;
24
24
  export declare function getTime(): string;
25
25
  export declare const debounce: (fn: any, delay: any) => (...args: any[]) => void;
26
- export declare const getValidPath: (filePath: string) => string;
27
- export declare const isTs: () => boolean;
28
26
  type AddressUrl = {
29
27
  label: string;
30
28
  url: string;
@@ -35,5 +33,12 @@ export declare const getAddressUrls: ({ protocol, port, host, }: {
35
33
  host?: string;
36
34
  }) => AddressUrl[];
37
35
  export declare const trackPerformance: (msg?: string) => void;
36
+ /**
37
+ * Fix path on windows
38
+ * C:\Users\Desktop\project\src\index.js -> C:\\Users\\Desktop\\project\\src\\index.js
39
+ */
40
+ export declare const getPathInJs: (absPath: string) => string;
41
+ export declare const mergeConfig: any;
42
+ export declare const getUserDepVersion: (root: string, dep: string) => any;
38
43
  export {};
39
44
  //# sourceMappingURL=utils.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAE,eAAe,EAAE,OAAO,EAAE,MAAM,eAAe,CAAA;AAE7D,eAAO,MAAM,UAAU,QAAiC,OAAO,CAAA;AAE/D,eAAO,MAAM,UA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E,MAAM,CAAA;IACjB,IAAI,EAAE,MAAM,CAAA;IACZ,IAAI,CAAC,EAAE,MAAM,CAAA;CACd,KAAG,UAAU,EAuCb,CAAA;AAED,eAAO,MAAM,gBAAgB,SAAU,MAAM,SAY5C,CAAA;AAED;;;GAGG;AACH,eAAO,MAAM,WAAW,YAAa,MAAM,WAE1C,CAAA;AAED,eAAO,MAAM,WAAW,KAAQ,CAAA;AAEhC,eAAO,MAAM,iBAAiB,SAAU,MAAM,OAAO,MAAM,QAK1D,CAAA"}
package/dist/utils.js CHANGED
@@ -7,7 +7,6 @@ var getFilename = () => fileURLToPath(import.meta.url);
7
7
  var getDirname = () => path.dirname(getFilename());
8
8
  var __dirname = /* @__PURE__ */ getDirname();
9
9
  var __filename = /* @__PURE__ */ getFilename();
10
- const glob = require("../compiled/fast-glob/index.js");
11
10
  import colors from "./colors.js";
12
11
  const portfinder = require("../compiled/portfinder/index.js");
13
12
  import fs from "node:fs";
@@ -16,6 +15,7 @@ import os from "node:os";
16
15
  import path2 from "node:path";
17
16
  import { DEFAULT_DEV_HOST } from "./constants.js";
18
17
  import { logger } from "./logger.js";
18
+ const { merge } = require("../compiled/webpack-merge/index.js");
19
19
  const getNodeEnv = () => process.env.NODE_ENV;
20
20
  const setNodeEnv = (env) => {
21
21
  process.env.NODE_ENV = env;
@@ -88,13 +88,13 @@ const getPort = (startPort) => {
88
88
  };
89
89
  const getCompiledPkgPath = (packageName) => path2.join(__dirname, "../compiled", packageName);
90
90
  const getUserDepPath = (root, deps) => {
91
- const paths = glob.sync(deps, {
92
- cwd: path2.resolve(root, "node_modules"),
93
- absolute: true,
94
- onlyDirectories: true,
95
- deep: 1
96
- });
97
- return paths?.[0];
91
+ const dependencies = Array.isArray(deps) ? deps : [deps];
92
+ for (const dep of dependencies) {
93
+ const absPath = path2.resolve(root, "node_modules", dep);
94
+ if (fs.existsSync(absPath)) {
95
+ return absPath;
96
+ }
97
+ }
98
98
  };
99
99
  const uniqueId = (length) => {
100
100
  const generateId = () => Date.now().toString(36);
@@ -117,17 +117,6 @@ const debounce = (fn, delay) => {
117
117
  }, delay);
118
118
  };
119
119
  };
120
- const getValidPath = (filePath) => {
121
- const absPath = path2.isAbsolute(filePath) ? filePath : path2.resolve(process.cwd(), filePath);
122
- if (fs.existsSync(absPath)) {
123
- return absPath;
124
- }
125
- return void 0;
126
- };
127
- const isTs = () => {
128
- const tsconfigPath = path2.resolve(process.cwd(), "tsconfig.json");
129
- return fs.existsSync(tsconfigPath);
130
- };
131
120
  const getIpv4Interfaces = () => {
132
121
  const interfaces = os.networkInterfaces();
133
122
  const ipv4Interfaces = /* @__PURE__ */ new Map();
@@ -205,20 +194,32 @@ const trackPerformance = (msg) => {
205
194
  }
206
195
  if (msg) {
207
196
  logger.wait(
208
- `${msg} ${colors.dim("for")} ${colors.bold(colors.yellow(`${Math.ceil(performance.now() - global[k])}ms`))}`
197
+ `${msg} ${colors.dim("for")} ${colors.bold(colors.yellow(`${(performance.now() - global[k]).toFixed(2)}ms`))}`
209
198
  );
210
199
  }
211
200
  global[k] = performance.now();
212
201
  };
202
+ const getPathInJs = (absPath) => {
203
+ return JSON.stringify(absPath).slice(1, -1);
204
+ };
205
+ const mergeConfig = merge;
206
+ const getUserDepVersion = (root, dep) => {
207
+ const depPath = getUserDepPath(root, dep);
208
+ if (!depPath)
209
+ return;
210
+ const packageInfo = JSON.parse(fs.readFileSync(path2.resolve(depPath, "package.json"), "utf-8"));
211
+ return packageInfo.version;
212
+ };
213
213
  export {
214
214
  debounce,
215
215
  getAddressUrls,
216
216
  getCompiledPkgPath,
217
217
  getNodeEnv,
218
+ getPathInJs,
218
219
  getPort,
219
220
  getTime,
220
221
  getUserDepPath,
221
- getValidPath,
222
+ getUserDepVersion,
222
223
  getValueByPath,
223
224
  isBoolean,
224
225
  isDev,
@@ -229,10 +230,10 @@ export {
229
230
  isProd,
230
231
  isRegExp,
231
232
  isString,
232
- isTs,
233
233
  isUndefined,
234
234
  isWatch,
235
235
  isWin,
236
+ mergeConfig,
236
237
  prettyTime,
237
238
  setDevServer,
238
239
  setNodeEnv,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@unpackjs/core",
3
- "version": "1.6.0",
3
+ "version": "1.6.2",
4
4
  "description": "",
5
5
  "type": "module",
6
6
  "exports": {
@@ -104,7 +104,7 @@
104
104
  "esbuild": "0.24.0",
105
105
  "esbuild-loader": "4.2.2",
106
106
  "fork-ts-checker-webpack-plugin": "9.0.2",
107
- "html-webpack-plugin": "5.6.2",
107
+ "html-webpack-plugin": "5.6.3",
108
108
  "json5": "2.2.3",
109
109
  "lightningcss": "1.27.0",
110
110
  "loader-runner": "4.3.0",
@@ -1,65 +0,0 @@
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 createService_exports = {};
29
- __export(createService_exports, {
30
- createService: () => createService
31
- });
32
- module.exports = __toCommonJS(createService_exports);
33
- var import_colors = __toESM(require("./colors.cjs"));
34
- var import_config = require("./config.cjs");
35
- var import_run = require("./run/index.cjs");
36
- var import_utils = require("./utils.cjs");
37
- async function createService({ command, cliOptions, defaultConfig }) {
38
- if (command === "build") {
39
- (0, import_utils.setNodeEnv)(cliOptions.watch ? "development" : "production");
40
- (0, import_utils.setDevServer)(false);
41
- } else {
42
- (0, import_utils.setNodeEnv)("development");
43
- (0, import_utils.setDevServer)(true);
44
- }
45
- if (!(0, import_utils.isDevServer)()) {
46
- console.log(
47
- import_colors.default.rainbow(`unpack v${"1.6.0"}`),
48
- import_colors.default.green(`building for ${(0, import_utils.isDev)() ? "development" : "production"}...`)
49
- );
50
- }
51
- const unpackConfig = await (0, import_config.loadConfig)({ cliOptions, defaultConfig });
52
- const commandMap = {
53
- build: () => {
54
- (0, import_run.bundlerBuild)(unpackConfig);
55
- },
56
- dev: () => {
57
- (0, import_run.bundlerDev)(unpackConfig);
58
- }
59
- };
60
- commandMap[command]();
61
- }
62
- // Annotate the CommonJS export names for ESM import in node:
63
- 0 && (module.exports = {
64
- createService
65
- });
@@ -1,8 +0,0 @@
1
- import type { CliOptions, Command, UnpackConfig } from './types/index';
2
- export type CreateServiceOptions = {
3
- command: Command;
4
- cliOptions?: CliOptions;
5
- defaultConfig?: UnpackConfig;
6
- };
7
- export declare function createService({ command, cliOptions, defaultConfig }: CreateServiceOptions): Promise<void>;
8
- //# sourceMappingURL=createService.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"createService.d.ts","sourceRoot":"","sources":["../src/createService.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAA;AAMxE,MAAM,MAAM,oBAAoB,GAAG;IACjC,OAAO,EAAE,OAAO,CAAA;IAChB,UAAU,CAAC,EAAE,UAAU,CAAA;IACvB,aAAa,CAAC,EAAE,YAAY,CAAA;CAC7B,CAAA;AACD,wBAAsB,aAAa,CAAC,EAAE,OAAO,EAAE,UAAU,EAAE,aAAa,EAAE,EAAE,oBAAoB,iBA0B/F"}
@@ -1,41 +0,0 @@
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 { loadConfig } from "./config.js";
12
- import { bundlerBuild, bundlerDev } from "./run/index.js";
13
- import { isDev, isDevServer, setDevServer, setNodeEnv } from "./utils.js";
14
- async function createService({ command, cliOptions, defaultConfig }) {
15
- if (command === "build") {
16
- setNodeEnv(cliOptions.watch ? "development" : "production");
17
- setDevServer(false);
18
- } else {
19
- setNodeEnv("development");
20
- setDevServer(true);
21
- }
22
- if (!isDevServer()) {
23
- console.log(
24
- colors.rainbow(`unpack v${"1.6.0"}`),
25
- colors.green(`building for ${isDev() ? "development" : "production"}...`)
26
- );
27
- }
28
- const unpackConfig = await loadConfig({ cliOptions, defaultConfig });
29
- const commandMap = {
30
- build: () => {
31
- bundlerBuild(unpackConfig);
32
- },
33
- dev: () => {
34
- bundlerDev(unpackConfig);
35
- }
36
- };
37
- commandMap[command]();
38
- }
39
- export {
40
- createService
41
- };