@unpackjs/core 1.6.1 → 1.6.3

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 (37) hide show
  1. package/compiled/css-loader/index.js +20 -20
  2. package/compiled/less-loader/index.js +8 -8
  3. package/compiled/postcss-loader/index.js +66 -63
  4. package/compiled/sass-loader/index.js +8 -8
  5. package/dist/bundler-config/experimentCss.cjs +2 -2
  6. package/dist/bundler-config/experimentCss.js +1 -1
  7. package/dist/bundler-config/index.cjs +4 -3
  8. package/dist/bundler-config/index.d.ts.map +1 -1
  9. package/dist/bundler-config/index.js +3 -2
  10. package/dist/createUnpack.cjs +4 -3
  11. package/dist/createUnpack.d.ts.map +1 -1
  12. package/dist/createUnpack.js +5 -4
  13. package/dist/plugin-progress/rspack.cjs +12 -11
  14. package/dist/plugin-progress/rspack.js +12 -11
  15. package/dist/plugin-progress/webpack.cjs +12 -11
  16. package/dist/plugin-progress/webpack.js +12 -11
  17. package/dist/progressBar.cjs +5 -5
  18. package/dist/progressBar.js +4 -4
  19. package/dist/run/dev.cjs +1 -1
  20. package/dist/run/dev.js +1 -1
  21. package/dist/thread-loader/worker.js +1 -1
  22. package/dist/utils.cjs +32 -9
  23. package/dist/utils.d.ts +3 -0
  24. package/dist/utils.d.ts.map +1 -1
  25. package/dist/utils.js +29 -9
  26. package/package.json +2 -7
  27. package/compiled/log-update/index.d.ts +0 -1
  28. package/compiled/log-update/index.js +0 -1970
  29. package/compiled/log-update/package.json +0 -1
  30. package/dist/lightningcss/index.cjs +0 -21
  31. package/dist/lightningcss/index.d.ts +0 -2
  32. package/dist/lightningcss/index.d.ts.map +0 -1
  33. package/dist/lightningcss/index.js +0 -10
  34. package/dist/typed-css-modules/index.cjs +0 -21
  35. package/dist/typed-css-modules/index.d.ts +0 -2
  36. package/dist/typed-css-modules/index.d.ts.map +0 -1
  37. package/dist/typed-css-modules/index.js +0 -10
@@ -43,7 +43,7 @@ function createUnpack() {
43
43
  outDir: "dist",
44
44
  minify: (0, import_utils.isProd)(),
45
45
  sourceMap: (0, import_utils.isProd)() ? false : "cheap-module-source-map",
46
- parallel: true,
46
+ parallel: !(0, import_utils.isDevServer)(),
47
47
  filenameHash: true,
48
48
  cache: (0, import_utils.isDev)()
49
49
  },
@@ -73,13 +73,14 @@ function createUnpack() {
73
73
  build: async (unpackConfig) => {
74
74
  (0, import_utils.setNodeEnv)("production");
75
75
  console.log(
76
- import_colors.default.rainbow(`unpack v${"1.6.1"}`),
76
+ import_colors.default.rainbow(`unpack v${"1.6.3"}`),
77
77
  import_colors.default.green("building for production...")
78
78
  );
79
79
  const config = await resolveConfig(unpackConfig);
80
80
  (0, import_run.bundlerBuild)(config);
81
81
  },
82
82
  serve: async (unpackConfig) => {
83
+ global.__unpack_start_time = performance.now();
83
84
  (0, import_utils.setNodeEnv)("development");
84
85
  (0, import_utils.setDevServer)(true);
85
86
  const config = await resolveConfig(unpackConfig);
@@ -88,7 +89,7 @@ function createUnpack() {
88
89
  watch: async (unpackConfig) => {
89
90
  (0, import_utils.setNodeEnv)("development");
90
91
  console.log(
91
- import_colors.default.rainbow(`unpack v${"1.6.1"}`),
92
+ import_colors.default.rainbow(`unpack v${"1.6.3"}`),
92
93
  import_colors.default.green("building for development...")
93
94
  );
94
95
  const config = await resolveConfig(unpackConfig);
@@ -1 +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"}
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;0BAOZ,YAAY;EAU3C"}
@@ -10,7 +10,7 @@ var __filename = /* @__PURE__ */ getFilename();
10
10
  import colors from "./colors.js";
11
11
  import { getNormalizedPluginsByHook } from "./plugin.js";
12
12
  import { bundlerBuild, bundlerDev } from "./run/index.js";
13
- import { isDev, isProd, mergeConfig, setDevServer, setNodeEnv } from "./utils.js";
13
+ import { isDev, isDevServer, isProd, mergeConfig, setDevServer, setNodeEnv } from "./utils.js";
14
14
  function createUnpack() {
15
15
  const resolveConfig = async (unpackConfig) => {
16
16
  const defaultConfig = {
@@ -20,7 +20,7 @@ function createUnpack() {
20
20
  outDir: "dist",
21
21
  minify: isProd(),
22
22
  sourceMap: isProd() ? false : "cheap-module-source-map",
23
- parallel: true,
23
+ parallel: !isDevServer(),
24
24
  filenameHash: true,
25
25
  cache: isDev()
26
26
  },
@@ -50,13 +50,14 @@ function createUnpack() {
50
50
  build: async (unpackConfig) => {
51
51
  setNodeEnv("production");
52
52
  console.log(
53
- colors.rainbow(`unpack v${"1.6.1"}`),
53
+ colors.rainbow(`unpack v${"1.6.3"}`),
54
54
  colors.green("building for production...")
55
55
  );
56
56
  const config = await resolveConfig(unpackConfig);
57
57
  bundlerBuild(config);
58
58
  },
59
59
  serve: async (unpackConfig) => {
60
+ global.__unpack_start_time = performance.now();
60
61
  setNodeEnv("development");
61
62
  setDevServer(true);
62
63
  const config = await resolveConfig(unpackConfig);
@@ -65,7 +66,7 @@ function createUnpack() {
65
66
  watch: async (unpackConfig) => {
66
67
  setNodeEnv("development");
67
68
  console.log(
68
- colors.rainbow(`unpack v${"1.6.1"}`),
69
+ colors.rainbow(`unpack v${"1.6.3"}`),
69
70
  colors.green("building for development...")
70
71
  );
71
72
  const config = await resolveConfig(unpackConfig);
@@ -52,17 +52,18 @@ class RspackPluginProgress extends import_core.rspack.ProgressPlugin {
52
52
  !(0, import_utils.isProd)() && import_logger.logger.wait("building...");
53
53
  });
54
54
  compiler.hooks.done.tap(PLUGIN_NAME, async (stats) => {
55
- if (this.startTime) {
56
- const hrtime = process.hrtime(this.startTime);
57
- const compileTime = hrtime[0] + hrtime[1] / 1e9;
58
- this.startTime = void 0;
59
- if (!stats.hasErrors()) {
60
- if ((0, import_utils.isProd)()) {
61
- await (0, import_reporter.printFileSize)({ root: compiler.options.context, stats });
62
- console.log(import_colors.default.green(`✓ built in ${import_colors.default.bold((0, import_utils.prettyTime)(compileTime))}`));
63
- } else {
64
- import_logger.logger.ready(`built in ${import_colors.default.bold((0, import_utils.prettyTime)(compileTime))}`);
65
- }
55
+ if (!this.startTime)
56
+ return;
57
+ (0, import_utils.isProd)() && this.progressBar.done();
58
+ const hrtime = process.hrtime(this.startTime);
59
+ const compileTime = hrtime[0] + hrtime[1] / 1e9;
60
+ this.startTime = void 0;
61
+ if (!stats.hasErrors()) {
62
+ if ((0, import_utils.isProd)()) {
63
+ await (0, import_reporter.printFileSize)({ root: compiler.options.context, stats });
64
+ console.log(import_colors.default.green(`✓ built in ${import_colors.default.bold((0, import_utils.prettyTime)(compileTime))}`));
65
+ } else {
66
+ import_logger.logger.ready(`built in ${import_colors.default.bold((0, import_utils.prettyTime)(compileTime))}`);
66
67
  }
67
68
  }
68
69
  });
@@ -29,17 +29,18 @@ class RspackPluginProgress extends rspack.ProgressPlugin {
29
29
  !isProd() && logger.wait("building...");
30
30
  });
31
31
  compiler.hooks.done.tap(PLUGIN_NAME, async (stats) => {
32
- if (this.startTime) {
33
- const hrtime = process.hrtime(this.startTime);
34
- const compileTime = hrtime[0] + hrtime[1] / 1e9;
35
- this.startTime = void 0;
36
- if (!stats.hasErrors()) {
37
- if (isProd()) {
38
- await printFileSize({ root: compiler.options.context, stats });
39
- console.log(colors.green(`✓ built in ${colors.bold(prettyTime(compileTime))}`));
40
- } else {
41
- logger.ready(`built in ${colors.bold(prettyTime(compileTime))}`);
42
- }
32
+ if (!this.startTime)
33
+ return;
34
+ isProd() && this.progressBar.done();
35
+ const hrtime = process.hrtime(this.startTime);
36
+ const compileTime = hrtime[0] + hrtime[1] / 1e9;
37
+ this.startTime = void 0;
38
+ if (!stats.hasErrors()) {
39
+ if (isProd()) {
40
+ await printFileSize({ root: compiler.options.context, stats });
41
+ console.log(colors.green(`✓ built in ${colors.bold(prettyTime(compileTime))}`));
42
+ } else {
43
+ logger.ready(`built in ${colors.bold(prettyTime(compileTime))}`);
43
44
  }
44
45
  }
45
46
  });
@@ -62,17 +62,18 @@ class WebpackPluginProgress extends import_webpack.default.ProgressPlugin {
62
62
  !(0, import_utils.isProd)() && import_logger.logger.wait("building...");
63
63
  });
64
64
  compiler.hooks.done.tap(PLUGIN_NAME, async (stats) => {
65
- if (this.startTime) {
66
- const hrtime = process.hrtime(this.startTime);
67
- const compileTime = hrtime[0] + hrtime[1] / 1e9;
68
- this.startTime = void 0;
69
- if (!stats.hasErrors()) {
70
- if ((0, import_utils.isProd)()) {
71
- await (0, import_reporter.printFileSize)({ root: compiler.options.context, stats });
72
- console.log(import_colors.default.green(`✓ built in ${import_colors.default.bold((0, import_utils.prettyTime)(compileTime))}`));
73
- } else {
74
- import_logger.logger.ready(`built in ${import_colors.default.bold((0, import_utils.prettyTime)(compileTime))}`);
75
- }
65
+ if (!this.startTime)
66
+ return;
67
+ (0, import_utils.isProd)() && this.progressBar.done();
68
+ const hrtime = process.hrtime(this.startTime);
69
+ const compileTime = hrtime[0] + hrtime[1] / 1e9;
70
+ this.startTime = void 0;
71
+ if (!stats.hasErrors()) {
72
+ if ((0, import_utils.isProd)()) {
73
+ await (0, import_reporter.printFileSize)({ root: compiler.options.context, stats });
74
+ console.log(import_colors.default.green(`✓ built in ${import_colors.default.bold((0, import_utils.prettyTime)(compileTime))}`));
75
+ } else {
76
+ import_logger.logger.ready(`built in ${import_colors.default.bold((0, import_utils.prettyTime)(compileTime))}`);
76
77
  }
77
78
  }
78
79
  });
@@ -39,17 +39,18 @@ class WebpackPluginProgress extends webpack.ProgressPlugin {
39
39
  !isProd() && logger.wait("building...");
40
40
  });
41
41
  compiler.hooks.done.tap(PLUGIN_NAME, async (stats) => {
42
- if (this.startTime) {
43
- const hrtime = process.hrtime(this.startTime);
44
- const compileTime = hrtime[0] + hrtime[1] / 1e9;
45
- this.startTime = void 0;
46
- if (!stats.hasErrors()) {
47
- if (isProd()) {
48
- await printFileSize({ root: compiler.options.context, stats });
49
- console.log(colors.green(`✓ built in ${colors.bold(prettyTime(compileTime))}`));
50
- } else {
51
- logger.ready(`built in ${colors.bold(prettyTime(compileTime))}`);
52
- }
42
+ if (!this.startTime)
43
+ return;
44
+ isProd() && this.progressBar.done();
45
+ const hrtime = process.hrtime(this.startTime);
46
+ const compileTime = hrtime[0] + hrtime[1] / 1e9;
47
+ this.startTime = void 0;
48
+ if (!stats.hasErrors()) {
49
+ if (isProd()) {
50
+ await printFileSize({ root: compiler.options.context, stats });
51
+ console.log(colors.green(`✓ built in ${colors.bold(prettyTime(compileTime))}`));
52
+ } else {
53
+ logger.ready(`built in ${colors.bold(prettyTime(compileTime))}`);
53
54
  }
54
55
  }
55
56
  });
@@ -31,7 +31,7 @@ __export(progressBar_exports, {
31
31
  });
32
32
  module.exports = __toCommonJS(progressBar_exports);
33
33
  var import_colors = __toESM(require("./colors.cjs"));
34
- const logUpdate = require("../compiled/log-update/index.js");
34
+ var import_utils = require("./utils.cjs");
35
35
  class ProgressBar {
36
36
  constructor() {
37
37
  this.options = {
@@ -43,7 +43,7 @@ class ProgressBar {
43
43
  }
44
44
  update({ current: originalCurrent, message = "" }) {
45
45
  const { columns: terminalWidth } = process.stdout;
46
- const messageWidth = terminalWidth - this.options.width - this.options.prefix.length - 7;
46
+ const messageWidth = terminalWidth - this.options.width - this.options.prefix.length - 8;
47
47
  let current = originalCurrent;
48
48
  if (originalCurrent >= 0.98) {
49
49
  current = 1;
@@ -54,14 +54,14 @@ class ProgressBar {
54
54
  const undone = import_colors.default.dim(this.options.char).repeat(undoneWidth);
55
55
  const bar = `${done}${undone}`;
56
56
  const prefix = this.options.prefix ? `${import_colors.default.bold(this.options.prefix)} ` : "";
57
- logUpdate(
57
+ (0, import_utils.logUpdate)(
58
58
  `${prefix}${bar} (${Math.floor(
59
59
  current * 100
60
- )}%) ${import_colors.default.dim(message.slice(0, messageWidth))}`
60
+ )}%) ${import_colors.default.dim(message.slice(0, messageWidth).padEnd(messageWidth, " "))}`
61
61
  );
62
62
  }
63
63
  done() {
64
- logUpdate.done();
64
+ console.log();
65
65
  }
66
66
  }
67
67
  // Annotate the CommonJS export names for ESM import in node:
@@ -8,7 +8,7 @@ var getDirname = () => path.dirname(getFilename());
8
8
  var __dirname = /* @__PURE__ */ getDirname();
9
9
  var __filename = /* @__PURE__ */ getFilename();
10
10
  import colors from "./colors.js";
11
- const logUpdate = require("../compiled/log-update/index.js");
11
+ import { logUpdate } from "./utils.js";
12
12
  class ProgressBar {
13
13
  constructor() {
14
14
  this.options = {
@@ -20,7 +20,7 @@ class ProgressBar {
20
20
  }
21
21
  update({ current: originalCurrent, message = "" }) {
22
22
  const { columns: terminalWidth } = process.stdout;
23
- const messageWidth = terminalWidth - this.options.width - this.options.prefix.length - 7;
23
+ const messageWidth = terminalWidth - this.options.width - this.options.prefix.length - 8;
24
24
  let current = originalCurrent;
25
25
  if (originalCurrent >= 0.98) {
26
26
  current = 1;
@@ -34,11 +34,11 @@ class ProgressBar {
34
34
  logUpdate(
35
35
  `${prefix}${bar} (${Math.floor(
36
36
  current * 100
37
- )}%) ${colors.dim(message.slice(0, messageWidth))}`
37
+ )}%) ${colors.dim(message.slice(0, messageWidth).padEnd(messageWidth, " "))}`
38
38
  );
39
39
  }
40
40
  done() {
41
- logUpdate.done();
41
+ console.log();
42
42
  }
43
43
  }
44
44
  export {
package/dist/run/dev.cjs CHANGED
@@ -55,7 +55,7 @@ async function bundlerDev(unpackConfig) {
55
55
  const server = new import_webpack_dev_server.default(devServerOptions, compiler);
56
56
  await server.start();
57
57
  import_logger.logger.greet(
58
- ` ${import_colors.default.green(`${import_colors.default.bold("UNPACK")} v${"1.6.1"}`)} ${import_colors.default.dim(
58
+ ` ${import_colors.default.green(`${import_colors.default.bold("UNPACK")} v${"1.6.3"}`)} ${import_colors.default.dim(
59
59
  `ready in ${import_colors.default.reset(
60
60
  import_colors.default.bold(Math.ceil(performance.now() - global.__unpack_start_time))
61
61
  )} ms`
package/dist/run/dev.js CHANGED
@@ -32,7 +32,7 @@ async function bundlerDev(unpackConfig) {
32
32
  const server = new WebpackDevServer(devServerOptions, compiler);
33
33
  await server.start();
34
34
  logger.greet(
35
- ` ${colors.green(`${colors.bold("UNPACK")} v${"1.6.1"}`)} ${colors.dim(
35
+ ` ${colors.green(`${colors.bold("UNPACK")} v${"1.6.3"}`)} ${colors.dim(
36
36
  `ready in ${colors.reset(
37
37
  colors.bold(Math.ceil(performance.now() - global.__unpack_start_time))
38
38
  )} ms`
@@ -12,7 +12,7 @@ import path from "path";
12
12
  import { fileURLToPath } from "url";
13
13
  var getFilename, getDirname, __dirname, __filename;
14
14
  var init_esm = __esm({
15
- "../../node_modules/.pnpm/@modern-js+module-tools@2.60.5_typescript@5.5.4/node_modules/@modern-js/module-tools/shims/esm.js"() {
15
+ "../../node_modules/.pnpm/@modern-js+module-tools@2.60.6_typescript@5.5.4/node_modules/@modern-js/module-tools/shims/esm.js"() {
16
16
  getFilename = () => fileURLToPath(import.meta.url);
17
17
  getDirname = () => path.dirname(getFilename());
18
18
  __dirname = /* @__PURE__ */ getDirname();
package/dist/utils.cjs CHANGED
@@ -27,6 +27,7 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
27
27
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
28
28
  var utils_exports = {};
29
29
  __export(utils_exports, {
30
+ clearLine: () => clearLine,
30
31
  debounce: () => debounce,
31
32
  getAddressUrls: () => getAddressUrls,
32
33
  getCompiledPkgPath: () => getCompiledPkgPath,
@@ -35,6 +36,7 @@ __export(utils_exports, {
35
36
  getPort: () => getPort,
36
37
  getTime: () => getTime,
37
38
  getUserDepPath: () => getUserDepPath,
39
+ getUserDepVersion: () => getUserDepVersion,
38
40
  getValueByPath: () => getValueByPath,
39
41
  isBoolean: () => isBoolean,
40
42
  isDev: () => isDev,
@@ -48,6 +50,7 @@ __export(utils_exports, {
48
50
  isUndefined: () => isUndefined,
49
51
  isWatch: () => isWatch,
50
52
  isWin: () => isWin,
53
+ logUpdate: () => logUpdate,
51
54
  mergeConfig: () => mergeConfig,
52
55
  prettyTime: () => prettyTime,
53
56
  setDevServer: () => setDevServer,
@@ -58,12 +61,12 @@ __export(utils_exports, {
58
61
  });
59
62
  module.exports = __toCommonJS(utils_exports);
60
63
  var import_colors = __toESM(require("./colors.cjs"));
64
+ var import_node_fs = __toESM(require("node:fs"));
61
65
  var import_node_net = __toESM(require("node:net"));
62
66
  var import_node_os = __toESM(require("node:os"));
63
67
  var import_node_path = __toESM(require("node:path"));
64
68
  var import_constants = require("./constants.cjs");
65
69
  var import_logger = require("./logger.cjs");
66
- const glob = require("../compiled/fast-glob/index.js");
67
70
  const portfinder = require("../compiled/portfinder/index.js");
68
71
  const { merge } = require("../compiled/webpack-merge/index.js");
69
72
  const getNodeEnv = () => process.env.NODE_ENV;
@@ -138,13 +141,13 @@ const getPort = (startPort) => {
138
141
  };
139
142
  const getCompiledPkgPath = (packageName) => import_node_path.default.join(__dirname, "../compiled", packageName);
140
143
  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];
144
+ const dependencies = Array.isArray(deps) ? deps : [deps];
145
+ for (const dep of dependencies) {
146
+ const absPath = import_node_path.default.resolve(root, "node_modules", dep);
147
+ if (import_node_fs.default.existsSync(absPath)) {
148
+ return absPath;
149
+ }
150
+ }
148
151
  };
149
152
  const uniqueId = (length) => {
150
153
  const generateId = () => Date.now().toString(36);
@@ -244,7 +247,7 @@ const trackPerformance = (msg) => {
244
247
  }
245
248
  if (msg) {
246
249
  import_logger.logger.wait(
247
- `${msg} ${import_colors.default.dim("for")} ${import_colors.default.bold(import_colors.default.yellow(`${Math.ceil(performance.now() - global[k])}ms`))}`
250
+ `${msg} ${import_colors.default.dim("for")} ${import_colors.default.bold(import_colors.default.yellow(`${(performance.now() - global[k]).toFixed(2)}ms`))}`
248
251
  );
249
252
  }
250
253
  global[k] = performance.now();
@@ -253,8 +256,26 @@ const getPathInJs = (absPath) => {
253
256
  return JSON.stringify(absPath).slice(1, -1);
254
257
  };
255
258
  const mergeConfig = merge;
259
+ const getUserDepVersion = (root, dep) => {
260
+ const depPath = getUserDepPath(root, dep);
261
+ if (!depPath)
262
+ return;
263
+ const packageInfo = JSON.parse(import_node_fs.default.readFileSync(import_node_path.default.resolve(depPath, "package.json"), "utf-8"));
264
+ return packageInfo.version;
265
+ };
266
+ const clearLine = () => {
267
+ if (!process.stdout.isTTY)
268
+ return;
269
+ process.stdout.clearLine(0);
270
+ process.stdout.cursorTo(0);
271
+ };
272
+ const logUpdate = (output) => {
273
+ clearLine();
274
+ process.stdout.write(output);
275
+ };
256
276
  // Annotate the CommonJS export names for ESM import in node:
257
277
  0 && (module.exports = {
278
+ clearLine,
258
279
  debounce,
259
280
  getAddressUrls,
260
281
  getCompiledPkgPath,
@@ -263,6 +284,7 @@ const mergeConfig = merge;
263
284
  getPort,
264
285
  getTime,
265
286
  getUserDepPath,
287
+ getUserDepVersion,
266
288
  getValueByPath,
267
289
  isBoolean,
268
290
  isDev,
@@ -276,6 +298,7 @@ const mergeConfig = merge;
276
298
  isUndefined,
277
299
  isWatch,
278
300
  isWin,
301
+ logUpdate,
279
302
  mergeConfig,
280
303
  prettyTime,
281
304
  setDevServer,
package/dist/utils.d.ts CHANGED
@@ -39,5 +39,8 @@ export declare const trackPerformance: (msg?: string) => void;
39
39
  */
40
40
  export declare const getPathInJs: (absPath: string) => string;
41
41
  export declare const mergeConfig: any;
42
+ export declare const getUserDepVersion: (root: string, dep: string) => any;
43
+ export declare const clearLine: () => void;
44
+ export declare const logUpdate: (output: string) => void;
42
45
  export {};
43
46
  //# sourceMappingURL=utils.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,eAAe,EAAE,OAAO,EAAE,MAAM,eAAe,CAAA;AAG7D,eAAO,MAAM,UAAU,QAAiC,OAAO,CAAA;AAE/D,eAAO,MAAM,UAAU,QAAS,OAAO,SAEtC,CAAA;AAED,eAAO,MAAM,YAAY,gBAAiB,OAAO,SAEhD,CAAA;AAED,eAAO,MAAM,KAAK,QAAO,OAAyC,CAAA;AAElE,eAAO,MAAM,WAAW,QAAO,OAA4C,CAAA;AAE3E,eAAO,MAAM,OAAO,QAAO,OAAoC,CAAA;AAE/D,eAAO,MAAM,MAAM,QAAO,OAAwC,CAAA;AAElE,eAAO,MAAM,KAAK,QAAO,OAAuC,CAAA;AAEhE,eAAO,MAAM,QAAQ,QAAS,OAAO,KAAG,GAAG,IAAI,MAAiC,CAAA;AAEhF,eAAO,MAAM,SAAS,SAAU,OAAO,KAAG,IAAI,IAAI,OAAoC,CAAA;AAEtF,eAAO,MAAM,WAAW,QAAS,OAAO,KAAG,GAAG,IAAI,SAAuC,CAAA;AAEzF,eAAO,MAAM,UAAU,SAAU,OAAO,KAAG,IAAI,IAAI,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,GAC3C,CAAA;AAE5B,eAAO,MAAM,QAAQ,QAAS,OAAO,KAAG,GAAG,IAAI,MAAM,CAAC,MAAM,EAAE,GAAG,CACxB,CAAA;AAEzC,eAAO,MAAM,aAAa,QAAS,OAAO,KAAG,GAAG,IAAI,MAAM,CAAC,MAAM,EAAE,GAAG,CACM,CAAA;AAE5E,eAAO,MAAM,QAAQ,QAAS,GAAG,KAAG,GAAG,IAAI,MACgB,CAAA;AAE3D,eAAO,MAAM,UAAU,YAAa,MAAM,WAYzC,CAAA;AAED,eAAO,MAAM,cAAc,WAAY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M,GAAG,SAQ/E,CAAA;AAED,eAAO,MAAM,QAAQ,WAAY,MAAM,WAItC,CAAA;AAED,wBAAgB,OAAO,WAMtB;AAED,eAAO,MAAM,QAAQ,mDAQpB,CAAA;AA6CD,KAAK,UAAU,GAAG;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,GAAG,EAAE,MAAM,CAAA;CAAE,CAAA;AAEhD,eAAO,MAAM,cAAc,8BAIxB;IACD,QAAQ,CAAC,EAAE,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;AAED,eAAO,MAAM,SAAS,YAIrB,CAAA;AAED,eAAO,MAAM,SAAS,WAAY,MAAM,SAGvC,CAAA"}
package/dist/utils.js CHANGED
@@ -7,9 +7,9 @@ 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");
12
+ import fs from "node:fs";
13
13
  import net from "node:net";
14
14
  import os from "node:os";
15
15
  import path2 from "node:path";
@@ -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);
@@ -194,7 +194,7 @@ const trackPerformance = (msg) => {
194
194
  }
195
195
  if (msg) {
196
196
  logger.wait(
197
- `${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`))}`
198
198
  );
199
199
  }
200
200
  global[k] = performance.now();
@@ -203,7 +203,25 @@ const getPathInJs = (absPath) => {
203
203
  return JSON.stringify(absPath).slice(1, -1);
204
204
  };
205
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
+ const clearLine = () => {
214
+ if (!process.stdout.isTTY)
215
+ return;
216
+ process.stdout.clearLine(0);
217
+ process.stdout.cursorTo(0);
218
+ };
219
+ const logUpdate = (output) => {
220
+ clearLine();
221
+ process.stdout.write(output);
222
+ };
206
223
  export {
224
+ clearLine,
207
225
  debounce,
208
226
  getAddressUrls,
209
227
  getCompiledPkgPath,
@@ -212,6 +230,7 @@ export {
212
230
  getPort,
213
231
  getTime,
214
232
  getUserDepPath,
233
+ getUserDepVersion,
215
234
  getValueByPath,
216
235
  isBoolean,
217
236
  isDev,
@@ -225,6 +244,7 @@ export {
225
244
  isUndefined,
226
245
  isWatch,
227
246
  isWin,
247
+ logUpdate,
228
248
  mergeConfig,
229
249
  prettyTime,
230
250
  setDevServer,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@unpackjs/core",
3
- "version": "1.6.1",
3
+ "version": "1.6.3",
4
4
  "description": "",
5
5
  "type": "module",
6
6
  "exports": {
@@ -13,10 +13,6 @@
13
13
  "types": "./compiled/fast-glob/index.d.ts",
14
14
  "default": "./compiled/fast-glob/index.js"
15
15
  },
16
- "./log-update": {
17
- "types": "./compiled/log-update/index.d.ts",
18
- "default": "./compiled/log-update/index.js"
19
- },
20
16
  "./portfinder": {
21
17
  "types": "./compiled/portfinder/index.d.ts",
22
18
  "default": "./compiled/portfinder/index.js"
@@ -87,7 +83,6 @@
87
83
  "fast-glob": "3.3.2",
88
84
  "less-loader": "12.2.0",
89
85
  "line-diff": "2.1.1",
90
- "log-update": "4.0.0",
91
86
  "portfinder": "1.0.32",
92
87
  "postcss-loader": "8.1.1",
93
88
  "sass-loader": "16.0.2",
@@ -98,7 +93,7 @@
98
93
  },
99
94
  "dependencies": {
100
95
  "picocolors": "1.1.1",
101
- "@rspack/core": "1.0.14",
96
+ "@rspack/core": "1.1.0-beta.0",
102
97
  "@types/less": "3.0.6",
103
98
  "copy-webpack-plugin": "12.0.2",
104
99
  "esbuild": "0.24.0",
@@ -1 +0,0 @@
1
- export = any;