@umijs/preset-umi 4.0.66 → 4.0.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.
@@ -41,6 +41,11 @@ function esbuildExternalPlugin(opts) {
41
41
  name: "esbuildExternalPlugin",
42
42
  setup(build) {
43
43
  build.onResolve({ filter: /.*/ }, (args) => {
44
+ if (args.path.includes("_UMI_PREPARE_EXTERNAL_")) {
45
+ return {
46
+ external: true
47
+ };
48
+ }
44
49
  if (!isSource(args.path)) {
45
50
  return {
46
51
  external: true
@@ -68,67 +68,64 @@ var tmpFiles_default = (api) => {
68
68
  initialValue: (0, import_path.join)(rendererPath, "dist/server.js")
69
69
  })
70
70
  );
71
+ const frameworkName = api.service.frameworkName;
71
72
  const srcPrefix = api.appData.hasSrcDir ? "src/" : "";
72
- const umiTempDir = `${srcPrefix}.umi`;
73
+ const umiTempDir = `${srcPrefix}.${frameworkName}`;
73
74
  const baseUrl = api.appData.hasSrcDir ? "../../" : "../";
74
75
  const isTs5 = (_a = api.appData.typescript.tsVersion) == null ? void 0 : _a.startsWith("5");
75
76
  const isTslibInstalled = !!api.appData.typescript.tslibVersion;
77
+ let umiTsConfig = {
78
+ compilerOptions: {
79
+ target: "esnext",
80
+ module: "esnext",
81
+ lib: ["dom", "dom.iterable", "esnext"],
82
+ allowJs: true,
83
+ skipLibCheck: true,
84
+ moduleResolution: isTs5 ? "bundler" : "node",
85
+ importHelpers: isTslibInstalled,
86
+ noEmit: true,
87
+ jsx: api.appData.framework === "vue" ? "preserve" : "react-jsx",
88
+ esModuleInterop: true,
89
+ sourceMap: true,
90
+ baseUrl,
91
+ strict: true,
92
+ resolveJsonModule: true,
93
+ allowSyntheticDefaultImports: true,
94
+ // Supported by vue only
95
+ ...api.appData.framework === "vue" ? {
96
+ // TODO Actually, it should be vite mode, but here it is written as vue only
97
+ // Required in Vite https://vitejs.dev/guide/features.html#typescript
98
+ isolatedModules: true
99
+ } : {},
100
+ paths: {
101
+ "@/*": [`${srcPrefix}*`],
102
+ "@@/*": [`${umiTempDir}/*`],
103
+ [`${api.appData.umi.importSource}`]: [umiDir],
104
+ [`${api.appData.umi.importSource}/typings`]: [
105
+ `${umiTempDir}/typings`
106
+ ],
107
+ ...api.config.vite ? {
108
+ "@fs/*": ["*"]
109
+ } : {}
110
+ }
111
+ },
112
+ include: [
113
+ `${baseUrl}.${frameworkName}rc.ts`,
114
+ `${baseUrl}**/*.d.ts`,
115
+ `${baseUrl}**/*.ts`,
116
+ `${baseUrl}**/*.tsx`,
117
+ api.appData.framework === "vue" && `${baseUrl}**/*.vue`
118
+ ].filter(Boolean)
119
+ };
120
+ umiTsConfig = await api.applyPlugins({
121
+ key: "modifyTSConfig",
122
+ type: api.ApplyPluginsType.modify,
123
+ initialValue: umiTsConfig
124
+ });
76
125
  api.writeTmpFile({
77
126
  noPluginDir: true,
78
127
  path: "tsconfig.json",
79
- // x 1、basic config
80
- // x 2、alias
81
- // 3、language service platform
82
- // 4、typing
83
- content: JSON.stringify(
84
- {
85
- compilerOptions: {
86
- target: "esnext",
87
- module: "esnext",
88
- lib: ["dom", "dom.iterable", "esnext"],
89
- allowJs: true,
90
- skipLibCheck: true,
91
- moduleResolution: isTs5 ? "bundler" : "node",
92
- importHelpers: isTslibInstalled,
93
- noEmit: true,
94
- jsx: api.appData.framework === "vue" ? "preserve" : "react-jsx",
95
- esModuleInterop: true,
96
- sourceMap: true,
97
- baseUrl,
98
- strict: true,
99
- resolveJsonModule: true,
100
- allowSyntheticDefaultImports: true,
101
- // Supported by vue only
102
- ...api.appData.framework === "vue" ? {
103
- // TODO Actually, it should be vite mode, but here it is written as vue only
104
- // Required in Vite https://vitejs.dev/guide/features.html#typescript
105
- isolatedModules: true,
106
- // For `<script setup>`
107
- // See <https://devblogs.microsoft.com/typescript/announcing-typescript-4-5-beta/#preserve-value-imports>
108
- preserveValueImports: true
109
- } : {},
110
- paths: {
111
- "@/*": [`${srcPrefix}*`],
112
- "@@/*": [`${umiTempDir}/*`],
113
- [`${api.appData.umi.importSource}`]: [umiDir],
114
- [`${api.appData.umi.importSource}/typings`]: [
115
- `${umiTempDir}/typings`
116
- ],
117
- ...api.config.vite ? {
118
- "@fs/*": ["*"]
119
- } : {}
120
- }
121
- },
122
- include: [
123
- `${baseUrl}.umirc.ts`,
124
- `${baseUrl}**/*.d.ts`,
125
- `${baseUrl}**/*.ts`,
126
- `${baseUrl}**/*.tsx`
127
- ]
128
- },
129
- null,
130
- 2
131
- )
128
+ content: JSON.stringify(umiTsConfig, null, 2)
132
129
  });
133
130
  api.writeTmpFile({
134
131
  noPluginDir: true,
@@ -113,6 +113,16 @@ var ui_default = (api) => {
113
113
  `
114
114
  ];
115
115
  });
116
+ api.modifyAppData(async (memo) => {
117
+ const uiModules = await api.applyPlugins({
118
+ key: "addUIModules",
119
+ initialValue: []
120
+ }) ?? [];
121
+ memo.ui = {
122
+ modules: uiModules
123
+ };
124
+ return memo;
125
+ });
116
126
  api.onGenerateFiles(({ isFirstTime }) => {
117
127
  if (!isFirstTime)
118
128
  return;
@@ -75,6 +75,7 @@ var registerMethods_default = (api) => {
75
75
  "addHTMLScripts",
76
76
  "addTmpGenerateWatcherPaths",
77
77
  "addOnDemandDeps",
78
+ "addUIModules",
78
79
  "chainWebpack",
79
80
  "modifyEntry",
80
81
  "modifyHTMLFavicon",
@@ -85,7 +86,8 @@ var registerMethods_default = (api) => {
85
86
  "modifyRendererPath",
86
87
  "modifyServerRendererPath",
87
88
  "modifyRoutes",
88
- "modifyBabelPresetOpts"
89
+ "modifyBabelPresetOpts",
90
+ "modifyTSConfig"
89
91
  ].forEach((name) => {
90
92
  api.registerMethod({ name });
91
93
  });
package/dist/types.d.ts CHANGED
@@ -67,6 +67,17 @@ export interface IOnGenerateFiles {
67
67
  files?: IFileInfo | null;
68
68
  isFirstTime?: boolean;
69
69
  }
70
+ export interface IUIMenu {
71
+ path: string;
72
+ url: string;
73
+ icon: string;
74
+ name: string;
75
+ }
76
+ export interface IUIModule {
77
+ name: string;
78
+ menus?: IUIMenu[];
79
+ [key: string]: any;
80
+ }
70
81
  export declare type GenerateFilesFn = (opts: IOnGenerateFiles) => Promise<void>;
71
82
  export declare type OnConfigChangeFn = (opts: {
72
83
  generate: GenerateFilesFn;
@@ -101,6 +112,7 @@ export declare type IApi = PluginAPI & IServicePluginAPI & {
101
112
  addRuntimePlugin: IAdd<null, string>;
102
113
  addRuntimePluginKey: IAdd<null, string>;
103
114
  addTmpGenerateWatcherPaths: IAdd<null, string>;
115
+ addUIModules: IAdd<null, IUIModule[]>;
104
116
  chainWebpack: {
105
117
  (fn: {
106
118
  (memo: WebpackChain, args: {
@@ -125,6 +137,7 @@ export declare type IApi = PluginAPI & IServicePluginAPI & {
125
137
  modifyRendererPath: IModify<string, {}>;
126
138
  modifyRoutes: IModify<Record<string, IRoute>, {}>;
127
139
  modifyServerRendererPath: IModify<string, {}>;
140
+ modifyTSConfig: IModify<Record<string, any>, {}>;
128
141
  modifyViteConfig: IModify<ViteInlineConfig, {
129
142
  env: Env;
130
143
  }>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@umijs/preset-umi",
3
- "version": "4.0.66",
3
+ "version": "4.0.68",
4
4
  "description": "@umijs/preset-umi",
5
5
  "homepage": "https://github.com/umijs/umi/tree/master/packages/preset-umi#readme",
6
6
  "bugs": "https://github.com/umijs/umi/issues",
@@ -37,20 +37,20 @@
37
37
  "react-router": "6.3.0",
38
38
  "react-router-dom": "6.3.0",
39
39
  "regenerator-runtime": "0.13.11",
40
- "@umijs/ast": "4.0.66",
41
- "@umijs/babel-preset-umi": "4.0.66",
42
- "@umijs/bundler-utils": "4.0.66",
43
- "@umijs/bundler-vite": "4.0.66",
44
- "@umijs/bundler-webpack": "4.0.66",
45
- "@umijs/core": "4.0.66",
46
- "@umijs/mfsu": "4.0.66",
47
- "@umijs/plugin-run": "4.0.66",
48
- "@umijs/renderer-react": "4.0.66",
49
- "@umijs/server": "4.0.66",
50
- "@umijs/utils": "4.0.66",
51
- "@umijs/zod2ts": "4.0.66",
40
+ "@umijs/ast": "4.0.68",
41
+ "@umijs/bundler-utils": "4.0.68",
42
+ "@umijs/bundler-webpack": "4.0.68",
43
+ "@umijs/bundler-vite": "4.0.68",
44
+ "@umijs/plugin-run": "4.0.68",
45
+ "@umijs/core": "4.0.68",
46
+ "@umijs/mfsu": "4.0.68",
47
+ "@umijs/renderer-react": "4.0.68",
48
+ "@umijs/did-you-know": "1.0.3",
49
+ "@umijs/babel-preset-umi": "4.0.68",
50
+ "@umijs/server": "4.0.68",
52
51
  "@umijs/ui": "3.0.0-alpha.0",
53
- "@umijs/did-you-know": "1.0.3"
52
+ "@umijs/utils": "4.0.68",
53
+ "@umijs/zod2ts": "4.0.68"
54
54
  },
55
55
  "devDependencies": {
56
56
  "@manypkg/get-packages": "1.1.3",
@@ -64,7 +64,7 @@
64
64
  "multer": "1.4.4",
65
65
  "os-locale": "^6.0.2",
66
66
  "sirv": "2.0.2",
67
- "vite": "4.2.0"
67
+ "vite": "4.3.1"
68
68
  },
69
69
  "publishConfig": {
70
70
  "access": "public"