@esmx/import 3.0.0-rc.46 → 3.0.0-rc.48
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/import-vm.d.ts +1 -1
- package/dist/import-vm.mjs +5 -5
- package/package.json +3 -3
- package/src/import-vm.ts +6 -6
package/dist/import-vm.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import vm from 'node:vm';
|
|
2
2
|
import type { ImportMap } from './types';
|
|
3
|
-
export declare function createVmImport(baseURL: URL, importMap?: ImportMap): (specifier: string, parent: string, sandbox?: vm.Context, options?: vm.CreateContextOptions) => Promise<
|
|
3
|
+
export declare function createVmImport(baseURL: URL, importMap?: ImportMap): (specifier: string, parent: string, sandbox?: vm.Context, options?: vm.CreateContextOptions) => Promise<any>;
|
package/dist/import-vm.mjs
CHANGED
|
@@ -46,14 +46,14 @@ export function createVmImport(baseURL, importMap = {}) {
|
|
|
46
46
|
return importBuiltinModule(specifier, context);
|
|
47
47
|
}
|
|
48
48
|
const meta = buildMeta(specifier, parent);
|
|
49
|
-
if (moduleIds.includes(meta.
|
|
49
|
+
if (moduleIds.includes(meta.url)) {
|
|
50
50
|
throw new CircularDependencyError(
|
|
51
51
|
"Circular dependency detected",
|
|
52
52
|
moduleIds,
|
|
53
53
|
meta.filename
|
|
54
54
|
);
|
|
55
55
|
}
|
|
56
|
-
const module = cache.get(meta.
|
|
56
|
+
const module = cache.get(meta.url);
|
|
57
57
|
if (module) {
|
|
58
58
|
return module;
|
|
59
59
|
}
|
|
@@ -62,7 +62,7 @@ export function createVmImport(baseURL, importMap = {}) {
|
|
|
62
62
|
moduleBuild().then(resolve);
|
|
63
63
|
});
|
|
64
64
|
});
|
|
65
|
-
cache.set(meta.
|
|
65
|
+
cache.set(meta.url, modulePromise);
|
|
66
66
|
return modulePromise;
|
|
67
67
|
async function moduleBuild() {
|
|
68
68
|
let text;
|
|
@@ -85,7 +85,7 @@ export function createVmImport(baseURL, importMap = {}) {
|
|
|
85
85
|
importModuleDynamically: (specifier2, referrer) => {
|
|
86
86
|
return moduleLinker(
|
|
87
87
|
specifier2,
|
|
88
|
-
meta.
|
|
88
|
+
meta.url,
|
|
89
89
|
referrer.context,
|
|
90
90
|
cache,
|
|
91
91
|
[...moduleIds, meta.filename]
|
|
@@ -95,7 +95,7 @@ export function createVmImport(baseURL, importMap = {}) {
|
|
|
95
95
|
await module2.link((specifier2, referrer) => {
|
|
96
96
|
return moduleLinker(
|
|
97
97
|
specifier2,
|
|
98
|
-
meta.
|
|
98
|
+
meta.url,
|
|
99
99
|
referrer.context,
|
|
100
100
|
cache,
|
|
101
101
|
[...moduleIds, meta.filename]
|
package/package.json
CHANGED
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
},
|
|
34
34
|
"devDependencies": {
|
|
35
35
|
"@biomejs/biome": "1.9.4",
|
|
36
|
-
"@esmx/lint": "3.0.0-rc.
|
|
36
|
+
"@esmx/lint": "3.0.0-rc.48",
|
|
37
37
|
"@types/node": "^24.0.0",
|
|
38
38
|
"@vitest/coverage-v8": "3.2.4",
|
|
39
39
|
"stylelint": "16.21.0",
|
|
@@ -41,7 +41,7 @@
|
|
|
41
41
|
"unbuild": "3.5.0",
|
|
42
42
|
"vitest": "3.2.4"
|
|
43
43
|
},
|
|
44
|
-
"version": "3.0.0-rc.
|
|
44
|
+
"version": "3.0.0-rc.48",
|
|
45
45
|
"type": "module",
|
|
46
46
|
"private": false,
|
|
47
47
|
"exports": {
|
|
@@ -60,5 +60,5 @@
|
|
|
60
60
|
"template",
|
|
61
61
|
"public"
|
|
62
62
|
],
|
|
63
|
-
"gitHead": "
|
|
63
|
+
"gitHead": "162ec15d59c5f38c477e78101efa689844d593e2"
|
|
64
64
|
}
|
package/src/import-vm.ts
CHANGED
|
@@ -57,7 +57,7 @@ export function createVmImport(baseURL: URL, importMap: ImportMap = {}) {
|
|
|
57
57
|
}
|
|
58
58
|
const meta = buildMeta(specifier, parent);
|
|
59
59
|
|
|
60
|
-
if (moduleIds.includes(meta.
|
|
60
|
+
if (moduleIds.includes(meta.url)) {
|
|
61
61
|
throw new CircularDependencyError(
|
|
62
62
|
'Circular dependency detected',
|
|
63
63
|
moduleIds,
|
|
@@ -65,7 +65,7 @@ export function createVmImport(baseURL: URL, importMap: ImportMap = {}) {
|
|
|
65
65
|
);
|
|
66
66
|
}
|
|
67
67
|
|
|
68
|
-
const module = cache.get(meta.
|
|
68
|
+
const module = cache.get(meta.url);
|
|
69
69
|
if (module) {
|
|
70
70
|
return module;
|
|
71
71
|
}
|
|
@@ -75,7 +75,7 @@ export function createVmImport(baseURL: URL, importMap: ImportMap = {}) {
|
|
|
75
75
|
});
|
|
76
76
|
});
|
|
77
77
|
|
|
78
|
-
cache.set(meta.
|
|
78
|
+
cache.set(meta.url, modulePromise);
|
|
79
79
|
return modulePromise;
|
|
80
80
|
|
|
81
81
|
async function moduleBuild(): Promise<vm.SourceTextModule> {
|
|
@@ -99,7 +99,7 @@ export function createVmImport(baseURL: URL, importMap: ImportMap = {}) {
|
|
|
99
99
|
importModuleDynamically: (specifier, referrer) => {
|
|
100
100
|
return moduleLinker(
|
|
101
101
|
specifier,
|
|
102
|
-
meta.
|
|
102
|
+
meta.url,
|
|
103
103
|
referrer.context,
|
|
104
104
|
cache,
|
|
105
105
|
[...moduleIds, meta.filename]
|
|
@@ -109,7 +109,7 @@ export function createVmImport(baseURL: URL, importMap: ImportMap = {}) {
|
|
|
109
109
|
await module.link((specifier: string, referrer) => {
|
|
110
110
|
return moduleLinker(
|
|
111
111
|
specifier,
|
|
112
|
-
meta.
|
|
112
|
+
meta.url,
|
|
113
113
|
referrer.context,
|
|
114
114
|
cache,
|
|
115
115
|
[...moduleIds, meta.filename]
|
|
@@ -134,6 +134,6 @@ export function createVmImport(baseURL: URL, importMap: ImportMap = {}) {
|
|
|
134
134
|
[]
|
|
135
135
|
);
|
|
136
136
|
|
|
137
|
-
return module.namespace
|
|
137
|
+
return module.namespace;
|
|
138
138
|
};
|
|
139
139
|
}
|