@umijs/preset-umi 4.0.43 → 4.0.45

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.
@@ -50,17 +50,22 @@ var jest_default = (api) => {
50
50
  });
51
51
  const hasSrc = api.paths.absSrcPath.endsWith("src");
52
52
  const importSource = api.appData.umi.importSource;
53
+ const jestMajorVersion = `^${getJestVersion()}`;
53
54
  const basicDeps = {
54
- jest: "^27",
55
- "@types/jest": "^27",
55
+ jest: jestMajorVersion,
56
+ "@types/jest": jestMajorVersion,
56
57
  typescript: "^4",
57
58
  "ts-node": "^10",
58
59
  "cross-env": "^7"
59
60
  };
61
+ const reactTestingDeps = {
62
+ "jest-environment-jsdom": jestMajorVersion,
63
+ "@testing-library/jest-dom": "^5",
64
+ "@testing-library/react": "^13"
65
+ };
60
66
  const packageToInstall = res.willUseTLR ? {
61
67
  ...basicDeps,
62
- "@testing-library/react": "^13",
63
- "@testing-library/jest-dom": "^5.16.4",
68
+ ...reactTestingDeps,
64
69
  "@types/testing-library__jest-dom": "^5.14.5"
65
70
  } : basicDeps;
66
71
  h.addDevDeps(packageToInstall);
@@ -106,15 +111,15 @@ export default async () => {
106
111
  // config opts for esbuild , it will pass to esbuild directly
107
112
  jsTransformerOpts: { jsx: 'automatic' },
108
113
  }),
109
-
114
+
110
115
  ${res.willUseTLR ? `setupFilesAfterEnv: ['<rootDir>/jest-setup.ts'],` : ""}
111
116
  collectCoverageFrom: [
112
- ${collectCoverageFrom.map((v) => ` '${v}'`).join(",\n")}
117
+ ${collectCoverageFrom.map((v) => ` '${v}'`).join(",\n")}
113
118
  ],
114
119
  // if you require some es-module npm package, please uncomment below line and insert your package name
115
120
  // transformIgnorePatterns: ['node_modules/(?!.*(lodash-es|your-es-pkg-name)/)']
116
121
  })) as Config.InitialOptions;
117
- }catch(e){
122
+ } catch (e) {
118
123
  console.log(e);
119
124
  throw e;
120
125
  }
@@ -126,5 +131,19 @@ export default async () => {
126
131
  }
127
132
  });
128
133
  };
134
+ function getJestVersion() {
135
+ try {
136
+ const umiPkg = require.resolve("umi/package.json", {
137
+ paths: [process.cwd()]
138
+ });
139
+ const testPkg = require.resolve("@umijs/test/package.json", {
140
+ paths: [umiPkg]
141
+ });
142
+ const version = require(testPkg).devDependencies.jest;
143
+ return import_utils.semver.minVersion(version).version.split(".")[0];
144
+ } catch {
145
+ return 29;
146
+ }
147
+ }
129
148
  // Annotate the CommonJS export names for ESM import in node:
130
149
  0 && (module.exports = {});
@@ -29,11 +29,11 @@ __export(build_exports, {
29
29
  });
30
30
  module.exports = __toCommonJS(build_exports);
31
31
  var import_esbuild = __toESM(require("@umijs/bundler-utils/compiled/esbuild"));
32
- var import_esbuildExternalPlugin = require("./esbuildPlugins/esbuildExternalPlugin");
32
+ var import_utils = require("@umijs/utils");
33
33
  var import_path = __toESM(require("path"));
34
34
  var import_esbuildAliasPlugin = require("./esbuildPlugins/esbuildAliasPlugin");
35
35
  var import_esbuildCollectIconPlugin = require("./esbuildPlugins/esbuildCollectIconPlugin");
36
- var import_utils = require("@umijs/utils");
36
+ var import_esbuildExternalPlugin = require("./esbuildPlugins/esbuildExternalPlugin");
37
37
  async function build(opts) {
38
38
  var _a, _b;
39
39
  const icons = opts.icons || /* @__PURE__ */ new Set();
@@ -64,8 +64,8 @@ async function build(opts) {
64
64
  write: false,
65
65
  outdir: import_path.default.join(import_path.default.dirname(opts.entryPoints[0]), "out"),
66
66
  plugins: [
67
- (0, import_esbuildAliasPlugin.esbuildAliasPlugin)({ alias: ((_a = opts.config) == null ? void 0 : _a.alias) || {} }),
68
67
  (0, import_esbuildExternalPlugin.esbuildExternalPlugin)(),
68
+ (0, import_esbuildAliasPlugin.esbuildAliasPlugin)({ alias: ((_a = opts.config) == null ? void 0 : _a.alias) || {} }),
69
69
  (0, import_esbuildCollectIconPlugin.esbuildCollectIconPlugin)({
70
70
  icons,
71
71
  alias: ((_b = opts.options) == null ? void 0 : _b.alias) || {}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@umijs/preset-umi",
3
- "version": "4.0.43",
3
+ "version": "4.0.45",
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",
@@ -27,19 +27,19 @@
27
27
  "dependencies": {
28
28
  "@iconify/utils": "2.0.9",
29
29
  "@svgr/core": "6.2.1",
30
- "@umijs/ast": "4.0.43",
31
- "@umijs/babel-preset-umi": "4.0.43",
32
- "@umijs/bundler-utils": "4.0.43",
33
- "@umijs/bundler-vite": "4.0.43",
34
- "@umijs/bundler-webpack": "4.0.43",
35
- "@umijs/core": "4.0.43",
30
+ "@umijs/ast": "4.0.45",
31
+ "@umijs/babel-preset-umi": "4.0.45",
32
+ "@umijs/bundler-utils": "4.0.45",
33
+ "@umijs/bundler-vite": "4.0.45",
34
+ "@umijs/bundler-webpack": "4.0.45",
35
+ "@umijs/core": "4.0.45",
36
36
  "@umijs/did-you-know": "^1.0.0",
37
37
  "@umijs/history": "5.3.1",
38
- "@umijs/mfsu": "4.0.43",
39
- "@umijs/plugin-run": "4.0.43",
40
- "@umijs/renderer-react": "4.0.43",
41
- "@umijs/server": "4.0.43",
42
- "@umijs/utils": "4.0.43",
38
+ "@umijs/mfsu": "4.0.45",
39
+ "@umijs/plugin-run": "4.0.45",
40
+ "@umijs/renderer-react": "4.0.45",
41
+ "@umijs/server": "4.0.45",
42
+ "@umijs/utils": "4.0.45",
43
43
  "babel-plugin-dynamic-import-node": "2.3.3",
44
44
  "click-to-react-component": "^1.0.8",
45
45
  "core-js": "3.27.1",