@umijs/mfsu 4.0.64 → 4.0.66

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/dep/dep.d.ts CHANGED
@@ -15,6 +15,7 @@ export declare class Dep {
15
15
  excludeNodeNatives: boolean;
16
16
  importer?: string;
17
17
  });
18
+ private normalizePath;
18
19
  buildExposeContent(): Promise<string>;
19
20
  getRealFile(): Promise<string | null>;
20
21
  static buildDeps(opts: {
package/dist/dep/dep.js CHANGED
@@ -34,6 +34,7 @@ __export(dep_exports, {
34
34
  module.exports = __toCommonJS(dep_exports);
35
35
  var import_utils = require("@umijs/utils");
36
36
  var import_assert = __toESM(require("assert"));
37
+ var import_crypto = require("crypto");
37
38
  var import_fs = require("fs");
38
39
  var import_path = require("path");
39
40
  var import_constants = require("../constants");
@@ -46,11 +47,24 @@ var Dep = class {
46
47
  this.version = opts.version;
47
48
  this.cwd = opts.cwd;
48
49
  this.shortFile = this.file;
49
- this.normalizedFile = this.shortFile.replace(/\//g, "_").replace(/:/g, "_");
50
+ this.normalizedFile = this.normalizePath(this.shortFile);
50
51
  this.filePath = `${import_constants.MF_VA_PREFIX}${this.normalizedFile}.js`;
51
52
  this.excludeNodeNatives = opts.excludeNodeNatives;
52
53
  this.importer = opts.importer;
53
54
  }
55
+ normalizePath(p) {
56
+ let longPath = p;
57
+ if (longPath.startsWith(this.cwd)) {
58
+ longPath = longPath.slice(this.cwd.length);
59
+ }
60
+ longPath = longPath.replace(/\//g, "_").replace(/:/g, "_");
61
+ if (longPath.length <= 200) {
62
+ return longPath;
63
+ }
64
+ const hash = (0, import_crypto.createHash)("md5").update(longPath).digest("hex").slice(0, 16);
65
+ const post = longPath.slice(-200);
66
+ return `${hash}_${post}`;
67
+ }
54
68
  async buildExposeContent() {
55
69
  const isNodeNatives = !!process.binding("natives")[this.file];
56
70
  if (isNodeNatives) {
@@ -26,6 +26,22 @@ module.exports = __toCommonJS(esbuild_exports);
26
26
  var import_es_module_lexer = require("@umijs/bundler-utils/compiled/es-module-lexer");
27
27
  var import_esbuild = require("@umijs/bundler-utils/compiled/esbuild");
28
28
  var import_path = require("path");
29
+ var LOADER_MAP = {
30
+ // js
31
+ js: "js",
32
+ cjs: "js",
33
+ mjs: "js",
34
+ jsx: "jsx",
35
+ cjsx: "jsx",
36
+ mjsx: "jsx",
37
+ // ts
38
+ ts: "ts",
39
+ cts: "ts",
40
+ mts: "ts",
41
+ tsx: "tsx",
42
+ ctsx: "tsx",
43
+ mtsx: "tsx"
44
+ };
29
45
  async function esbuildTranspiler(source) {
30
46
  const done = this.async();
31
47
  const options = this.getOptions();
@@ -33,10 +49,11 @@ async function esbuildTranspiler(source) {
33
49
  const transform = (implementation == null ? void 0 : implementation.transform) || import_esbuild.transform;
34
50
  const filePath = this.resourcePath;
35
51
  const ext = (0, import_path.extname)(filePath).slice(1);
52
+ const loader = LOADER_MAP[ext] ?? "default";
36
53
  const transformOptions = {
37
54
  ...otherOptions,
38
55
  target: options.target ?? "es2015",
39
- loader: ext ?? "js",
56
+ loader,
40
57
  sourcemap: this.sourceMap,
41
58
  sourcefile: filePath
42
59
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@umijs/mfsu",
3
- "version": "4.0.64",
3
+ "version": "4.0.66",
4
4
  "description": "@umijs/mfsu",
5
5
  "homepage": "https://github.com/umijs/umi/tree/master/packages/mfsu#readme",
6
6
  "bugs": "https://github.com/umijs/umi/issues",
@@ -19,9 +19,9 @@
19
19
  "dependencies": {
20
20
  "enhanced-resolve": "5.9.3",
21
21
  "is-equal": "^1.6.4",
22
- "@umijs/bundler-esbuild": "4.0.64",
23
- "@umijs/bundler-utils": "4.0.64",
24
- "@umijs/utils": "4.0.64"
22
+ "@umijs/bundler-esbuild": "4.0.66",
23
+ "@umijs/bundler-utils": "4.0.66",
24
+ "@umijs/utils": "4.0.66"
25
25
  },
26
26
  "devDependencies": {
27
27
  "is-absolute-url": "^4.0.1",