@umijs/preset-umi 4.0.60 → 4.0.62

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.
@@ -100,6 +100,18 @@ var appData_default = (api) => {
100
100
  memo.git = git;
101
101
  }
102
102
  memo.framework = "react";
103
+ const tsPkg = tryLoadDepPkg({
104
+ name: "typescript",
105
+ from: api.cwd
106
+ });
107
+ const tslibPkg = tryLoadDepPkg({
108
+ name: "tslib",
109
+ from: api.cwd
110
+ });
111
+ memo.typescript = {
112
+ tsVersion: tsPkg == null ? void 0 : tsPkg.version,
113
+ tslibVersion: tslibPkg == null ? void 0 : tslibPkg.version
114
+ };
103
115
  return memo;
104
116
  });
105
117
  api.register({
@@ -194,5 +206,14 @@ function findGitDir(dir) {
194
206
  }
195
207
  return null;
196
208
  }
209
+ function tryLoadDepPkg(opts) {
210
+ const { name, from } = opts;
211
+ try {
212
+ return require(require.resolve(`${name}/package.json`, {
213
+ paths: [from]
214
+ }));
215
+ } catch {
216
+ }
217
+ }
197
218
  // Annotate the CommonJS export names for ESM import in node:
198
219
  0 && (module.exports = {});
@@ -53,7 +53,7 @@ var tmpFiles_default = (api) => {
53
53
  }
54
54
  });
55
55
  api.onGenerateFiles(async (opts) => {
56
- var _a, _b;
56
+ var _a, _b, _c;
57
57
  const rendererPath = (0, import_utils.winPath)(
58
58
  await api.applyPlugins({
59
59
  key: "modifyRendererPath",
@@ -71,6 +71,8 @@ var tmpFiles_default = (api) => {
71
71
  const srcPrefix = api.appData.hasSrcDir ? "src/" : "";
72
72
  const umiTempDir = `${srcPrefix}.umi`;
73
73
  const baseUrl = api.appData.hasSrcDir ? "../../" : "../";
74
+ const isTs5 = (_a = api.appData.typescript.tsVersion) == null ? void 0 : _a.startsWith("5");
75
+ const isTslibInstalled = !!api.appData.typescript.tslibVersion;
74
76
  api.writeTmpFile({
75
77
  noPluginDir: true,
76
78
  path: "tsconfig.json",
@@ -83,8 +85,12 @@ var tmpFiles_default = (api) => {
83
85
  compilerOptions: {
84
86
  target: "esnext",
85
87
  module: "esnext",
86
- moduleResolution: "node",
87
- importHelpers: true,
88
+ lib: ["dom", "dom.iterable", "esnext"],
89
+ allowJs: true,
90
+ skipLibCheck: true,
91
+ moduleResolution: isTs5 ? "bundler" : "node",
92
+ importHelpers: isTslibInstalled,
93
+ noEmit: true,
88
94
  jsx: api.appData.framework === "vue" ? "preserve" : "react-jsx",
89
95
  esModuleInterop: true,
90
96
  sourceMap: true,
@@ -344,7 +350,7 @@ export default function EmptyRoute() {
344
350
  }
345
351
  const hasSrc = api.appData.hasSrcDir;
346
352
  const pages = (0, import_path.basename)(
347
- ((_a = api.config.conventionRoutes) == null ? void 0 : _a.base) || api.paths.absPagesPath
353
+ ((_b = api.config.conventionRoutes) == null ? void 0 : _b.base) || api.paths.absPagesPath
348
354
  );
349
355
  const prefix = hasSrc ? `../../../src/${pages}/` : `../../${pages}/`;
350
356
  const clonedRoutes = import_utils.lodash.cloneDeep(routes);
@@ -362,7 +368,7 @@ export default function EmptyRoute() {
362
368
  routesString = routesString.replace(/"(clientLoaders\[.*?)"/g, "$1");
363
369
  headerImports.push(`import clientLoaders from './loaders.js';`);
364
370
  }
365
- if (!api.userConfig.routes) {
371
+ if (!api.userConfig.routes && api.isPluginEnable("routeProps")) {
366
372
  routesString = routesString.replace(
367
373
  /"routeProps":"(routeProps\[.*?)"/g,
368
374
  "...$1"
@@ -406,7 +412,7 @@ if (process.env.NODE_ENV === 'development') {
406
412
  });
407
413
  const plugins = await api.applyPlugins({
408
414
  key: "addRuntimePlugin",
409
- initialValue: [(_b = api.appData.appJS) == null ? void 0 : _b.path].filter(Boolean)
415
+ initialValue: [(_c = api.appData.appJS) == null ? void 0 : _c.path].filter(Boolean)
410
416
  });
411
417
  const validKeys = await api.applyPlugins({
412
418
  key: "addRuntimePluginKey",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@umijs/preset-umi",
3
- "version": "4.0.60",
3
+ "version": "4.0.62",
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",
@@ -36,19 +36,19 @@
36
36
  "react-router": "6.3.0",
37
37
  "react-router-dom": "6.3.0",
38
38
  "regenerator-runtime": "0.13.11",
39
- "@umijs/ast": "4.0.60",
40
- "@umijs/babel-preset-umi": "4.0.60",
41
- "@umijs/bundler-utils": "4.0.60",
42
- "@umijs/bundler-webpack": "4.0.60",
43
- "@umijs/bundler-vite": "4.0.60",
44
- "@umijs/core": "4.0.60",
45
- "@umijs/mfsu": "4.0.60",
46
- "@umijs/plugin-run": "4.0.60",
47
- "@umijs/did-you-know": "1.0.3",
48
- "@umijs/renderer-react": "4.0.60",
49
- "@umijs/server": "4.0.60",
50
- "@umijs/utils": "4.0.60",
51
- "@umijs/zod2ts": "4.0.60"
39
+ "@umijs/bundler-utils": "4.0.62",
40
+ "@umijs/ast": "4.0.62",
41
+ "@umijs/core": "4.0.62",
42
+ "@umijs/babel-preset-umi": "4.0.62",
43
+ "@umijs/bundler-webpack": "4.0.62",
44
+ "@umijs/renderer-react": "4.0.62",
45
+ "@umijs/bundler-vite": "4.0.62",
46
+ "@umijs/server": "4.0.62",
47
+ "@umijs/utils": "4.0.62",
48
+ "@umijs/plugin-run": "4.0.62",
49
+ "@umijs/mfsu": "4.0.62",
50
+ "@umijs/zod2ts": "4.0.62",
51
+ "@umijs/did-you-know": "1.0.3"
52
52
  },
53
53
  "devDependencies": {
54
54
  "@manypkg/get-packages": "1.1.3",
@@ -62,7 +62,7 @@
62
62
  "multer": "1.4.4",
63
63
  "os-locale": "^6.0.2",
64
64
  "sirv": "2.0.2",
65
- "vite": "4.1.4"
65
+ "vite": "4.2.0"
66
66
  },
67
67
  "publishConfig": {
68
68
  "access": "public"