@umijs/preset-umi 4.6.67 → 4.6.68

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 (147) hide show
  1. package/dist/commands/build.d.ts +1 -1
  2. package/dist/commands/config/config.d.ts +1 -1
  3. package/dist/commands/config/list.d.ts +1 -1
  4. package/dist/commands/config/remove.js +2 -1
  5. package/dist/commands/config/set.js +2 -1
  6. package/dist/commands/deadcode.d.ts +1 -1
  7. package/dist/commands/deadcode.js +2 -1
  8. package/dist/commands/dev/createRouteMiddleware.js +2 -1
  9. package/dist/commands/dev/depBuildWorker/depBuildWorker.js +3 -3
  10. package/dist/commands/dev/depBuildWorker/depBuilder.d.ts +1 -1
  11. package/dist/commands/dev/depBuildWorker/depBuilder.js +6 -5
  12. package/dist/commands/dev/depBuildWorker/dev-config.d.ts +1 -1
  13. package/dist/commands/dev/depBuildWorker/getConfig.js +2 -2
  14. package/dist/commands/dev/depBuildWorker/workerPreset.d.ts +2 -2
  15. package/dist/commands/dev/dev.d.ts +1 -1
  16. package/dist/commands/dev/dev.js +2 -1
  17. package/dist/commands/generators/api.d.ts +1 -1
  18. package/dist/commands/generators/component.d.ts +1 -1
  19. package/dist/commands/generators/component.js +0 -2
  20. package/dist/commands/generators/cypress.d.ts +1 -1
  21. package/dist/commands/generators/dva.d.ts +1 -1
  22. package/dist/commands/generators/jest.d.ts +1 -1
  23. package/dist/commands/generators/mock.d.ts +1 -1
  24. package/dist/commands/generators/page.d.ts +1 -1
  25. package/dist/commands/generators/page.js +9 -8
  26. package/dist/commands/generators/precommit.d.ts +1 -1
  27. package/dist/commands/generators/prettier.d.ts +1 -1
  28. package/dist/commands/generators/tailwindcss.d.ts +1 -1
  29. package/dist/commands/generators/tsconfig.d.ts +1 -1
  30. package/dist/commands/generators/utils.js +0 -2
  31. package/dist/commands/help.d.ts +1 -1
  32. package/dist/commands/lint.d.ts +1 -1
  33. package/dist/commands/mfsu/mfsu.d.ts +1 -1
  34. package/dist/commands/mfsu/util.js +0 -2
  35. package/dist/commands/plugin.d.ts +1 -1
  36. package/dist/commands/preview.d.ts +1 -1
  37. package/dist/commands/setup.d.ts +1 -1
  38. package/dist/commands/verify-commit.d.ts +1 -1
  39. package/dist/commands/version.d.ts +1 -1
  40. package/dist/constants.d.ts +1 -0
  41. package/dist/constants.js +3 -0
  42. package/dist/features/404/404.d.ts +2 -2
  43. package/dist/features/__sample.d.ts +1 -1
  44. package/dist/features/aiDev/aiDev.d.ts +1 -1
  45. package/dist/features/aiDev/aiDev.js +2 -1
  46. package/dist/features/apiRoute/apiRoute.d.ts +1 -1
  47. package/dist/features/apiRoute/apiRoute.js +2 -1
  48. package/dist/features/apiRoute/dev-server/esbuild.js +2 -1
  49. package/dist/features/apiRoute/request.d.ts +0 -2
  50. package/dist/features/apiRoute/request.js +6 -5
  51. package/dist/features/apiRoute/response.d.ts +0 -1
  52. package/dist/features/apiRoute/response.js +0 -1
  53. package/dist/features/apiRoute/utils.js +18 -9
  54. package/dist/features/appData/appData.d.ts +1 -1
  55. package/dist/features/appData/appData.js +2 -2
  56. package/dist/features/appData/umiInfo.d.ts +1 -1
  57. package/dist/features/bundler/bundler.d.ts +1 -1
  58. package/dist/features/check/babel722.d.ts +1 -1
  59. package/dist/features/check/check.d.ts +1 -1
  60. package/dist/features/classPropertiesLoose/classPropertiesLoose.d.ts +1 -1
  61. package/dist/features/clickToComponent/clickToComponent.d.ts +1 -1
  62. package/dist/features/clientLoader/clientLoader.d.ts +1 -1
  63. package/dist/features/codeSplitting/codeSplitting.d.ts +1 -1
  64. package/dist/features/codeSplitting/codeSplitting.js +4 -2
  65. package/dist/features/configPlugins/configPlugins.d.ts +1 -1
  66. package/dist/features/crossorigin/crossorigin.d.ts +1 -1
  67. package/dist/features/depsOnDemand/depsOnDemand.d.ts +1 -1
  68. package/dist/features/devTool/devTool.d.ts +1 -1
  69. package/dist/features/esbuildHelperChecker/esbuildHelperChecker.d.ts +1 -1
  70. package/dist/features/esbuildHelperChecker/esbuildHelperChecker.js +10 -5
  71. package/dist/features/esmi/Service.js +5 -5
  72. package/dist/features/esmi/esmi.d.ts +1 -1
  73. package/dist/features/exportStatic/exportStatic.d.ts +1 -1
  74. package/dist/features/favicons/favicons.d.ts +1 -1
  75. package/dist/features/favicons/favicons.js +4 -2
  76. package/dist/features/helmet/helmet.d.ts +2 -2
  77. package/dist/features/icons/icons.d.ts +1 -1
  78. package/dist/features/icons/svgr.js +4 -2
  79. package/dist/features/legacy/legacy.d.ts +1 -1
  80. package/dist/features/legacy/legacy.js +6 -6
  81. package/dist/features/lowImport/lowImport.d.ts +1 -1
  82. package/dist/features/mako/mako.d.ts +1 -1
  83. package/dist/features/mock/createMockMiddleware.js +2 -1
  84. package/dist/features/monorepo/redirect.d.ts +1 -1
  85. package/dist/features/monorepo/redirect.js +4 -2
  86. package/dist/features/mpa/mpa.d.ts +1 -1
  87. package/dist/features/mpa/mpa.js +10 -5
  88. package/dist/features/okam/okam.d.ts +1 -1
  89. package/dist/features/overrides/overrides.d.ts +1 -1
  90. package/dist/features/overrides/overrides.js +2 -1
  91. package/dist/features/overrides/transform.js +4 -2
  92. package/dist/features/phantomDependency/phantomDependency.d.ts +1 -1
  93. package/dist/features/phantomDependency/phantomDependency.js +30 -15
  94. package/dist/features/polyfill/polyfill.d.ts +1 -1
  95. package/dist/features/polyfill/publicPathPolyfill.d.ts +1 -1
  96. package/dist/features/prepare/esbuildPlugins/esbuildAliasPlugin.js +8 -4
  97. package/dist/features/prepare/prepare.d.ts +1 -1
  98. package/dist/features/prepare/prepare.js +2 -1
  99. package/dist/features/reactCompiler/forget.d.ts +1 -1
  100. package/dist/features/reactCompiler/reactCompiler.d.ts +1 -1
  101. package/dist/features/reactCompiler/reactCompiler.js +4 -2
  102. package/dist/features/routePrefetch/routePrefetch.d.ts +1 -1
  103. package/dist/features/routePreloadOnLoad/routePreloadOnLoad.d.ts +1 -1
  104. package/dist/features/routePreloadOnLoad/routePreloadOnLoad.js +4 -2
  105. package/dist/features/routeProps/routeProps.d.ts +1 -1
  106. package/dist/features/ssr/builder/css-loader.js +2 -2
  107. package/dist/features/ssr/mako/mako.d.ts +1 -0
  108. package/dist/features/ssr/mako/mako.js +2 -2
  109. package/dist/features/ssr/ssr.d.ts +1 -1
  110. package/dist/features/ssr/ssr.js +4 -3
  111. package/dist/features/ssr/utils.js +4 -2
  112. package/dist/features/ssr/utoopack/utoopack.js +3 -3
  113. package/dist/features/ssr/webpack/webpack.js +2 -2
  114. package/dist/features/stagewise/stagewise.d.ts +1 -1
  115. package/dist/features/swc/swc.d.ts +1 -1
  116. package/dist/features/terminal/terminal.d.ts +1 -1
  117. package/dist/features/test/test.d.ts +1 -1
  118. package/dist/features/tmpFiles/configTypes.d.ts +1 -1
  119. package/dist/features/tmpFiles/getModuleExports.js +2 -2
  120. package/dist/features/tmpFiles/routes.js +7 -6
  121. package/dist/features/tmpFiles/tmpFiles.d.ts +1 -1
  122. package/dist/features/tmpFiles/tmpFiles.js +13 -14
  123. package/dist/features/transform/CodeFrameError.js +0 -1
  124. package/dist/features/transform/transform.d.ts +1 -1
  125. package/dist/features/ui/ui.d.ts +1 -1
  126. package/dist/features/ui/ui.js +2 -1
  127. package/dist/features/utoopack/utoopack.d.ts +1 -1
  128. package/dist/features/vite/vite.d.ts +1 -1
  129. package/dist/features/webpack/webpack.d.ts +1 -1
  130. package/dist/index.d.ts +2 -2
  131. package/dist/libs/folderCache/AutoUpdateFolderCache.js +3 -9
  132. package/dist/libs/folderCache/AutoUpdateSourceCodeCache.d.ts +2 -2
  133. package/dist/libs/folderCache/AutoUpdateSourceCodeCache.js +2 -5
  134. package/dist/libs/folderCache/FolderWatch.js +2 -5
  135. package/dist/libs/folderCache/LazySourceCodeCache.d.ts +2 -2
  136. package/dist/libs/folderCache/LazySourceCodeCache.js +6 -10
  137. package/dist/libs/folderCache/constant.d.ts +28 -28
  138. package/dist/libs/folderCache/types.d.ts +5 -5
  139. package/dist/libs/scan.d.ts +1 -1
  140. package/dist/libs/scan.js +4 -2
  141. package/dist/registerMethods.d.ts +1 -1
  142. package/dist/types.d.ts +12 -13
  143. package/dist/utils/extractEntryAssets.d.ts +1 -1
  144. package/dist/utils/routeExportExtractor.d.ts +1 -1
  145. package/dist/utils/routeExportExtractor.js +2 -1
  146. package/dist/utils/serializeAppData.js +2 -1
  147. package/package.json +15 -15
@@ -102,7 +102,8 @@ function getOriginalAssetName(file) {
102
102
  return `${(0, import_path.basename)(file, ext).replace(/\.[a-f0-9]{8,}$/i, "")}${ext}`;
103
103
  }
104
104
  function walkSourceAssets(dir, cwd, ret = []) {
105
- if (!(0, import_fs.existsSync)(dir)) return ret;
105
+ if (!(0, import_fs.existsSync)(dir))
106
+ return ret;
106
107
  for (const entry of (0, import_fs.readdirSync)(dir, { withFileTypes: true })) {
107
108
  const absPath = (0, import_path.join)(dir, entry.name);
108
109
  if (entry.isDirectory()) {
@@ -144,7 +145,8 @@ function findClientCssFiles(files) {
144
145
  function getSourceAssetMap(api, statsAssets, publicPath) {
145
146
  const outputAssets = statsAssets.filter((file) => assetExts.has((0, import_path.extname)(file))).map((file) => {
146
147
  const absPath = (0, import_path.join)(api.paths.absOutputPath, file);
147
- if (!(0, import_fs.existsSync)(absPath)) return null;
148
+ if (!(0, import_fs.existsSync)(absPath))
149
+ return null;
148
150
  return {
149
151
  file,
150
152
  name: getOriginalAssetName(file),
@@ -32,7 +32,7 @@ __export(utoopack_exports, {
32
32
  build: () => build
33
33
  });
34
34
  module.exports = __toCommonJS(utoopack_exports);
35
- var import_types = require("@umijs/bundler-webpack/dist/types");
35
+ var import_bundler_webpack = require("@umijs/bundler-webpack");
36
36
  var import_utils = require("@umijs/utils");
37
37
  var import_fs = require("fs");
38
38
  var import_path = __toESM(require("path"));
@@ -77,7 +77,7 @@ var build = async (api, opts) => {
77
77
  const absOutputFile = (0, import_utils2.absServerBuildPath)(api);
78
78
  require("@umijs/bundler-webpack/dist/requireHook");
79
79
  const { buildSSR } = require(process.env.UTOOPACK);
80
- const useHash = api.config.hash && api.env === import_types.Env.production;
80
+ const useHash = api.config.hash && api.env === import_bundler_webpack.Env.production;
81
81
  const publicPath = api.userConfig.publicPath || "/";
82
82
  const entry = import_path.default.resolve(api.paths.absTmpPath, "umi.server.ts");
83
83
  const stats = await buildSSR({
@@ -89,7 +89,7 @@ var build = async (api, opts) => {
89
89
  config: api.config,
90
90
  serverBuildPath: absOutputFile,
91
91
  useHash,
92
- isDev: api.env === import_types.Env.development
92
+ isDev: api.env === import_bundler_webpack.Env.development
93
93
  });
94
94
  const serverFile = getServerBuildFile(stats) || (0, import_path.basename)(absOutputFile);
95
95
  const jsonFilePath = (0, import_path.join)((0, import_path.dirname)(absOutputFile), "build-manifest.json");
@@ -33,7 +33,7 @@ __export(webpack_exports, {
33
33
  });
34
34
  module.exports = __toCommonJS(webpack_exports);
35
35
  var bundlerWebpack = __toESM(require("@umijs/bundler-webpack"));
36
- var import_types = require("@umijs/bundler-webpack/dist/types");
36
+ var import_bundler_webpack = require("@umijs/bundler-webpack");
37
37
  var import_utils = require("@umijs/utils");
38
38
  var import_path = require("path");
39
39
  var import_utils2 = require("../utils");
@@ -42,7 +42,7 @@ var build2 = async (api, opts) => {
42
42
  const now = (/* @__PURE__ */ new Date()).getTime();
43
43
  const bundlerOpts = import_utils.lodash.cloneDeep(opts);
44
44
  const oChainWebpack = bundlerOpts.chainWebpack;
45
- const useHash = api.config.hash && api.env === import_types.Env.production;
45
+ const useHash = api.config.hash && api.env === import_bundler_webpack.Env.production;
46
46
  delete bundlerOpts.config.deadCode;
47
47
  bundlerOpts.extraBabelPlugins.push([
48
48
  require.resolve("babel-plugin-dynamic-import-node"),
@@ -1,3 +1,3 @@
1
1
  import { IApi } from '../../types';
2
- declare const _default: (api: IApi) => void;
3
2
  export default _default;
3
+ declare function _default(api: IApi): void;
@@ -1,3 +1,3 @@
1
1
  import { IApi } from '../../types';
2
- declare const _default: (api: IApi) => void;
3
2
  export default _default;
3
+ declare function _default(api: IApi): void;
@@ -1,3 +1,3 @@
1
1
  import { IApi } from '../../types';
2
- declare const _default: (api: IApi) => void;
3
2
  export default _default;
3
+ declare function _default(api: IApi): void;
@@ -1,3 +1,3 @@
1
1
  import { IApi } from '../../types';
2
- declare const _default: (api: IApi) => void;
3
2
  export default _default;
3
+ declare function _default(api: IApi): void;
@@ -1,3 +1,3 @@
1
1
  import { IApi } from '../../types';
2
- declare const _default: (api: IApi) => void;
3
2
  export default _default;
3
+ declare function _default(api: IApi): void;
@@ -29,8 +29,8 @@ async function getModuleExports(opts) {
29
29
  const { file } = opts;
30
30
  const content = (0, import_fs.readFileSync)(file, "utf-8");
31
31
  try {
32
- const [_, exports2] = await (0, import_bundler_utils.parseModule)({ content, path: file });
33
- return exports2 || [];
32
+ const [_, exports] = await (0, import_bundler_utils.parseModule)({ content, path: file });
33
+ return exports || [];
34
34
  } catch (e) {
35
35
  console.log(
36
36
  `Parse file ${import_utils.chalk.red(
@@ -151,17 +151,17 @@ async function getRoutes(opts) {
151
151
  const enableRouteProps = !opts.api.userConfig.routes;
152
152
  const needCollectExports = enableSSR || enableClientLoader || enableRouteProps;
153
153
  if (needCollectExports) {
154
- const exports2 = isJSFile && (0, import_fs.existsSync)(file) ? await (0, import_getModuleExports.getModuleExports)({
154
+ const exports = isJSFile && (0, import_fs.existsSync)(file) ? await (0, import_getModuleExports.getModuleExports)({
155
155
  file
156
156
  }) : [];
157
157
  if (enableSSR) {
158
- routes[id].hasServerLoader = exports2.includes("serverLoader");
159
- routes[id].hasMetadataLoader = exports2.includes("metadataLoader");
158
+ routes[id].hasServerLoader = exports.includes("serverLoader");
159
+ routes[id].hasMetadataLoader = exports.includes("metadataLoader");
160
160
  }
161
- if (enableClientLoader && exports2.includes("clientLoader")) {
161
+ if (enableClientLoader && exports.includes("clientLoader")) {
162
162
  routes[id].clientLoader = `clientLoaders['${id}']`;
163
163
  }
164
- if (enableRouteProps && exports2.includes("routeProps")) {
164
+ if (enableRouteProps && exports.includes("routeProps")) {
165
165
  routes[id].routeProps = `routeProps['${id}']`;
166
166
  }
167
167
  }
@@ -239,7 +239,8 @@ function getProjectRootCwd(cwd) {
239
239
  const splittedCwd = cwd.split("/");
240
240
  for (let level = -1; level >= -3; level -= 1) {
241
241
  const rootCwd = splittedCwd.slice(0, level).join("/");
242
- if (!rootCwd) break;
242
+ if (!rootCwd)
243
+ break;
243
244
  if ((0, import_utils.isMonorepo)({ root: rootCwd })) {
244
245
  return rootCwd;
245
246
  }
@@ -1,3 +1,3 @@
1
1
  import { IApi } from '../../types';
2
- declare const _default: (api: IApi) => void;
3
2
  export default _default;
3
+ declare function _default(api: IApi): void;
@@ -35,7 +35,6 @@ module.exports = __toCommonJS(tmpFiles_exports);
35
35
  var import_utils = require("@umijs/utils");
36
36
  var import_fs = require("fs");
37
37
  var import_path = require("path");
38
- var import_umi = require("umi");
39
38
  var import_getMarkupArgs = require("../../commands/dev/getMarkupArgs");
40
39
  var import_constants = require("../../constants");
41
40
  var import_getModuleExports = require("./getModuleExports");
@@ -584,36 +583,36 @@ if (process.env.NODE_ENV === 'development') {
584
583
  )
585
584
  })
586
585
  );
587
- const exports2 = [];
586
+ const exports = [];
588
587
  const beforeExports = [];
589
588
  const afterExports = [];
590
589
  const exportMembers = ["default"];
591
- exports2.push("// @umijs/renderer-*");
592
- exports2.push(
590
+ exports.push("// @umijs/renderer-*");
591
+ exports.push(
593
592
  `export { ${(await getExportsAndCheck({
594
593
  path: (0, import_path.join)(rendererPath, "dist/index.js"),
595
594
  exportMembers
596
595
  })).join(", ")} } from '${rendererPath}';`
597
596
  );
598
- exports2.push(
597
+ exports.push(
599
598
  `export type { History, ClientLoader } from '${rendererPath}'`
600
599
  );
601
- exports2.push("// umi/client/client/plugin");
600
+ exports.push("// umi/client/client/plugin");
602
601
  const umiPluginPath = (0, import_utils.winPath)((0, import_path.join)(umiDir, "client/client/plugin.js"));
603
- exports2.push(
602
+ exports.push(
604
603
  `export { ${(await getExportsAndCheck({
605
604
  path: umiPluginPath,
606
605
  exportMembers
607
606
  })).join(", ")} } from '${umiPluginPath}';`
608
607
  );
609
- exports2.push(`export { history, createHistory } from './core/history';`);
608
+ exports.push(`export { history, createHistory } from './core/history';`);
610
609
  checkMembers({
611
610
  members: ["history", "createHistory"],
612
611
  exportMembers,
613
612
  path: "@@/core/history.ts"
614
613
  });
615
614
  if (api.service.config.terminal !== false) {
616
- exports2.push(`export { terminal } from './core/terminal';`);
615
+ exports.push(`export { terminal } from './core/terminal';`);
617
616
  checkMembers({
618
617
  members: ["terminal"],
619
618
  exportMembers,
@@ -630,13 +629,13 @@ if (process.env.NODE_ENV === 'development') {
630
629
  }
631
630
  }
632
631
  if (api.appData.framework === "react") {
633
- exports2.push("// react ssr");
632
+ exports.push("// react ssr");
634
633
  if (api.config.ssr) {
635
- exports2.push(
634
+ exports.push(
636
635
  `export { useServerInsertedHTML } from './core/serverInsertedHTMLContext';`
637
636
  );
638
637
  } else {
639
- exports2.push(
638
+ exports.push(
640
639
  `export const useServerInsertedHTML: Function = () => {};`
641
640
  );
642
641
  }
@@ -683,7 +682,7 @@ if (process.env.NODE_ENV === 'development') {
683
682
  let runtimeConfigType = "export type RuntimeConfig = IDefaultRuntimeConfig";
684
683
  for (const plugin of allPlugins) {
685
684
  const runtimeConfigFile = (0, import_utils.winPath)(
686
- (0, import_path.join)(api.paths.absTmpPath, plugin, import_umi.RUNTIME_TYPE_FILE_NAME)
685
+ (0, import_path.join)(api.paths.absTmpPath, plugin, import_constants.RUNTIME_TYPE_FILE_NAME)
687
686
  );
688
687
  if ((0, import_fs.existsSync)(runtimeConfigFile)) {
689
688
  const noSuffixRuntimeConfigFile = runtimeConfigFile.replace(
@@ -716,7 +715,7 @@ if (process.env.NODE_ENV === 'development') {
716
715
  api.writeTmpFile({
717
716
  noPluginDir: true,
718
717
  path: "exports.ts",
719
- content: [...beforeExports, ...exports2, ...afterExports].join("\n")
718
+ content: [...beforeExports, ...exports, ...afterExports].join("\n")
720
719
  });
721
720
  },
722
721
  stage: 1e4
@@ -23,7 +23,6 @@ __export(CodeFrameError_exports, {
23
23
  });
24
24
  module.exports = __toCommonJS(CodeFrameError_exports);
25
25
  var CodeFrameError = class extends Error {
26
- location;
27
26
  constructor(msg, location) {
28
27
  super(msg);
29
28
  this.location = location;
@@ -1,3 +1,3 @@
1
1
  import { IApi } from '../../types';
2
- declare const _default: (api: IApi) => void;
3
2
  export default _default;
3
+ declare function _default(api: IApi): void;
@@ -1,3 +1,3 @@
1
1
  import { IApi } from '../../types';
2
- declare const _default: (api: IApi) => void;
3
2
  export default _default;
3
+ declare function _default(api: IApi): void;
@@ -124,7 +124,8 @@ var ui_default = (api) => {
124
124
  return memo;
125
125
  });
126
126
  api.onGenerateFiles(({ isFirstTime }) => {
127
- if (!isFirstTime) return;
127
+ if (!isFirstTime)
128
+ return;
128
129
  api.writeTmpFile({
129
130
  path: "core/ui.ts",
130
131
  noPluginDir: true,
@@ -1,4 +1,4 @@
1
1
  import { IApi } from '../../types';
2
2
  export declare function getPackVersionFromBundler(bundlerEntry: string): any;
3
- declare const _default: (api: IApi) => void;
4
3
  export default _default;
4
+ declare function _default(api: IApi): void;
@@ -1,3 +1,3 @@
1
1
  import type { IApi } from '../../types';
2
- declare const _default: (api: IApi) => void;
3
2
  export default _default;
3
+ declare function _default(api: IApi): void;
@@ -1,3 +1,3 @@
1
1
  import { IApi } from '../../types';
2
- declare const _default: (api: IApi) => void;
3
2
  export default _default;
3
+ declare function _default(api: IApi): void;
package/dist/index.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  export type { UmiApiRequest, UmiApiResponse } from './features/apiRoute';
2
2
  export type { IApi, IConfig, IRoute, IUtoopackUserConfig, webpack, } from './types';
3
- declare const _default: () => {
3
+ export default _default;
4
+ declare function _default(): {
4
5
  plugins: (string | false)[];
5
6
  };
6
- export default _default;
@@ -27,15 +27,9 @@ var import_fs = require("fs");
27
27
  var import_path = require("path");
28
28
  var { watch } = import_utils.chokidar;
29
29
  var AutoUpdateFolderCache = class {
30
- fileContentCache = {};
31
- watcher;
32
- readyPromise;
33
- cwd;
34
- pendingChanges = [];
35
- debouchedHandleChanges;
36
- onCacheUpdated;
37
- filesLoader;
38
30
  constructor(opts) {
31
+ this.fileContentCache = {};
32
+ this.pendingChanges = [];
39
33
  this.cwd = opts.cwd;
40
34
  this.onCacheUpdated = opts.onCacheUpdate;
41
35
  this.filesLoader = opts.filesLoader || this._defaultLoader;
@@ -65,7 +59,7 @@ var AutoUpdateFolderCache = class {
65
59
  modifiedFiles.push(c.path);
66
60
  break;
67
61
  default:
68
- /* @__PURE__ */ ((_n) => {
62
+ ((_n) => {
69
63
  })(c.event);
70
64
  }
71
65
  }
@@ -1,12 +1,12 @@
1
1
  import { ImportSpecifier } from '@umijs/bundler-utils/compiled/es-module-lexer';
2
2
  import { AutoUpdateFolderCache } from './AutoUpdateFolderCache';
3
3
  import type { FileChangeEvent } from './types';
4
- export declare type MergedCodeInfo = {
4
+ export type MergedCodeInfo = {
5
5
  code: string;
6
6
  imports: readonly ImportSpecifier[];
7
7
  events: FileChangeEvent[];
8
8
  };
9
- export declare type Listener = (info: MergedCodeInfo) => void;
9
+ export type Listener = (info: MergedCodeInfo) => void;
10
10
  export declare class AutoUpdateSrcCodeCache {
11
11
  private readonly srcPath;
12
12
  private readonly cachePath;
@@ -41,12 +41,9 @@ var import_path = require("path");
41
41
  var import_AutoUpdateFolderCache = require("./AutoUpdateFolderCache");
42
42
  var import_constant = require("./constant");
43
43
  var AutoUpdateSrcCodeCache = class {
44
- srcPath;
45
- cachePath;
46
- folderCache;
47
- listeners = [];
48
- ignores = import_constant.DEFAULT_SRC_IGNORES;
49
44
  constructor(opts) {
45
+ this.listeners = [];
46
+ this.ignores = import_constant.DEFAULT_SRC_IGNORES;
50
47
  this.srcPath = opts.cwd;
51
48
  this.cachePath = opts.cachePath;
52
49
  this.folderCache = new import_AutoUpdateFolderCache.AutoUpdateFolderCache({
@@ -26,12 +26,9 @@ var import_utils = require("@umijs/utils");
26
26
  var import_path = require("path");
27
27
  var { watch } = import_utils.chokidar;
28
28
  var FolderWatch = class {
29
- cwd;
30
- watcher;
31
- readyPromise;
32
- listeners = [];
33
- eventMap = { add: 0, unlink: 0, change: 0 };
34
29
  constructor(opts) {
30
+ this.listeners = [];
31
+ this.eventMap = { add: 0, unlink: 0, change: 0 };
35
32
  this.cwd = opts.cwd;
36
33
  this.watcher = watch(`./**/*.{${opts.exts.join(",")}}`, {
37
34
  ignored: opts.ignored || [],
@@ -1,10 +1,10 @@
1
1
  import { ImportSpecifier } from '@umijs/bundler-utils/compiled/es-module-lexer';
2
2
  import type { FileChangeEvent, FileContentCache } from './types';
3
- export declare type MergedCodeInfo = {
3
+ export type MergedCodeInfo = {
4
4
  code: string;
5
5
  imports: readonly ImportSpecifier[];
6
6
  };
7
- export declare type Listener = (info: MergedCodeInfo) => void;
7
+ export type Listener = (info: MergedCodeInfo) => void;
8
8
  export declare class LazySourceCodeCache {
9
9
  private readonly srcPath;
10
10
  private readonly cachePath;
@@ -41,16 +41,12 @@ var import_path = require("path");
41
41
  var import_constant = require("./constant");
42
42
  var import_FolderWatch = require("./FolderWatch");
43
43
  var LazySourceCodeCache = class {
44
- srcPath;
45
- cachePath;
46
- folderWatch;
47
- listeners = [];
48
- ignores = import_constant.DEFAULT_SRC_IGNORES;
49
- fileContentCache = {};
50
- pendingFilesEvents = [];
51
- root;
52
- tsConfigRaw = "{}";
53
44
  constructor(opts) {
45
+ this.listeners = [];
46
+ this.ignores = import_constant.DEFAULT_SRC_IGNORES;
47
+ this.fileContentCache = {};
48
+ this.pendingFilesEvents = [];
49
+ this.tsConfigRaw = "{}";
54
50
  this.root = opts.root;
55
51
  this.srcPath = opts.cwd;
56
52
  this.cachePath = opts.cachePath;
@@ -147,7 +143,7 @@ var LazySourceCodeCache = class {
147
143
  modifiedFiles.push(c.path);
148
144
  break;
149
145
  default:
150
- /* @__PURE__ */ ((_n) => {
146
+ ((_n) => {
151
147
  })(c.event);
152
148
  }
153
149
  }
@@ -1,31 +1,31 @@
1
1
  export declare const DEFAULT_SRC_IGNORES: string[];
2
2
  export declare const possibleExtUsingEmptyLoader: {
3
- readonly '.aac': "empty";
4
- readonly '.css': "empty";
5
- readonly '.less': "empty";
6
- readonly '.sass': "empty";
7
- readonly '.scss': "empty";
8
- readonly '.eot': "empty";
9
- readonly '.flac': "empty";
10
- readonly '.gif': "empty";
11
- readonly '.htm': "empty";
12
- readonly '.html': "empty";
13
- readonly '.ico': "empty";
14
- readonly '.icon': "empty";
15
- readonly '.jpeg': "empty";
16
- readonly '.jpg': "empty";
17
- readonly '.empty': "empty";
18
- readonly '.mdx': "empty";
19
- readonly '.mp3': "empty";
20
- readonly '.mp4': "empty";
21
- readonly '.ogg': "empty";
22
- readonly '.otf': "empty";
23
- readonly '.png': "empty";
24
- readonly '.svg': "empty";
25
- readonly '.ttf': "empty";
26
- readonly '.wav': "empty";
27
- readonly '.webm': "empty";
28
- readonly '.webp': "empty";
29
- readonly '.woff': "empty";
30
- readonly '.woff2': "empty";
3
+ readonly '.aac': 'empty';
4
+ readonly '.css': 'empty';
5
+ readonly '.less': 'empty';
6
+ readonly '.sass': 'empty';
7
+ readonly '.scss': 'empty';
8
+ readonly '.eot': 'empty';
9
+ readonly '.flac': 'empty';
10
+ readonly '.gif': 'empty';
11
+ readonly '.htm': 'empty';
12
+ readonly '.html': 'empty';
13
+ readonly '.ico': 'empty';
14
+ readonly '.icon': 'empty';
15
+ readonly '.jpeg': 'empty';
16
+ readonly '.jpg': 'empty';
17
+ readonly '.empty': 'empty';
18
+ readonly '.mdx': 'empty';
19
+ readonly '.mp3': 'empty';
20
+ readonly '.mp4': 'empty';
21
+ readonly '.ogg': 'empty';
22
+ readonly '.otf': 'empty';
23
+ readonly '.png': 'empty';
24
+ readonly '.svg': 'empty';
25
+ readonly '.ttf': 'empty';
26
+ readonly '.wav': 'empty';
27
+ readonly '.webm': 'empty';
28
+ readonly '.webp': 'empty';
29
+ readonly '.woff': 'empty';
30
+ readonly '.woff2': 'empty';
31
31
  };
@@ -1,9 +1,9 @@
1
- declare type FileContent = string;
2
- export declare type AbsPath = string;
3
- export declare type FileContentCache = Record<AbsPath, FileContent>;
4
- export declare type FileChangeEvent = {
1
+ type FileContent = string;
2
+ export type AbsPath = string;
3
+ export type FileContentCache = Record<AbsPath, FileContent>;
4
+ export type FileChangeEvent = {
5
5
  event: 'unlink' | 'change' | 'add';
6
6
  path: string;
7
7
  };
8
- export declare type Event = FileChangeEvent['event'];
8
+ export type Event = FileChangeEvent['event'];
9
9
  export {};
@@ -28,6 +28,6 @@ export declare function scan(opts: {
28
28
  version: string;
29
29
  matches: string[];
30
30
  subpaths: string[];
31
- external?: boolean | undefined;
31
+ external?: boolean;
32
32
  }>>;
33
33
  export {};
package/dist/libs/scan.js CHANGED
@@ -62,7 +62,8 @@ async function scanContent(opts) {
62
62
  }
63
63
  ).map((imp) => {
64
64
  let importType = "import" /* import */;
65
- if (imp.d > -1) importType = "dynamicImport" /* dynamicImport */;
65
+ if (imp.d > -1)
66
+ importType = "dynamicImport" /* dynamicImport */;
66
67
  if (opts.content.slice(imp.ss, imp.se).startsWith("export ")) {
67
68
  importType = "export" /* export */;
68
69
  }
@@ -109,7 +110,8 @@ async function scan(opts) {
109
110
  const ret = {};
110
111
  while (queueDeps.length) {
111
112
  const depPath = queueDeps.shift();
112
- if (cache.has(depPath)) continue;
113
+ if (cache.has(depPath))
114
+ continue;
113
115
  const content = await getContent(depPath);
114
116
  const { deps } = await scanContent({ content });
115
117
  cache.set(depPath, deps);
@@ -1,3 +1,3 @@
1
1
  import { IApi } from './types';
2
- declare const _default: (api: IApi) => void;
3
2
  export default _default;
3
+ declare function _default(api: IApi): void;
package/dist/types.d.ts CHANGED
@@ -1,9 +1,8 @@
1
1
  import type { ImportDeclaration } from '@umijs/bundler-utils/compiled/@babel/types';
2
2
  import type { BuildResult as ESBuildBuildResult, Plugin as ESBuildPlugin } from '@umijs/bundler-utils/compiled/esbuild';
3
- import type { Express, RequestHandler, webpack } from '@umijs/bundler-webpack';
3
+ import type { Express, IConfig, RequestHandler, webpack } from '@umijs/bundler-webpack';
4
4
  import type WebpackChain from '@umijs/bundler-webpack/compiled/webpack-5-chain';
5
5
  import { createWebSocketServer } from '@umijs/bundler-webpack/dist/server/ws';
6
- import type { IConfig } from '@umijs/bundler-webpack/dist/types';
7
6
  import type { IAdd, IEvent, IModify, IRoute as ICoreRoute, IServicePluginAPI, PluginAPI } from '@umijs/core';
8
7
  import { Env } from '@umijs/core';
9
8
  import type { getMarkup } from '@umijs/server';
@@ -15,7 +14,7 @@ import type CodeFrameError from './features/transform/CodeFrameError';
15
14
  export type { IUtoopackUserConfig } from '@umijs/bundler-utoopack';
16
15
  export { UmiApiRequest, UmiApiResponse } from './features/apiRoute';
17
16
  export { webpack, IConfig };
18
- export declare type IScript = Partial<{
17
+ export type IScript = Partial<{
19
18
  async: boolean;
20
19
  charset: string;
21
20
  content: string;
@@ -24,12 +23,12 @@ export declare type IScript = Partial<{
24
23
  src: string;
25
24
  type: string;
26
25
  }> | string;
27
- export declare type IStyle = Partial<{
26
+ export type IStyle = Partial<{
28
27
  content: string;
29
28
  src: string;
30
29
  type: string;
31
30
  }> | string;
32
- export declare type ILink = Partial<{
31
+ export type ILink = Partial<{
33
32
  as: string;
34
33
  crossOrigin: string | null;
35
34
  disabled: boolean;
@@ -45,22 +44,22 @@ export declare type ILink = Partial<{
45
44
  target: string;
46
45
  type: string;
47
46
  }>;
48
- export declare type IMeta = Partial<{
47
+ export type IMeta = Partial<{
49
48
  content: string;
50
49
  'http-equiv': string;
51
50
  name: string;
52
51
  scheme: string;
53
52
  }>;
54
- export declare type IApiMiddleware = {
53
+ export type IApiMiddleware = {
55
54
  name: string;
56
55
  path: string;
57
56
  };
58
- export declare type IEntryImport = {
57
+ export type IEntryImport = {
59
58
  source: string;
60
59
  specifier?: string;
61
60
  };
62
- export declare type IRoute = ICoreRoute;
63
- export declare type IFileInfo = Array<{
61
+ export type IRoute = ICoreRoute;
62
+ export type IFileInfo = Array<{
64
63
  event: string;
65
64
  path: string;
66
65
  }>;
@@ -79,8 +78,8 @@ export interface IUIModule {
79
78
  menus?: IUIMenu[];
80
79
  [key: string]: any;
81
80
  }
82
- export declare type GenerateFilesFn = (opts: IOnGenerateFiles) => Promise<void>;
83
- export declare type OnConfigChangeFn = (opts: {
81
+ export type GenerateFilesFn = (opts: IOnGenerateFiles) => Promise<void>;
82
+ export type OnConfigChangeFn = (opts: {
84
83
  generate: GenerateFilesFn;
85
84
  }) => void | Promise<void>;
86
85
  export interface IUniBundlerInstance {
@@ -99,7 +98,7 @@ export interface IBundlerOpts {
99
98
  host: string;
100
99
  [key: string]: any;
101
100
  }
102
- export declare type IApi = PluginAPI & IServicePluginAPI & {
101
+ export type IApi = PluginAPI & IServicePluginAPI & {
103
102
  addApiMiddlewares: IAdd<null, IApiMiddleware>;
104
103
  addBeforeBabelPlugins: IAdd<null, any>;
105
104
  addBeforeBabelPresets: IAdd<null, any>;
@@ -1,4 +1,4 @@
1
- export declare type EntryAssets = {
1
+ export type EntryAssets = {
2
2
  js: string[];
3
3
  css: string[];
4
4
  [key: string]: string[];
@@ -9,6 +9,6 @@ interface IRouteExportExtractorGenTmpFileOpts extends IRouteExportExtractor {
9
9
  interface IRouteExportExtractorSetupBuilderOpts extends IRouteExportExtractor {
10
10
  outFile: string;
11
11
  }
12
- declare type ISetupRouteExportExtractorOpts = IRouteExportExtractorGenTmpFileOpts & IRouteExportExtractorSetupBuilderOpts;
12
+ type ISetupRouteExportExtractorOpts = IRouteExportExtractorGenTmpFileOpts & IRouteExportExtractorSetupBuilderOpts;
13
13
  export declare function setupRouteExportExtractor(opts: ISetupRouteExportExtractorOpts): void;
14
14
  export {};
@@ -96,7 +96,8 @@ async function setupExportExtractBuilder(opts) {
96
96
  setup(build) {
97
97
  let entry;
98
98
  build.onResolve({ filter: /.*/ }, (args) => {
99
- if (args.kind === "entry-point") entry = args.path;
99
+ if (args.kind === "entry-point")
100
+ entry = args.path;
100
101
  if (args.kind === "entry-point" || args.importer === entry) {
101
102
  return { path: (0, import_path.resolve)(args.resolveDir, args.path) };
102
103
  }