@esmx/core 3.0.0-rc.62 → 3.0.0-rc.63

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/README.md CHANGED
@@ -1,5 +1,5 @@
1
1
  <div align="center">
2
- <img src="https://www.esmnext.com/logo.svg?t=2025" width="120" alt="Esmx Logo" />
2
+ <img src="https://esmx.dev/logo.svg?t=2025" width="120" alt="Esmx Logo" />
3
3
  <h1>@esmx/core</h1>
4
4
 
5
5
  <div>
@@ -9,7 +9,7 @@
9
9
  <a href="https://github.com/esmnext/esmx/actions/workflows/build.yml">
10
10
  <img src="https://github.com/esmnext/esmx/actions/workflows/build.yml/badge.svg" alt="Build" />
11
11
  </a>
12
- <a href="https://www.esmnext.com/coverage/">
12
+ <a href="https://esmx.dev/coverage/">
13
13
  <img src="https://img.shields.io/badge/coverage-live%20report-brightgreen" alt="Coverage Report" />
14
14
  </a>
15
15
  <a href="https://nodejs.org/">
@@ -47,11 +47,11 @@ npm install @esmx/core
47
47
  npm install @esmx/core
48
48
  ```
49
49
 
50
- For detailed usage examples and configuration options, please visit the [official documentation](https://www.esmnext.com).
50
+ For detailed usage examples and configuration options, please visit the [official documentation](https://esmx.dev).
51
51
 
52
52
  ## 📚 Documentation
53
53
 
54
- Visit the [official documentation](https://www.esmnext.com) for detailed usage guides and API reference.
54
+ Visit the [official documentation](https://esmx.dev) for detailed usage guides and API reference.
55
55
 
56
56
  ## 📄 License
57
57
 
package/README.zh-CN.md CHANGED
@@ -1,5 +1,5 @@
1
1
  <div align="center">
2
- <img src="https://www.esmnext.com/logo.svg?t=2025" width="120" alt="Esmx Logo" />
2
+ <img src="https://esmx.dev/logo.svg?t=2025" width="120" alt="Esmx Logo" />
3
3
  <h1>@esmx/core</h1>
4
4
 
5
5
  <div>
@@ -9,7 +9,7 @@
9
9
  <a href="https://github.com/esmnext/esmx/actions/workflows/build.yml">
10
10
  <img src="https://github.com/esmnext/esmx/actions/workflows/build.yml/badge.svg" alt="Build" />
11
11
  </a>
12
- <a href="https://www.esmnext.com/coverage/">
12
+ <a href="https://esmx.dev/coverage/">
13
13
  <img src="https://img.shields.io/badge/coverage-live%20report-brightgreen" alt="Coverage Report" />
14
14
  </a>
15
15
  <a href="https://nodejs.org/">
@@ -47,11 +47,11 @@ npm install @esmx/core
47
47
  npm install @esmx/core
48
48
  ```
49
49
 
50
- 详细的使用示例和配置选项,请访问[官方文档](https://www.esmnext.com)。
50
+ 详细的使用示例和配置选项,请访问[官方文档](https://esmx.dev)。
51
51
 
52
52
  ## 📚 文档
53
53
 
54
- 访问[官方文档](https://www.esmnext.com)获取详细的使用指南和 API 参考。
54
+ 访问[官方文档](https://esmx.dev)获取详细的使用指南和 API 参考。
55
55
 
56
56
  ## 📄 许可证
57
57
 
package/dist/core.mjs CHANGED
@@ -676,7 +676,7 @@ export class Esmx {
676
676
  const manifests = await this.getManifestList(env);
677
677
  let json = {};
678
678
  switch (env) {
679
- case "client":
679
+ case "client": {
680
680
  json = getImportMap({
681
681
  manifests,
682
682
  getScope(name, scope) {
@@ -687,6 +687,7 @@ export class Esmx {
687
687
  }
688
688
  });
689
689
  break;
690
+ }
690
691
  case "server":
691
692
  json = getImportMap({
692
693
  manifests,
@@ -17,4 +17,34 @@ export interface GetImportMapOptions {
17
17
  }
18
18
  export declare function buildImportsMap(manifests: readonly ImportMapManifest[], getFile: (name: string, file: string) => string): SpecifierMap;
19
19
  export declare function buildScopesMap(imports: SpecifierMap, manifests: readonly ImportMapManifest[], getScope: (name: string, scope: string) => string): ScopesMap;
20
- export declare function getImportMap({ manifests, getFile, getScope }: GetImportMapOptions): ImportMap;
20
+ /**
21
+ * Fixes Chrome's nested scope resolution bug in import maps.
22
+ *
23
+ * Chrome has a bug where nested scopes in import maps are not resolved correctly.
24
+ * For example, when you have both "/shared-modules/" and "/shared-modules/vue2/" scopes,
25
+ * Chrome fails to properly apply the more specific nested scope.
26
+ *
27
+ * This function works around the bug by:
28
+ * 1. Sorting scopes by path depth (shallow paths first, deeper paths last)
29
+ * 2. Manually applying scopes to matching imports in the correct order
30
+ *
31
+ * @example
32
+ * Problematic import map that fails in Chrome:
33
+ * ```json
34
+ * {
35
+ * "scopes": {
36
+ * "/shared-modules/": {
37
+ * "vue": "/shared-modules/vue.d8c7a640.final.mjs"
38
+ * },
39
+ * "/shared-modules/vue2/": {
40
+ * "vue": "/shared-modules/vue2.9b4efaf3.final.mjs"
41
+ * }
42
+ * }
43
+ * }
44
+ * ```
45
+ *
46
+ * @see https://github.com/guybedford/es-module-shims/issues/529
47
+ * @see https://issues.chromium.org/issues/453147451
48
+ */
49
+ export declare function fixNestedScopesResolution(importMap: Required<ImportMap>): Required<ImportMap>;
50
+ export declare function getImportMap({ manifests, getFile, getScope }: GetImportMapOptions): Required<ImportMap>;
@@ -36,6 +36,24 @@ export function buildScopesMap(imports, manifests, getScope) {
36
36
  });
37
37
  return scopes;
38
38
  }
39
+ export function fixNestedScopesResolution(importMap) {
40
+ Object.entries(importMap.scopes).sort(([pathA], [pathB]) => {
41
+ const depthA = pathA.split("/").length;
42
+ const depthB = pathB.split("/").length;
43
+ return depthA - depthB;
44
+ }).forEach(([scopePath, scopeMappings]) => {
45
+ Object.values(importMap.imports).forEach((importPath) => {
46
+ if (importPath.startsWith(scopePath)) {
47
+ importMap.scopes[importPath] = {
48
+ ...importMap.scopes[importPath],
49
+ ...scopeMappings
50
+ };
51
+ }
52
+ });
53
+ Reflect.deleteProperty(importMap.scopes, scopePath);
54
+ });
55
+ return importMap;
56
+ }
39
57
  export function getImportMap({
40
58
  manifests,
41
59
  getFile,