@umijs/bundler-utoopack 4.6.75 → 4.6.77

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.
package/dist/config.js CHANGED
@@ -582,7 +582,8 @@ function getUserUtoopackConfig(utoopackConfig = {}, opts) {
582
582
  var _a, _b;
583
583
  const userUtoopackConfig = import_utils.lodash.omit(utoopackConfig, [
584
584
  "babelLoader",
585
- "root"
585
+ "root",
586
+ "watch"
586
587
  ]);
587
588
  const packageImports = ((_a = userUtoopackConfig.optimization) == null ? void 0 : _a.packageImports) || [];
588
589
  if (((_b = opts.config.antd) == null ? void 0 : _b.import) && opts.modularizeImports.antd && Array.isArray(packageImports) && packageImports.includes("antd")) {
@@ -740,7 +741,7 @@ async function getSSRUtooPackConfig(rawOpts) {
740
741
  return utooBundlerOpts;
741
742
  }
742
743
  async function getDevUtooPackConfig(rawOpts) {
743
- var _a;
744
+ var _a, _b;
744
745
  const opts = normalizeUtoopackOpts(rawOpts);
745
746
  let webpackConfig = await (0, import_bundler_webpack.getConfig)({
746
747
  cwd: opts.cwd,
@@ -834,7 +835,7 @@ async function getDevUtooPackConfig(rawOpts) {
834
835
  emotion
835
836
  },
836
837
  define,
837
- stats: true,
838
+ stats: false,
838
839
  // Windows persistent cache restore is currently unstable in utoopack dev.
839
840
  persistentCaching: getDefaultPersistentCaching("development"),
840
841
  nodePolyfill: true,
@@ -853,6 +854,7 @@ async function getDevUtooPackConfig(rawOpts) {
853
854
  userUtoopackConfig
854
855
  ),
855
856
  watch: {
857
+ ...(_b = opts.config.utoopack) == null ? void 0 : _b.watch,
856
858
  enable: true
857
859
  },
858
860
  dev: true,
package/dist/index.d.ts CHANGED
@@ -2,8 +2,9 @@ import { IDevOpts } from './config';
2
2
  import type { IOpts } from './types';
3
3
  export { findRootDir } from '@utoo/pack';
4
4
  export * from './config';
5
- export type { IUtoopackUserConfig } from './types';
5
+ export type { IUtoopackUserConfig, IUtoopackWatchConfig } from './types';
6
6
  export declare function isUtoopackProxyStartupError(error: any, utooServePort: number): boolean;
7
+ export declare function createDevStatsFromClientPaths(clientPaths: string[] | undefined, entryNames: string[]): any;
7
8
  export declare function build(opts: IOpts): Promise<any>;
8
9
  export declare function buildSSR(opts: IOpts & {
9
10
  serverBuildPath: string;
package/dist/index.js CHANGED
@@ -32,6 +32,7 @@ var src_exports = {};
32
32
  __export(src_exports, {
33
33
  build: () => build,
34
34
  buildSSR: () => buildSSR,
35
+ createDevStatsFromClientPaths: () => createDevStatsFromClientPaths,
35
36
  dev: () => dev,
36
37
  findRootDir: () => import_pack.findRootDir,
37
38
  isUtoopackProxyStartupError: () => isUtoopackProxyStartupError
@@ -51,6 +52,33 @@ __reExport(src_exports, require("./config"), module.exports);
51
52
  function isUtoopackProxyStartupError(error, utooServePort) {
52
53
  return (error == null ? void 0 : error.code) === "ECONNREFUSED" && Number(error == null ? void 0 : error.port) === utooServePort && (!(error == null ? void 0 : error.address) || error.address === "127.0.0.1");
53
54
  }
55
+ function addStatsCompatibility(stats) {
56
+ stats.hasErrors = () => false;
57
+ stats.toJson = () => stats;
58
+ stats.toString = () => {
59
+ };
60
+ stats.compilation = {
61
+ ...stats,
62
+ assets: (stats.assets || []).reduce(
63
+ (acc, cur) => Object.assign(acc, { [cur.name]: cur }),
64
+ {}
65
+ )
66
+ };
67
+ return stats;
68
+ }
69
+ function createDevStatsFromClientPaths(clientPaths, entryNames) {
70
+ const assets = Array.from(new Set(clientPaths ?? [])).map((name) => ({
71
+ name
72
+ }));
73
+ return addStatsCompatibility({
74
+ assets,
75
+ chunks: [],
76
+ modules: [],
77
+ entrypoints: Object.fromEntries(
78
+ entryNames.map((entryName) => [entryName, { assets, chunks: [] }])
79
+ )
80
+ });
81
+ }
54
82
  function getUtoopackRootDir(cwd, utoopackConfig, findRootDir2) {
55
83
  const normalizedCwd = (0, import_config.normalizeUtoopackPath)(cwd);
56
84
  if (typeof (utoopackConfig == null ? void 0 : utoopackConfig.root) === "string") {
@@ -306,30 +334,24 @@ async function dev(opts) {
306
334
  `File stats.json not found by utoopack dev at ${statsPath}: ${e.message}`
307
335
  );
308
336
  }
309
- stats.hasErrors = () => false;
310
- stats.toJson = () => stats;
311
- stats.toString = () => {
312
- };
313
- stats.compilation = {
314
- ...stats,
315
- assets: stats.assets.reduce(
316
- (acc, cur) => Object.assign(acc, { [cur.name]: cur }),
317
- {}
318
- )
319
- };
320
- return stats;
337
+ return addStatsCompatibility(stats);
321
338
  };
339
+ let clientPaths = [];
340
+ const shouldReadFullStats = Boolean(process.env.ANALYZE) || Boolean(utooPackConfig.config.stats);
322
341
  try {
323
342
  await Promise.all([
324
343
  serverReady,
325
344
  utooPackServe(utooPackConfig, normalizedCwd, rootDir, {
326
345
  port: utooServePort,
327
346
  hostname: "127.0.0.1",
328
- logServerInfo: false
347
+ logServerInfo: false,
348
+ onReady(context) {
349
+ clientPaths = context.clientPaths ?? [];
350
+ }
329
351
  })
330
352
  ]);
331
353
  const time = Date.now() - devStartTime;
332
- const stats = createStatsObject();
354
+ const stats = shouldReadFullStats ? createStatsObject() : createDevStatsFromClientPaths(clientPaths, Object.keys(opts.entry));
333
355
  await (onDevCompileDone == null ? void 0 : onDevCompileDone({
334
356
  stats,
335
357
  time,
@@ -354,6 +376,7 @@ async function dev(opts) {
354
376
  0 && (module.exports = {
355
377
  build,
356
378
  buildSSR,
379
+ createDevStatsFromClientPaths,
357
380
  dev,
358
381
  findRootDir,
359
382
  isUtoopackProxyStartupError,
package/dist/types.d.ts CHANGED
@@ -1,8 +1,14 @@
1
1
  import type { IOpts as IConfigOpts } from '@umijs/bundler-webpack';
2
2
  import type { ConfigComplete } from '@utoo/pack';
3
+ export type IUtoopackWatchConfig = {
4
+ pollIntervalMs?: number;
5
+ ignored?: string[];
6
+ nodeModulesRegexes?: string[];
7
+ };
3
8
  export type IUtoopackUserConfig = ConfigComplete & {
4
9
  babelLoader?: boolean;
5
10
  root?: string;
11
+ watch?: IUtoopackWatchConfig;
6
12
  };
7
13
  export type IOpts = {
8
14
  cwd: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@umijs/bundler-utoopack",
3
- "version": "4.6.75",
3
+ "version": "4.6.77",
4
4
  "description": "@umijs/bundler-utoopack",
5
5
  "repository": {
6
6
  "type": "git",
@@ -14,7 +14,7 @@
14
14
  "dist"
15
15
  ],
16
16
  "dependencies": {
17
- "@utoo/pack": "1.4.23",
17
+ "@utoo/pack": "1.4.25",
18
18
  "compression": "^1.7.4",
19
19
  "connect-history-api-fallback": "^2.0.0",
20
20
  "cors": "^2.8.5",
@@ -26,8 +26,8 @@
26
26
  "resolve-url-loader": "5.0.0",
27
27
  "sass": "1.54.0",
28
28
  "sass-loader": "13.2.0",
29
- "@umijs/bundler-utils": "4.6.75",
30
- "@umijs/bundler-webpack": "4.6.75"
29
+ "@umijs/bundler-utils": "4.6.77",
30
+ "@umijs/bundler-webpack": "4.6.77"
31
31
  },
32
32
  "publishConfig": {
33
33
  "access": "public"