@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
package/dist/commands/build.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import type { IConfig } from '@umijs/bundler-webpack
|
|
1
|
+
import type { IConfig } from '@umijs/bundler-webpack';
|
|
2
2
|
export declare function list(config: IConfig, name?: string): void;
|
|
@@ -26,7 +26,8 @@ var import_ast = require("@umijs/ast");
|
|
|
26
26
|
var import_fs = require("fs");
|
|
27
27
|
function remove(mainConfigFile, name) {
|
|
28
28
|
const ast = (0, import_ast.getASTByFilePath)(mainConfigFile);
|
|
29
|
-
if (!ast)
|
|
29
|
+
if (!ast)
|
|
30
|
+
return;
|
|
30
31
|
const generateCode = (0, import_ast.generate)((0, import_ast.removeConfigByName)(ast, name));
|
|
31
32
|
const prettier = require("@umijs/utils/compiled/prettier");
|
|
32
33
|
const printStr = prettier.format(generateCode, {
|
|
@@ -35,7 +35,8 @@ function set(api, name, value) {
|
|
|
35
35
|
api.appData.mainConfigFile = absPath;
|
|
36
36
|
}
|
|
37
37
|
const ast = (0, import_ast.getASTByFilePath)(mainConfigFile);
|
|
38
|
-
if (!ast)
|
|
38
|
+
if (!ast)
|
|
39
|
+
return;
|
|
39
40
|
const generateCode = (0, import_ast.generate)((0, import_ast.setConfigByName)(ast, name, value));
|
|
40
41
|
const prettier = require("@umijs/utils/compiled/prettier");
|
|
41
42
|
const printStr = prettier.format(generateCode, {
|
|
@@ -205,7 +205,8 @@ var deadcode_default = (api) => {
|
|
|
205
205
|
const recordJsonPath = (0, import_utils.winPath)(
|
|
206
206
|
(0, import_path.join)(cwd, typeof out === "string" ? out : recordJson)
|
|
207
207
|
);
|
|
208
|
-
if (gitInfo)
|
|
208
|
+
if (gitInfo)
|
|
209
|
+
import_utils.logger.wait("generating file...");
|
|
209
210
|
await outputUnusedFiles(unusedFiles, recordJsonPath, {
|
|
210
211
|
gitInfo,
|
|
211
212
|
cwd
|
|
@@ -44,7 +44,8 @@ function createRouteMiddleware(opts) {
|
|
|
44
44
|
hasErrors: () => false
|
|
45
45
|
};
|
|
46
46
|
}
|
|
47
|
-
if (webpackStats)
|
|
47
|
+
if (webpackStats)
|
|
48
|
+
return Promise.resolve(webpackStats);
|
|
48
49
|
return new Promise((resolve) => {
|
|
49
50
|
onStats = (stats) => {
|
|
50
51
|
resolve(stats);
|
|
@@ -24,7 +24,6 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
24
24
|
// src/commands/dev/depBuildWorker/depBuildWorker.ts
|
|
25
25
|
var import_bundler_webpack = require("@umijs/bundler-webpack");
|
|
26
26
|
var import_constants = require("@umijs/bundler-webpack/dist/constants");
|
|
27
|
-
var import_types = require("@umijs/bundler-webpack/dist/types");
|
|
28
27
|
var import_mfsu = require("@umijs/mfsu");
|
|
29
28
|
var import_utils = require("@umijs/utils");
|
|
30
29
|
var import_path = require("path");
|
|
@@ -71,7 +70,7 @@ async function start() {
|
|
|
71
70
|
const depConfig = await (0, import_bundler_webpack.getConfig)({
|
|
72
71
|
cwd: opts.cwd,
|
|
73
72
|
rootDir: opts.rootDir,
|
|
74
|
-
env:
|
|
73
|
+
env: import_bundler_webpack.Env.development,
|
|
75
74
|
entry: opts.entry,
|
|
76
75
|
userConfig: opts.config,
|
|
77
76
|
disableCopy: true,
|
|
@@ -114,7 +113,8 @@ start().catch((e) => {
|
|
|
114
113
|
import_utils.logger.error("[MFSU][eager] build worker start failed", e);
|
|
115
114
|
});
|
|
116
115
|
function makeArray(a) {
|
|
117
|
-
if (Array.isArray(a))
|
|
116
|
+
if (Array.isArray(a))
|
|
117
|
+
return a;
|
|
118
118
|
return [a];
|
|
119
119
|
}
|
|
120
120
|
function setupWorkerEnv() {
|
|
@@ -45,10 +45,9 @@ var import_path = require("path");
|
|
|
45
45
|
var import_worker_threads = require("worker_threads");
|
|
46
46
|
var MF_ENTRY = "mf_index.js";
|
|
47
47
|
var DepBuilderInWorker = class {
|
|
48
|
-
completeFns = [];
|
|
49
|
-
isBuilding = false;
|
|
50
|
-
opts;
|
|
51
48
|
constructor(opts) {
|
|
49
|
+
this.completeFns = [];
|
|
50
|
+
this.isBuilding = false;
|
|
52
51
|
this.opts = opts;
|
|
53
52
|
}
|
|
54
53
|
async buildWithWebpack(opts) {
|
|
@@ -155,8 +154,10 @@ var DepBuilderInWorker = class {
|
|
|
155
154
|
depConfig.output.path = this.opts.tmpBase;
|
|
156
155
|
depConfig.output.publicPath = "auto";
|
|
157
156
|
depConfig.devtool = false;
|
|
158
|
-
if ((_a = depConfig.output) == null ? void 0 : _a.library)
|
|
159
|
-
|
|
157
|
+
if ((_a = depConfig.output) == null ? void 0 : _a.library)
|
|
158
|
+
delete depConfig.output.library;
|
|
159
|
+
if ((_b = depConfig.output) == null ? void 0 : _b.libraryTarget)
|
|
160
|
+
delete depConfig.output.libraryTarget;
|
|
160
161
|
depConfig.optimization || (depConfig.optimization = {});
|
|
161
162
|
depConfig.optimization.splitChunks = {
|
|
162
163
|
chunks: (chunk) => {
|
|
@@ -32,9 +32,9 @@ __export(getConfig_exports, {
|
|
|
32
32
|
getDevConfig: () => getDevConfig
|
|
33
33
|
});
|
|
34
34
|
module.exports = __toCommonJS(getConfig_exports);
|
|
35
|
-
var
|
|
35
|
+
var { Service } = require("umi");
|
|
36
36
|
async function getDevConfig() {
|
|
37
|
-
const service = new
|
|
37
|
+
const service = new Service({
|
|
38
38
|
presets: [require.resolve("./workerPreset")]
|
|
39
39
|
});
|
|
40
40
|
const opts = await service.run({
|
package/dist/commands/dev/dev.js
CHANGED
|
@@ -216,7 +216,8 @@ PORT=8888 umi dev
|
|
|
216
216
|
const isPublicAvailable = (0, import_fs.existsSync)(publicDir) && (0, import_fs.readdirSync)(publicDir).length;
|
|
217
217
|
let restarted = false;
|
|
218
218
|
const restartServer = () => {
|
|
219
|
-
if (restarted)
|
|
219
|
+
if (restarted)
|
|
220
|
+
return;
|
|
220
221
|
restarted = true;
|
|
221
222
|
import_utils.logger.event(`public dir changed, restart server...`);
|
|
222
223
|
api.restartServer();
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { IApi } from '../../types';
|
|
2
2
|
import { type IArgsComponent } from './utils';
|
|
3
|
-
declare const _default: (api: IApi) => void;
|
|
4
3
|
export default _default;
|
|
4
|
+
declare function _default(api: IApi): void;
|
|
5
5
|
export declare class ComponentGenerator {
|
|
6
6
|
readonly opts: {
|
|
7
7
|
componentName: string;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { prompts } from '@umijs/utils';
|
|
2
2
|
import { IApi } from '../../types';
|
|
3
3
|
import { type IArgsPage } from './utils';
|
|
4
|
-
declare const _default: (api: IApi) => void;
|
|
5
4
|
export default _default;
|
|
5
|
+
declare function _default(api: IApi): void;
|
|
6
6
|
export declare class PageGenerator {
|
|
7
7
|
readonly options: {
|
|
8
8
|
args: IArgsPage;
|
|
@@ -59,6 +59,13 @@ var USER_TEMPLATE_PAGE_DIR = "templates/page";
|
|
|
59
59
|
var PageGenerator = class {
|
|
60
60
|
constructor(options) {
|
|
61
61
|
this.options = options;
|
|
62
|
+
this.isDirMode = false;
|
|
63
|
+
this.dir = "";
|
|
64
|
+
this.name = "";
|
|
65
|
+
this.importSource = "";
|
|
66
|
+
this.needEnsureDirMode = false;
|
|
67
|
+
this.prompts = import_utils2.promptsExitWhenCancel;
|
|
68
|
+
this.paths = [];
|
|
62
69
|
this.isDirMode = !!options.args.dir;
|
|
63
70
|
this.importSource = options.importSource || "umi";
|
|
64
71
|
const [_, ...inputPaths] = options.args._;
|
|
@@ -68,13 +75,6 @@ var PageGenerator = class {
|
|
|
68
75
|
this.needEnsureDirMode = true;
|
|
69
76
|
}
|
|
70
77
|
}
|
|
71
|
-
isDirMode = false;
|
|
72
|
-
dir = "";
|
|
73
|
-
name = "";
|
|
74
|
-
importSource = "";
|
|
75
|
-
needEnsureDirMode = false;
|
|
76
|
-
prompts = import_utils2.promptsExitWhenCancel;
|
|
77
|
-
paths = [];
|
|
78
78
|
async run() {
|
|
79
79
|
if (this.paths.length === 0) {
|
|
80
80
|
await this.runInteractiveMode();
|
|
@@ -129,7 +129,8 @@ var PageGenerator = class {
|
|
|
129
129
|
this.isDirMode = false;
|
|
130
130
|
}
|
|
131
131
|
async ensureDirMode() {
|
|
132
|
-
if (!this.needEnsureDirMode)
|
|
132
|
+
if (!this.needEnsureDirMode)
|
|
133
|
+
return;
|
|
133
134
|
const response = await this.prompts({
|
|
134
135
|
type: "select",
|
|
135
136
|
name: "mode",
|
package/dist/commands/help.d.ts
CHANGED
package/dist/commands/lint.d.ts
CHANGED
|
@@ -49,8 +49,6 @@ var MFSUUtilBase = class {
|
|
|
49
49
|
this.mfsuCacheBase = ((_b = (_a = api.config) == null ? void 0 : _a.mfsu) == null ? void 0 : _b.cacheDirectoryPath) || (0, import_path.join)(cacheBase, "mfsu");
|
|
50
50
|
this.cliName = this.api.appData.umi.cliName;
|
|
51
51
|
}
|
|
52
|
-
mfsuCacheBase;
|
|
53
|
-
cliName;
|
|
54
52
|
async prepare() {
|
|
55
53
|
var _a, _b, _c, _d;
|
|
56
54
|
const api = this.api;
|
package/dist/commands/setup.d.ts
CHANGED
package/dist/constants.d.ts
CHANGED
package/dist/constants.js
CHANGED
|
@@ -22,6 +22,7 @@ __export(constants_exports, {
|
|
|
22
22
|
CACHE_DIR_NAME: () => CACHE_DIR_NAME,
|
|
23
23
|
DEFAULT_HOST: () => DEFAULT_HOST,
|
|
24
24
|
DEFAULT_PORT: () => DEFAULT_PORT,
|
|
25
|
+
RUNTIME_TYPE_FILE_NAME: () => RUNTIME_TYPE_FILE_NAME,
|
|
25
26
|
TEMPLATES_DIR: () => TEMPLATES_DIR
|
|
26
27
|
});
|
|
27
28
|
module.exports = __toCommonJS(constants_exports);
|
|
@@ -29,11 +30,13 @@ var import_path = require("path");
|
|
|
29
30
|
var DEFAULT_PORT = "8000";
|
|
30
31
|
var DEFAULT_HOST = "0.0.0.0";
|
|
31
32
|
var CACHE_DIR_NAME = ".cache";
|
|
33
|
+
var RUNTIME_TYPE_FILE_NAME = "runtimeConfig.d.ts";
|
|
32
34
|
var TEMPLATES_DIR = (0, import_path.join)(__dirname, "../templates");
|
|
33
35
|
// Annotate the CommonJS export names for ESM import in node:
|
|
34
36
|
0 && (module.exports = {
|
|
35
37
|
CACHE_DIR_NAME,
|
|
36
38
|
DEFAULT_HOST,
|
|
37
39
|
DEFAULT_PORT,
|
|
40
|
+
RUNTIME_TYPE_FILE_NAME,
|
|
38
41
|
TEMPLATES_DIR
|
|
39
42
|
});
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { IApi, IRoute } from '../../types';
|
|
2
|
-
|
|
2
|
+
type Routes = Record<string, IRoute>;
|
|
3
3
|
export declare function patchRoutes(routes: Routes): Routes;
|
|
4
|
-
declare const _default: (api: IApi) => void;
|
|
5
4
|
export default _default;
|
|
5
|
+
declare function _default(api: IApi): void;
|
|
@@ -54,7 +54,8 @@ var aiDev_default = (api) => {
|
|
|
54
54
|
if (api.config.mako || api.config.utoopack) {
|
|
55
55
|
return;
|
|
56
56
|
}
|
|
57
|
-
if (!process.env.UMI_AI_COMMAND || !process.env.UMI_AI_PACKAGE)
|
|
57
|
+
if (!process.env.UMI_AI_COMMAND || !process.env.UMI_AI_PACKAGE)
|
|
58
|
+
return;
|
|
58
59
|
try {
|
|
59
60
|
const aiCommand = process.env.UMI_AI_COMMAND;
|
|
60
61
|
const aiPackage = process.env.UMI_AI_PACKAGE;
|
|
@@ -66,7 +66,8 @@ var apiRoute_default = (api) => {
|
|
|
66
66
|
},
|
|
67
67
|
enableBy: () => {
|
|
68
68
|
const hasApiRoutes = import_fs.default.existsSync((0, import_path.join)(api.paths.absSrcPath, "api"));
|
|
69
|
-
if (!hasApiRoutes)
|
|
69
|
+
if (!hasApiRoutes)
|
|
70
|
+
return false;
|
|
70
71
|
const config = api.userConfig.apiRoute;
|
|
71
72
|
if (!config) {
|
|
72
73
|
return false;
|
|
@@ -55,7 +55,8 @@ async function esbuild_default(api, apiRoutes) {
|
|
|
55
55
|
(0, import_utils2.esbuildIgnorePathPrefixPlugin)(),
|
|
56
56
|
(0, import_watchRebuild.esbuildWatchRebuildPlugin)({
|
|
57
57
|
onRebuild(error) {
|
|
58
|
-
if (error)
|
|
58
|
+
if (error)
|
|
59
|
+
import_utils.logger.error("Compile api routes failed: ", error);
|
|
59
60
|
Object.keys(require.cache).forEach((modulePath) => {
|
|
60
61
|
if (modulePath.startsWith((0, import_path.join)(api.paths.cwd, import_constants.OUTPUT_PATH)))
|
|
61
62
|
delete require.cache[modulePath];
|
|
@@ -26,17 +26,17 @@ __export(request_exports, {
|
|
|
26
26
|
module.exports = __toCommonJS(request_exports);
|
|
27
27
|
var import_utils = require("./utils");
|
|
28
28
|
var UmiApiRequest = class {
|
|
29
|
-
_req;
|
|
30
|
-
_params = {};
|
|
31
29
|
constructor(req, apiRoutes) {
|
|
30
|
+
this._params = {};
|
|
31
|
+
this._body = null;
|
|
32
32
|
this._req = req;
|
|
33
33
|
const m = (0, import_utils.matchApiRoute)(apiRoutes, this.pathName || "");
|
|
34
|
-
if (m)
|
|
34
|
+
if (m)
|
|
35
|
+
this._params = m.params;
|
|
35
36
|
}
|
|
36
37
|
get params() {
|
|
37
38
|
return this._params;
|
|
38
39
|
}
|
|
39
|
-
_body = null;
|
|
40
40
|
get body() {
|
|
41
41
|
return this._body;
|
|
42
42
|
}
|
|
@@ -128,7 +128,8 @@ function parseMultipart(body, boundary) {
|
|
|
128
128
|
);
|
|
129
129
|
const meta = Buffer.from(hexMeta, "hex").toString("utf-8");
|
|
130
130
|
const name = (_a = meta.split('name="')[1]) == null ? void 0 : _a.split('"')[0];
|
|
131
|
-
if (!name)
|
|
131
|
+
if (!name)
|
|
132
|
+
return acc;
|
|
132
133
|
const fileName = (_b = meta.split('filename="')[1]) == null ? void 0 : _b.split('"')[0];
|
|
133
134
|
if (fileName) {
|
|
134
135
|
const fileBufferBeforeTrim = Buffer.from(hexValue, "hex");
|
|
@@ -34,30 +34,39 @@ function esbuildIgnorePathPrefixPlugin() {
|
|
|
34
34
|
};
|
|
35
35
|
}
|
|
36
36
|
function matchApiRoute(apiRoutes, path) {
|
|
37
|
-
if (path.startsWith("/"))
|
|
38
|
-
|
|
37
|
+
if (path.startsWith("/"))
|
|
38
|
+
path = path.substring(1);
|
|
39
|
+
if (path.startsWith("api/"))
|
|
40
|
+
path = path.substring(4);
|
|
39
41
|
const pathSegments = path.split("/").filter((p) => p !== "");
|
|
40
42
|
if (pathSegments.length === 0 || pathSegments.length === 1 && pathSegments[0] === "api") {
|
|
41
43
|
const route2 = apiRoutes.find((r) => r.path === "/");
|
|
42
|
-
if (route2)
|
|
43
|
-
|
|
44
|
+
if (route2)
|
|
45
|
+
return { route: route2, params: {} };
|
|
46
|
+
else
|
|
47
|
+
return void 0;
|
|
44
48
|
}
|
|
45
49
|
const params = {};
|
|
46
50
|
const route = apiRoutes.find((route2) => {
|
|
47
51
|
const routePathSegments = route2.path.split("/").filter((p) => p !== "");
|
|
48
|
-
if (routePathSegments.length !== pathSegments.length)
|
|
52
|
+
if (routePathSegments.length !== pathSegments.length)
|
|
53
|
+
return false;
|
|
49
54
|
for (let i = 0; i < routePathSegments.length; i++) {
|
|
50
55
|
const routePathSegment = routePathSegments[i];
|
|
51
56
|
if (routePathSegment.match(/^\[.*]$/)) {
|
|
52
57
|
params[routePathSegment.substring(1, routePathSegment.length - 1)] = pathSegments[i];
|
|
53
|
-
if (i == routePathSegments.length - 1)
|
|
58
|
+
if (i == routePathSegments.length - 1)
|
|
59
|
+
return true;
|
|
54
60
|
continue;
|
|
55
61
|
}
|
|
56
|
-
if (routePathSegment !== pathSegments[i])
|
|
57
|
-
|
|
62
|
+
if (routePathSegment !== pathSegments[i])
|
|
63
|
+
return false;
|
|
64
|
+
if (i == routePathSegments.length - 1)
|
|
65
|
+
return true;
|
|
58
66
|
}
|
|
59
67
|
});
|
|
60
|
-
if (route)
|
|
68
|
+
if (route)
|
|
69
|
+
return { route, params };
|
|
61
70
|
}
|
|
62
71
|
// Annotate the CommonJS export names for ESM import in node:
|
|
63
72
|
0 && (module.exports = {
|
|
@@ -160,13 +160,13 @@ var appData_default = (api) => {
|
|
|
160
160
|
async function getAppJsInfo() {
|
|
161
161
|
for (const path of (0, import_watch.expandJSPaths)((0, import_path.join)(api.paths.absSrcPath, "app"))) {
|
|
162
162
|
if ((0, import_fs.existsSync)(path)) {
|
|
163
|
-
const [_,
|
|
163
|
+
const [_, exports] = await bundlerUtils.parseModule({
|
|
164
164
|
path,
|
|
165
165
|
content: (0, import_fs.readFileSync)(path, "utf-8")
|
|
166
166
|
});
|
|
167
167
|
return {
|
|
168
168
|
path,
|
|
169
|
-
exports
|
|
169
|
+
exports
|
|
170
170
|
};
|
|
171
171
|
}
|
|
172
172
|
}
|