@umijs/preset-umi 4.2.8 → 4.2.10

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.
@@ -271,6 +271,7 @@ PORT=8888 umi dev
271
271
  };
272
272
  if (((_b = api.config.mfsu) == null ? void 0 : _b.strategy) === "eager") {
273
273
  srcCodeCache = new import_LazySourceCodeCache.LazySourceCodeCache({
274
+ root: api.paths.cwd,
274
275
  cwd: api.paths.absSrcPath,
275
276
  cachePath: (0, import_path.join)(
276
277
  api.paths.absNodeModulesPath,
@@ -93,6 +93,7 @@ var MFSUUtilBase = class {
93
93
  };
94
94
  if (((_a = api.config.mfsu) == null ? void 0 : _a.strategy) === "eager") {
95
95
  srcCodeCache = new import_LazySourceCodeCache.LazySourceCodeCache({
96
+ root: api.paths.cwd,
96
97
  cwd: api.paths.absSrcPath,
97
98
  cachePath: (0, import_path.join)(
98
99
  api.paths.absNodeModulesPath,
@@ -35,13 +35,16 @@ module.exports = __toCommonJS(build_exports);
35
35
  var import_watchRebuild = require("@umijs/bundler-esbuild/dist/plugins/watchRebuild");
36
36
  var import_esbuild = __toESM(require("@umijs/bundler-utils/compiled/esbuild"));
37
37
  var import_utils = require("@umijs/utils");
38
+ var import_fs = require("fs");
38
39
  var import_path = __toESM(require("path"));
40
+ var import_constant = require("../../libs/folderCache/constant");
39
41
  var import_esbuildAliasPlugin = require("./esbuildPlugins/esbuildAliasPlugin");
40
42
  var import_esbuildExternalPlugin = require("./esbuildPlugins/esbuildExternalPlugin");
41
43
  async function build(opts) {
42
44
  var _a;
43
45
  const outdir = import_path.default.join(import_path.default.dirname(opts.entryPoints[0]), "out");
44
46
  const alias = ((_a = opts.config) == null ? void 0 : _a.alias) || {};
47
+ const tsconfig = (0, import_fs.existsSync)(import_path.default.join(opts.config.cwd, "tsconfig.json")) ? "tsconfig.json" : void 0;
45
48
  const buildOptions = {
46
49
  // 需要指定 absWorkingDir 兼容 APP_ROOT 的情况
47
50
  absWorkingDir: opts.config.cwd,
@@ -50,12 +53,14 @@ async function build(opts) {
50
53
  target: "esnext",
51
54
  loader: {
52
55
  // use tsx loader for js/jsx/ts/tsx files
53
- // since only ts support decorator
56
+ // since only ts support paramDecorator
57
+ ...import_constant.possibleExtUsingEmptyLoader,
54
58
  ".js": "tsx",
55
59
  ".jsx": "tsx",
56
60
  ".ts": "ts",
57
61
  ".tsx": "tsx"
58
62
  },
63
+ tsconfig,
59
64
  // do I need this?
60
65
  // incremental: true,
61
66
  bundle: true,
@@ -13,9 +13,12 @@ export declare class LazySourceCodeCache {
13
13
  private ignores;
14
14
  fileContentCache: FileContentCache;
15
15
  private pendingFilesEvents;
16
+ private root;
17
+ private tsConfigRaw;
16
18
  constructor(opts: {
17
19
  cwd: string;
18
20
  cachePath: string;
21
+ root: string;
19
22
  });
20
23
  init(files: string[]): Promise<void>;
21
24
  initWithScan(): Promise<void>;
@@ -46,6 +46,8 @@ var LazySourceCodeCache = class {
46
46
  this.ignores = import_constant.DEFAULT_SRC_IGNORES;
47
47
  this.fileContentCache = {};
48
48
  this.pendingFilesEvents = [];
49
+ this.tsConfigRaw = "{}";
50
+ this.root = opts.root;
49
51
  this.srcPath = opts.cwd;
50
52
  this.cachePath = opts.cachePath;
51
53
  this.folderWatch = new import_FolderWatch.FolderWatch({
@@ -57,6 +59,16 @@ var LazySourceCodeCache = class {
57
59
  this.folderWatch.listen((e) => {
58
60
  this.pendingFilesEvents.push(e);
59
61
  });
62
+ try {
63
+ this.tsConfigRaw = (0, import_fs.readFileSync)(
64
+ (0, import_path.join)(this.root, "tsconfig.json"),
65
+ "utf-8"
66
+ );
67
+ } catch (e) {
68
+ import_utils.logger.debug(
69
+ "load project tsconfig.json failed, fallback to empty config"
70
+ );
71
+ }
60
72
  }
61
73
  async init(files) {
62
74
  await Promise.all([import_es_module_lexer.init, this.folderWatch.init()]);
@@ -156,7 +168,8 @@ var LazySourceCodeCache = class {
156
168
  const loaded = {};
157
169
  await esbuildTransform(files, {
158
170
  srcPath: this.srcPath,
159
- cachePath: this.cachePath
171
+ cachePath: this.cachePath,
172
+ tsconfigRaw: this.tsConfigRaw
160
173
  });
161
174
  for (const f of files) {
162
175
  let newFile = (0, import_path.join)(this.cachePath, (0, import_path.relative)(this.srcPath, f));
@@ -177,12 +190,13 @@ async function esbuildTransform(files, opts) {
177
190
  outdir: opts.cachePath,
178
191
  outbase: opts.srcPath,
179
192
  loader: {
193
+ ...import_constant.possibleExtUsingEmptyLoader,
180
194
  // in case some js using some feature, eg: decorator
181
195
  ".js": "tsx",
182
196
  ".jsx": "tsx"
183
197
  },
184
198
  logLevel: "error",
185
- tsconfig: (0, import_path.join)(__dirname, "empty.tsconfig.json")
199
+ tsconfigRaw: opts.tsconfigRaw
186
200
  });
187
201
  } catch (e) {
188
202
  if (((_a = e.errors) == null ? void 0 : _a.length) || ((_b = e.warnings) == null ? void 0 : _b.length)) {
@@ -1 +1,31 @@
1
1
  export declare const DEFAULT_SRC_IGNORES: string[];
2
+ export declare const possibleExtUsingEmptyLoader: {
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
+ };
@@ -19,7 +19,8 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
19
19
  // src/libs/folderCache/constant.ts
20
20
  var constant_exports = {};
21
21
  __export(constant_exports, {
22
- DEFAULT_SRC_IGNORES: () => DEFAULT_SRC_IGNORES
22
+ DEFAULT_SRC_IGNORES: () => DEFAULT_SRC_IGNORES,
23
+ possibleExtUsingEmptyLoader: () => possibleExtUsingEmptyLoader
23
24
  });
24
25
  module.exports = __toCommonJS(constant_exports);
25
26
  var DEFAULT_SRC_IGNORES = [
@@ -35,7 +36,38 @@ var DEFAULT_SRC_IGNORES = [
35
36
  "**/jest.config.{ts,js}",
36
37
  "**/jest-setup.{ts,js}"
37
38
  ];
39
+ var possibleExtUsingEmptyLoader = {
40
+ ".aac": "empty",
41
+ ".css": "empty",
42
+ ".less": "empty",
43
+ ".sass": "empty",
44
+ ".scss": "empty",
45
+ ".eot": "empty",
46
+ ".flac": "empty",
47
+ ".gif": "empty",
48
+ ".htm": "empty",
49
+ ".html": "empty",
50
+ ".ico": "empty",
51
+ ".icon": "empty",
52
+ ".jpeg": "empty",
53
+ ".jpg": "empty",
54
+ ".empty": "empty",
55
+ ".mdx": "empty",
56
+ ".mp3": "empty",
57
+ ".mp4": "empty",
58
+ ".ogg": "empty",
59
+ ".otf": "empty",
60
+ ".png": "empty",
61
+ ".svg": "empty",
62
+ ".ttf": "empty",
63
+ ".wav": "empty",
64
+ ".webm": "empty",
65
+ ".webp": "empty",
66
+ ".woff": "empty",
67
+ ".woff2": "empty"
68
+ };
38
69
  // Annotate the CommonJS export names for ESM import in node:
39
70
  0 && (module.exports = {
40
- DEFAULT_SRC_IGNORES
71
+ DEFAULT_SRC_IGNORES,
72
+ possibleExtUsingEmptyLoader
41
73
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@umijs/preset-umi",
3
- "version": "4.2.8",
3
+ "version": "4.2.10",
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",
@@ -21,7 +21,7 @@
21
21
  "dependencies": {
22
22
  "@iconify/utils": "2.1.1",
23
23
  "@svgr/core": "6.5.1",
24
- "@umijs/bundler-mako": "0.5.2",
24
+ "@umijs/bundler-mako": "0.5.4",
25
25
  "@umijs/es-module-parser": "0.0.7",
26
26
  "@umijs/history": "5.3.1",
27
27
  "babel-plugin-dynamic-import-node": "2.3.3",
@@ -41,21 +41,21 @@
41
41
  "react-router": "6.3.0",
42
42
  "react-router-dom": "6.3.0",
43
43
  "regenerator-runtime": "0.13.11",
44
- "@umijs/babel-preset-umi": "4.2.8",
45
- "@umijs/ast": "4.2.8",
46
- "@umijs/bundler-utils": "4.2.8",
47
- "@umijs/bundler-esbuild": "4.2.8",
48
- "@umijs/bundler-vite": "4.2.8",
49
- "@umijs/bundler-webpack": "4.2.8",
50
- "@umijs/core": "4.2.8",
51
- "@umijs/mfsu": "4.2.8",
52
- "@umijs/plugin-run": "4.2.8",
53
- "@umijs/server": "4.2.8",
54
- "@umijs/renderer-react": "4.2.8",
55
- "@umijs/utils": "4.2.8",
56
- "@umijs/zod2ts": "4.2.8",
44
+ "@umijs/ast": "4.2.10",
45
+ "@umijs/bundler-esbuild": "4.2.10",
46
+ "@umijs/babel-preset-umi": "4.2.10",
47
+ "@umijs/bundler-utils": "4.2.10",
48
+ "@umijs/bundler-vite": "4.2.10",
49
+ "@umijs/core": "4.2.10",
50
+ "@umijs/bundler-webpack": "4.2.10",
57
51
  "@umijs/did-you-know": "1.0.3",
58
- "@umijs/ui": "3.0.1"
52
+ "@umijs/mfsu": "4.2.10",
53
+ "@umijs/renderer-react": "4.2.10",
54
+ "@umijs/plugin-run": "4.2.10",
55
+ "@umijs/server": "4.2.10",
56
+ "@umijs/ui": "3.0.1",
57
+ "@umijs/utils": "4.2.10",
58
+ "@umijs/zod2ts": "4.2.10"
59
59
  },
60
60
  "devDependencies": {
61
61
  "@manypkg/get-packages": "1.1.3",