@esmx/import 3.0.0-rc.116 → 3.0.0-rc.118

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/package.json CHANGED
@@ -1,5 +1,15 @@
1
1
  {
2
2
  "name": "@esmx/import",
3
+ "description": "Import map utilities for resolving and merging ESM import maps",
4
+ "repository": {
5
+ "type": "git",
6
+ "url": "https://github.com/esmnext/esmx.git",
7
+ "directory": "packages/import"
8
+ },
9
+ "homepage": "https://github.com/esmnext/esmx",
10
+ "bugs": {
11
+ "url": "https://github.com/esmnext/esmx/issues"
12
+ },
3
13
  "template": "library-node",
4
14
  "license": "MIT",
5
15
  "contributors": [
@@ -24,8 +34,8 @@
24
34
  "lint:js": "biome check --write --no-errors-on-unmatched",
25
35
  "lint:css": "pnpm run lint:js",
26
36
  "lint:type": "tsc --noEmit",
27
- "test": "vitest run --pass-with-no-tests",
28
- "coverage": "vitest run --coverage --pass-with-no-tests",
37
+ "test": "cross-env NODE_OPTIONS=--experimental-vm-modules vitest run --pass-with-no-tests",
38
+ "coverage": "cross-env NODE_OPTIONS=--experimental-vm-modules vitest run --coverage --pass-with-no-tests",
29
39
  "build": "unbuild"
30
40
  },
31
41
  "dependencies": {
@@ -34,12 +44,13 @@
34
44
  "devDependencies": {
35
45
  "@biomejs/biome": "2.3.7",
36
46
  "@types/node": "^24.0.0",
37
- "@vitest/coverage-v8": "3.2.4",
47
+ "@vitest/coverage-v8": "3.2.6",
48
+ "cross-env": "^10.1.0",
38
49
  "typescript": "5.9.3",
39
50
  "unbuild": "3.6.1",
40
- "vitest": "3.2.4"
51
+ "vitest": "3.2.6"
41
52
  },
42
- "version": "3.0.0-rc.116",
53
+ "version": "3.0.0-rc.118",
43
54
  "type": "module",
44
55
  "private": false,
45
56
  "exports": {
@@ -58,5 +69,11 @@
58
69
  "template",
59
70
  "public"
60
71
  ],
61
- "gitHead": "2e16b175552400382913b445ae7e112b78c422f5"
72
+ "gitHead": "2fdbd62470f64e6e45568550941c78cb259e4917",
73
+ "engines": {
74
+ "node": ">=24"
75
+ },
76
+ "publishConfig": {
77
+ "access": "public"
78
+ }
62
79
  }
package/src/error.test.ts CHANGED
@@ -202,5 +202,51 @@ describe('Module Loading Errors', () => {
202
202
  ` └─ ${relativeE} ❌ Loading failed`
203
203
  );
204
204
  });
205
+
206
+ it('should handle formatModuleChain with original error', () => {
207
+ const moduleIds: string[] = [];
208
+ const targetModule = '/src/error.js';
209
+ const originalError = new Error('Original error message');
210
+
211
+ const formatted = formatModuleChain(
212
+ moduleIds,
213
+ targetModule,
214
+ originalError
215
+ );
216
+
217
+ expect(formatted).toContain('Error details:');
218
+ expect(formatted).toContain('Original error message');
219
+ });
220
+ });
221
+
222
+ describe('ModuleLoadingError base class', () => {
223
+ it('should create base error with all properties', () => {
224
+ const moduleIds = ['/src/a.js'];
225
+ const targetModule = '/src/b.js';
226
+ const originalError = new Error('cause');
227
+
228
+ const error = new ModuleLoadingError(
229
+ 'Base error',
230
+ moduleIds,
231
+ targetModule,
232
+ originalError
233
+ );
234
+
235
+ expect(error.name).toBe('ModuleLoadingError');
236
+ expect(error.message).toBe('Base error');
237
+ expect(error.moduleIds).toEqual(moduleIds);
238
+ expect(error.targetModule).toBe(targetModule);
239
+ expect(error.originalError).toBe(originalError);
240
+ });
241
+
242
+ it('should create base error without original error', () => {
243
+ const error = new ModuleLoadingError(
244
+ 'Simple error',
245
+ [],
246
+ '/src/x.js'
247
+ );
248
+
249
+ expect(error.originalError).toBeUndefined();
250
+ });
205
251
  });
206
252
  });
@@ -21,14 +21,17 @@ export function createLoaderImport(baseURL: URL, importMap: ImportMap = {}) {
21
21
  registered = JSON.stringify(importMap);
22
22
  } else if (registered !== JSON.stringify(importMap)) {
23
23
  throw new Error(
24
- `'createLoaderImport()' can only be created once and cannot be created repeatedly`
24
+ `[@esmx/import] createLoaderImport() is a per-process singleton and was called twice with different importMap data. Ensure your app initializes the loader exactly once at startup.`
25
25
  );
26
26
  }
27
27
  return (specifier: string): Promise<Record<string, any>> => {
28
28
  try {
29
29
  return import(specifier);
30
30
  } catch (e) {
31
- throw new Error(`Failed to import '${specifier}'`);
31
+ const cause = e instanceof Error ? e.message : String(e);
32
+ throw new Error(
33
+ `[@esmx/import] Failed to import '${specifier}'. Verify the specifier is declared in the importMap (modules.imports in entry.node.ts) or matches a federated module name. Original error: ${cause}`
34
+ );
32
35
  }
33
36
  };
34
37
  }