@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.
- package/dist/commands/build.d.ts +1 -1
- package/dist/commands/config/config.d.ts +1 -1
- package/dist/commands/config/list.d.ts +1 -1
- package/dist/commands/config/remove.js +2 -1
- package/dist/commands/config/set.js +2 -1
- package/dist/commands/deadcode.d.ts +1 -1
- package/dist/commands/deadcode.js +2 -1
- package/dist/commands/dev/createRouteMiddleware.js +2 -1
- package/dist/commands/dev/depBuildWorker/depBuildWorker.js +3 -3
- package/dist/commands/dev/depBuildWorker/depBuilder.d.ts +1 -1
- package/dist/commands/dev/depBuildWorker/depBuilder.js +6 -5
- package/dist/commands/dev/depBuildWorker/dev-config.d.ts +1 -1
- package/dist/commands/dev/depBuildWorker/getConfig.js +2 -2
- package/dist/commands/dev/depBuildWorker/workerPreset.d.ts +2 -2
- package/dist/commands/dev/dev.d.ts +1 -1
- package/dist/commands/dev/dev.js +2 -1
- package/dist/commands/generators/api.d.ts +1 -1
- package/dist/commands/generators/component.d.ts +1 -1
- package/dist/commands/generators/component.js +0 -2
- package/dist/commands/generators/cypress.d.ts +1 -1
- package/dist/commands/generators/dva.d.ts +1 -1
- package/dist/commands/generators/jest.d.ts +1 -1
- package/dist/commands/generators/mock.d.ts +1 -1
- package/dist/commands/generators/page.d.ts +1 -1
- package/dist/commands/generators/page.js +9 -8
- package/dist/commands/generators/precommit.d.ts +1 -1
- package/dist/commands/generators/prettier.d.ts +1 -1
- package/dist/commands/generators/tailwindcss.d.ts +1 -1
- package/dist/commands/generators/tsconfig.d.ts +1 -1
- package/dist/commands/generators/utils.js +0 -2
- package/dist/commands/help.d.ts +1 -1
- package/dist/commands/lint.d.ts +1 -1
- package/dist/commands/mfsu/mfsu.d.ts +1 -1
- package/dist/commands/mfsu/util.js +0 -2
- package/dist/commands/plugin.d.ts +1 -1
- package/dist/commands/preview.d.ts +1 -1
- package/dist/commands/setup.d.ts +1 -1
- package/dist/commands/verify-commit.d.ts +1 -1
- package/dist/commands/version.d.ts +1 -1
- package/dist/constants.d.ts +1 -0
- package/dist/constants.js +3 -0
- package/dist/features/404/404.d.ts +2 -2
- package/dist/features/__sample.d.ts +1 -1
- package/dist/features/aiDev/aiDev.d.ts +1 -1
- package/dist/features/aiDev/aiDev.js +2 -1
- package/dist/features/apiRoute/apiRoute.d.ts +1 -1
- package/dist/features/apiRoute/apiRoute.js +2 -1
- package/dist/features/apiRoute/dev-server/esbuild.js +2 -1
- package/dist/features/apiRoute/request.d.ts +0 -2
- package/dist/features/apiRoute/request.js +6 -5
- package/dist/features/apiRoute/response.d.ts +0 -1
- package/dist/features/apiRoute/response.js +0 -1
- package/dist/features/apiRoute/utils.js +18 -9
- package/dist/features/appData/appData.d.ts +1 -1
- package/dist/features/appData/appData.js +2 -2
- package/dist/features/appData/umiInfo.d.ts +1 -1
- package/dist/features/bundler/bundler.d.ts +1 -1
- package/dist/features/check/babel722.d.ts +1 -1
- package/dist/features/check/check.d.ts +1 -1
- package/dist/features/classPropertiesLoose/classPropertiesLoose.d.ts +1 -1
- package/dist/features/clickToComponent/clickToComponent.d.ts +1 -1
- package/dist/features/clientLoader/clientLoader.d.ts +1 -1
- package/dist/features/codeSplitting/codeSplitting.d.ts +1 -1
- package/dist/features/codeSplitting/codeSplitting.js +4 -2
- package/dist/features/configPlugins/configPlugins.d.ts +1 -1
- package/dist/features/crossorigin/crossorigin.d.ts +1 -1
- package/dist/features/depsOnDemand/depsOnDemand.d.ts +1 -1
- package/dist/features/devTool/devTool.d.ts +1 -1
- package/dist/features/esbuildHelperChecker/esbuildHelperChecker.d.ts +1 -1
- package/dist/features/esbuildHelperChecker/esbuildHelperChecker.js +10 -5
- package/dist/features/esmi/Service.js +5 -5
- package/dist/features/esmi/esmi.d.ts +1 -1
- package/dist/features/exportStatic/exportStatic.d.ts +1 -1
- package/dist/features/favicons/favicons.d.ts +1 -1
- package/dist/features/favicons/favicons.js +4 -2
- package/dist/features/helmet/helmet.d.ts +2 -2
- package/dist/features/icons/icons.d.ts +1 -1
- package/dist/features/icons/svgr.js +4 -2
- package/dist/features/legacy/legacy.d.ts +1 -1
- package/dist/features/legacy/legacy.js +6 -6
- package/dist/features/lowImport/lowImport.d.ts +1 -1
- package/dist/features/mako/mako.d.ts +1 -1
- package/dist/features/mock/createMockMiddleware.js +2 -1
- package/dist/features/monorepo/redirect.d.ts +1 -1
- package/dist/features/monorepo/redirect.js +4 -2
- package/dist/features/mpa/mpa.d.ts +1 -1
- package/dist/features/mpa/mpa.js +10 -5
- package/dist/features/okam/okam.d.ts +1 -1
- package/dist/features/overrides/overrides.d.ts +1 -1
- package/dist/features/overrides/overrides.js +2 -1
- package/dist/features/overrides/transform.js +4 -2
- package/dist/features/phantomDependency/phantomDependency.d.ts +1 -1
- package/dist/features/phantomDependency/phantomDependency.js +30 -15
- package/dist/features/polyfill/polyfill.d.ts +1 -1
- package/dist/features/polyfill/publicPathPolyfill.d.ts +1 -1
- package/dist/features/prepare/esbuildPlugins/esbuildAliasPlugin.js +8 -4
- package/dist/features/prepare/prepare.d.ts +1 -1
- package/dist/features/prepare/prepare.js +2 -1
- package/dist/features/reactCompiler/forget.d.ts +1 -1
- package/dist/features/reactCompiler/reactCompiler.d.ts +1 -1
- package/dist/features/reactCompiler/reactCompiler.js +4 -2
- package/dist/features/routePrefetch/routePrefetch.d.ts +1 -1
- package/dist/features/routePreloadOnLoad/routePreloadOnLoad.d.ts +1 -1
- package/dist/features/routePreloadOnLoad/routePreloadOnLoad.js +4 -2
- package/dist/features/routeProps/routeProps.d.ts +1 -1
- package/dist/features/ssr/builder/css-loader.js +2 -2
- package/dist/features/ssr/mako/mako.d.ts +1 -0
- package/dist/features/ssr/mako/mako.js +2 -2
- package/dist/features/ssr/ssr.d.ts +1 -1
- package/dist/features/ssr/ssr.js +4 -3
- package/dist/features/ssr/utils.js +4 -2
- package/dist/features/ssr/utoopack/utoopack.js +3 -3
- package/dist/features/ssr/webpack/webpack.js +2 -2
- package/dist/features/stagewise/stagewise.d.ts +1 -1
- package/dist/features/swc/swc.d.ts +1 -1
- package/dist/features/terminal/terminal.d.ts +1 -1
- package/dist/features/test/test.d.ts +1 -1
- package/dist/features/tmpFiles/configTypes.d.ts +1 -1
- package/dist/features/tmpFiles/getModuleExports.js +2 -2
- package/dist/features/tmpFiles/routes.js +7 -6
- package/dist/features/tmpFiles/tmpFiles.d.ts +1 -1
- package/dist/features/tmpFiles/tmpFiles.js +13 -14
- package/dist/features/transform/CodeFrameError.js +0 -1
- package/dist/features/transform/transform.d.ts +1 -1
- package/dist/features/ui/ui.d.ts +1 -1
- package/dist/features/ui/ui.js +2 -1
- package/dist/features/utoopack/utoopack.d.ts +1 -1
- package/dist/features/vite/vite.d.ts +1 -1
- package/dist/features/webpack/webpack.d.ts +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/libs/folderCache/AutoUpdateFolderCache.js +3 -9
- package/dist/libs/folderCache/AutoUpdateSourceCodeCache.d.ts +2 -2
- package/dist/libs/folderCache/AutoUpdateSourceCodeCache.js +2 -5
- package/dist/libs/folderCache/FolderWatch.js +2 -5
- package/dist/libs/folderCache/LazySourceCodeCache.d.ts +2 -2
- package/dist/libs/folderCache/LazySourceCodeCache.js +6 -10
- package/dist/libs/folderCache/constant.d.ts +28 -28
- package/dist/libs/folderCache/types.d.ts +5 -5
- package/dist/libs/scan.d.ts +1 -1
- package/dist/libs/scan.js +4 -2
- package/dist/registerMethods.d.ts +1 -1
- package/dist/types.d.ts +12 -13
- package/dist/utils/extractEntryAssets.d.ts +1 -1
- package/dist/utils/routeExportExtractor.d.ts +1 -1
- package/dist/utils/routeExportExtractor.js +2 -1
- package/dist/utils/serializeAppData.js +2 -1
- 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))
|
|
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))
|
|
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
|
|
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 ===
|
|
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 ===
|
|
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
|
|
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 ===
|
|
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"),
|
|
@@ -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 [_,
|
|
33
|
-
return
|
|
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
|
|
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 =
|
|
159
|
-
routes[id].hasMetadataLoader =
|
|
158
|
+
routes[id].hasServerLoader = exports.includes("serverLoader");
|
|
159
|
+
routes[id].hasMetadataLoader = exports.includes("metadataLoader");
|
|
160
160
|
}
|
|
161
|
-
if (enableClientLoader &&
|
|
161
|
+
if (enableClientLoader && exports.includes("clientLoader")) {
|
|
162
162
|
routes[id].clientLoader = `clientLoaders['${id}']`;
|
|
163
163
|
}
|
|
164
|
-
if (enableRouteProps &&
|
|
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)
|
|
242
|
+
if (!rootCwd)
|
|
243
|
+
break;
|
|
243
244
|
if ((0, import_utils.isMonorepo)({ root: rootCwd })) {
|
|
244
245
|
return rootCwd;
|
|
245
246
|
}
|
|
@@ -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
|
|
586
|
+
const exports = [];
|
|
588
587
|
const beforeExports = [];
|
|
589
588
|
const afterExports = [];
|
|
590
589
|
const exportMembers = ["default"];
|
|
591
|
-
|
|
592
|
-
|
|
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
|
-
|
|
597
|
+
exports.push(
|
|
599
598
|
`export type { History, ClientLoader } from '${rendererPath}'`
|
|
600
599
|
);
|
|
601
|
-
|
|
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
|
-
|
|
602
|
+
exports.push(
|
|
604
603
|
`export { ${(await getExportsAndCheck({
|
|
605
604
|
path: umiPluginPath,
|
|
606
605
|
exportMembers
|
|
607
606
|
})).join(", ")} } from '${umiPluginPath}';`
|
|
608
607
|
);
|
|
609
|
-
|
|
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
|
-
|
|
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
|
-
|
|
632
|
+
exports.push("// react ssr");
|
|
634
633
|
if (api.config.ssr) {
|
|
635
|
-
|
|
634
|
+
exports.push(
|
|
636
635
|
`export { useServerInsertedHTML } from './core/serverInsertedHTMLContext';`
|
|
637
636
|
);
|
|
638
637
|
} else {
|
|
639
|
-
|
|
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,
|
|
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, ...
|
|
718
|
+
content: [...beforeExports, ...exports, ...afterExports].join("\n")
|
|
720
719
|
});
|
|
721
720
|
},
|
|
722
721
|
stage: 1e4
|
package/dist/features/ui/ui.d.ts
CHANGED
package/dist/features/ui/ui.js
CHANGED
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
|
-
|
|
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
|
-
|
|
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
|
|
4
|
+
export type MergedCodeInfo = {
|
|
5
5
|
code: string;
|
|
6
6
|
imports: readonly ImportSpecifier[];
|
|
7
7
|
events: FileChangeEvent[];
|
|
8
8
|
};
|
|
9
|
-
export
|
|
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
|
|
3
|
+
export type MergedCodeInfo = {
|
|
4
4
|
code: string;
|
|
5
5
|
imports: readonly ImportSpecifier[];
|
|
6
6
|
};
|
|
7
|
-
export
|
|
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
|
-
|
|
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':
|
|
4
|
-
readonly '.css':
|
|
5
|
-
readonly '.less':
|
|
6
|
-
readonly '.sass':
|
|
7
|
-
readonly '.scss':
|
|
8
|
-
readonly '.eot':
|
|
9
|
-
readonly '.flac':
|
|
10
|
-
readonly '.gif':
|
|
11
|
-
readonly '.htm':
|
|
12
|
-
readonly '.html':
|
|
13
|
-
readonly '.ico':
|
|
14
|
-
readonly '.icon':
|
|
15
|
-
readonly '.jpeg':
|
|
16
|
-
readonly '.jpg':
|
|
17
|
-
readonly '.empty':
|
|
18
|
-
readonly '.mdx':
|
|
19
|
-
readonly '.mp3':
|
|
20
|
-
readonly '.mp4':
|
|
21
|
-
readonly '.ogg':
|
|
22
|
-
readonly '.otf':
|
|
23
|
-
readonly '.png':
|
|
24
|
-
readonly '.svg':
|
|
25
|
-
readonly '.ttf':
|
|
26
|
-
readonly '.wav':
|
|
27
|
-
readonly '.webm':
|
|
28
|
-
readonly '.webp':
|
|
29
|
-
readonly '.woff':
|
|
30
|
-
readonly '.woff2':
|
|
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
|
-
|
|
2
|
-
export
|
|
3
|
-
export
|
|
4
|
-
export
|
|
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
|
|
8
|
+
export type Event = FileChangeEvent['event'];
|
|
9
9
|
export {};
|
package/dist/libs/scan.d.ts
CHANGED
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)
|
|
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))
|
|
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);
|
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
|
|
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
|
|
26
|
+
export type IStyle = Partial<{
|
|
28
27
|
content: string;
|
|
29
28
|
src: string;
|
|
30
29
|
type: string;
|
|
31
30
|
}> | string;
|
|
32
|
-
export
|
|
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
|
|
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
|
|
53
|
+
export type IApiMiddleware = {
|
|
55
54
|
name: string;
|
|
56
55
|
path: string;
|
|
57
56
|
};
|
|
58
|
-
export
|
|
57
|
+
export type IEntryImport = {
|
|
59
58
|
source: string;
|
|
60
59
|
specifier?: string;
|
|
61
60
|
};
|
|
62
|
-
export
|
|
63
|
-
export
|
|
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
|
|
83
|
-
export
|
|
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
|
|
101
|
+
export type IApi = PluginAPI & IServicePluginAPI & {
|
|
103
102
|
addApiMiddlewares: IAdd<null, IApiMiddleware>;
|
|
104
103
|
addBeforeBabelPlugins: IAdd<null, any>;
|
|
105
104
|
addBeforeBabelPresets: IAdd<null, any>;
|
|
@@ -9,6 +9,6 @@ interface IRouteExportExtractorGenTmpFileOpts extends IRouteExportExtractor {
|
|
|
9
9
|
interface IRouteExportExtractorSetupBuilderOpts extends IRouteExportExtractor {
|
|
10
10
|
outFile: string;
|
|
11
11
|
}
|
|
12
|
-
|
|
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")
|
|
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
|
}
|