@endo/module-source 1.1.2 → 1.2.0
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 +9 -0
- package/package.json +9 -5
- package/shim.js +5 -1
- package/src/babelPlugin.d.ts.map +1 -1
- package/src/babelPlugin.js +2 -0
- package/src/module-source.d.ts +1 -0
- package/src/module-source.d.ts.map +1 -1
- package/src/module-source.js +2 -0
- package/src/transform-analyze.d.ts +1 -0
- package/src/transform-analyze.d.ts.map +1 -1
- package/src/transform-analyze.js +3 -0
package/README.md
CHANGED
|
@@ -74,6 +74,15 @@ the hook returns a promise, it will be dropped and rejections will go uncaught.
|
|
|
74
74
|
If the hook must do async work, these should be queued up as a job that the
|
|
75
75
|
caller can later await.
|
|
76
76
|
|
|
77
|
+
## XS Specific Variant
|
|
78
|
+
|
|
79
|
+
With the `xs` condition, `@endo/module-source` will not entrain Babel and will
|
|
80
|
+
just adapt the native `ModuleSource` to the older interface presented by this
|
|
81
|
+
package.
|
|
82
|
+
That is, the XS native `bindings` will be translated to `imports`, `exports`,
|
|
83
|
+
and `reexports` getters.
|
|
84
|
+
This form of `ModuleSource` ignores all options.
|
|
85
|
+
|
|
77
86
|
## Bug Disclosure
|
|
78
87
|
|
|
79
88
|
Please help us practice coordinated security bug disclosure, by using the
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@endo/module-source",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.2.0",
|
|
4
4
|
"description": "Ponyfill for the SES ModuleSource and module-to-program transformer",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"ses",
|
|
@@ -22,7 +22,10 @@
|
|
|
22
22
|
"type": "module",
|
|
23
23
|
"main": "./index.js",
|
|
24
24
|
"exports": {
|
|
25
|
-
".":
|
|
25
|
+
".": {
|
|
26
|
+
"xs": "./src-xs/index.js",
|
|
27
|
+
"default": "./index.js"
|
|
28
|
+
},
|
|
26
29
|
"./shim.js": "./shim.js",
|
|
27
30
|
"./package.json": "./package.json"
|
|
28
31
|
},
|
|
@@ -35,14 +38,15 @@
|
|
|
35
38
|
"lint:types": "tsc",
|
|
36
39
|
"lint:eslint": "eslint .",
|
|
37
40
|
"lint-fix": "eslint --fix .",
|
|
38
|
-
"test": "ava"
|
|
41
|
+
"test": "ava",
|
|
42
|
+
"test:xs": "node scripts/generate-test-xs.js && xst tmp/test-xs.js"
|
|
39
43
|
},
|
|
40
44
|
"dependencies": {
|
|
41
45
|
"@agoric/babel-generator": "^7.17.6",
|
|
42
46
|
"@babel/parser": "^7.23.6",
|
|
43
47
|
"@babel/traverse": "^7.23.6",
|
|
44
48
|
"@babel/types": "^7.24.0",
|
|
45
|
-
"ses": "^1.
|
|
49
|
+
"ses": "^1.11.0"
|
|
46
50
|
},
|
|
47
51
|
"devDependencies": {
|
|
48
52
|
"ava": "^6.1.3",
|
|
@@ -85,5 +89,5 @@
|
|
|
85
89
|
"typeCoverage": {
|
|
86
90
|
"atLeast": 40.33
|
|
87
91
|
},
|
|
88
|
-
"gitHead": "
|
|
92
|
+
"gitHead": "e0683e0bfdbfc84351af332c9e78813d7b67ef89"
|
|
89
93
|
}
|
package/shim.js
CHANGED
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
/* global globalThis */
|
|
2
2
|
|
|
3
|
-
import
|
|
3
|
+
// We are using a reflexive import to make sure we pass through the conditional
|
|
4
|
+
// export in package.json.
|
|
5
|
+
// Eslint does not yet seem to have a carve-out for package-reflexive imports.
|
|
6
|
+
// eslint-disable-next-line import/no-extraneous-dependencies
|
|
7
|
+
import { ModuleSource } from '@endo/module-source';
|
|
4
8
|
|
|
5
9
|
Object.defineProperty(globalThis, 'ModuleSource', {
|
|
6
10
|
value: ModuleSource,
|
package/src/babelPlugin.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"babelPlugin.d.ts","sourceRoot":"","sources":["babelPlugin.js"],"names":[],"mappings":";AAwCA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"babelPlugin.d.ts","sourceRoot":"","sources":["babelPlugin.js"],"names":[],"mappings":";AAwCA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA+kBC"}
|
package/src/babelPlugin.js
CHANGED
|
@@ -49,6 +49,7 @@ function makeModulePlugins(options) {
|
|
|
49
49
|
reexportMap,
|
|
50
50
|
liveExportMap,
|
|
51
51
|
importMeta,
|
|
52
|
+
dynamicImport,
|
|
52
53
|
} = options;
|
|
53
54
|
|
|
54
55
|
if (sourceType !== 'module') {
|
|
@@ -286,6 +287,7 @@ function makeModulePlugins(options) {
|
|
|
286
287
|
CallExpression(path) {
|
|
287
288
|
// import(FOO) -> $h_import(FOO)
|
|
288
289
|
if (path.node.callee.type === 'Import') {
|
|
290
|
+
dynamicImport.present = true;
|
|
289
291
|
path.node.callee = hiddenIdentifier(h.HIDDEN_IMPORT);
|
|
290
292
|
}
|
|
291
293
|
},
|
package/src/module-source.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"module-source.d.ts","sourceRoot":"","sources":["module-source.js"],"names":[],"mappings":"AAmCA;;;;;;GAMG;AAEH;;;;GAIG;AAEH;;;;;;GAMG;AAKH;;;;;;;GAOG;AACH,qCAHW,MAAM,
|
|
1
|
+
{"version":3,"file":"module-source.d.ts","sourceRoot":"","sources":["module-source.js"],"names":[],"mappings":"AAmCA;;;;;;GAMG;AAEH;;;;GAIG;AAEH;;;;;;GAMG;AAKH;;;;;;;GAOG;AACH,qCAHW,MAAM,6CAsChB;;IApED;;;;;;OAMG;IAEH;;;;OAIG;IAEH;;;;;;OAMG;IAKH;;;;;;;OAOG;IACH,oBAHW,MAAM,uCAsChB;IAhBC,kBAAyC;IACzC,eAMC;IACD,mBAA+C;IAC/C,8BAA0C;IAC1C,uBAAsC;IACtC,qBAAkC;IAClC,wBAAwC;IACxC,yBAAkC;IAClC,6BAA0C;;;iBAhE9B,MAAM;YACN,MAAM;cACN,MAAM;YACN,MAAM;;wCAKT,MAAM,WACN,oBAAoB"}
|
package/src/module-source.js
CHANGED
|
@@ -82,6 +82,7 @@ export function ModuleSource(source, opts = {}) {
|
|
|
82
82
|
reexportMap,
|
|
83
83
|
fixedExportMap,
|
|
84
84
|
exportAlls,
|
|
85
|
+
needsImport,
|
|
85
86
|
needsImportMeta,
|
|
86
87
|
} = analyzeModule(source, opts);
|
|
87
88
|
this.imports = freeze([...keys(imports)]);
|
|
@@ -97,6 +98,7 @@ export function ModuleSource(source, opts = {}) {
|
|
|
97
98
|
this.__liveExportMap__ = liveExportMap;
|
|
98
99
|
this.__reexportMap__ = reexportMap;
|
|
99
100
|
this.__fixedExportMap__ = fixedExportMap;
|
|
101
|
+
this.__needsImport__ = needsImport;
|
|
100
102
|
this.__needsImportMeta__ = needsImportMeta;
|
|
101
103
|
freeze(this);
|
|
102
104
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"transform-analyze.d.ts","sourceRoot":"","sources":["transform-analyze.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"transform-analyze.d.ts","sourceRoot":"","sources":["transform-analyze.js"],"names":[],"mappings":"AAkIO,+DArHM,MAAM,0DACN,OAAO;;;;;;;;;GAuHnB;AAEM;;EA6DN;6BA5L0B,oBAAoB"}
|
package/src/transform-analyze.js
CHANGED
|
@@ -41,6 +41,7 @@ const makeCreateStaticRecord = transformSource =>
|
|
|
41
41
|
hoistedDecls: [],
|
|
42
42
|
importSources: Object.create(null),
|
|
43
43
|
importDecls: [],
|
|
44
|
+
dynamicImport: { present: false },
|
|
44
45
|
// enables passing import.meta usage hints up.
|
|
45
46
|
importMeta: { present: false },
|
|
46
47
|
};
|
|
@@ -103,6 +104,7 @@ const makeCreateStaticRecord = transformSource =>
|
|
|
103
104
|
imports: ${h.HIDDEN_IMPORTS}, \
|
|
104
105
|
liveVar: ${h.HIDDEN_LIVE}, \
|
|
105
106
|
onceVar: ${h.HIDDEN_ONCE}, \
|
|
107
|
+
import: ${h.HIDDEN_IMPORT}, \
|
|
106
108
|
importMeta: ${h.HIDDEN_META}, \
|
|
107
109
|
}) => (function () { 'use strict'; \
|
|
108
110
|
${preamble} \
|
|
@@ -119,6 +121,7 @@ const makeCreateStaticRecord = transformSource =>
|
|
|
119
121
|
liveExportMap: freeze(sourceOptions.liveExportMap),
|
|
120
122
|
fixedExportMap: freeze(sourceOptions.fixedExportMap),
|
|
121
123
|
reexportMap: freeze(sourceOptions.reexportMap),
|
|
124
|
+
needsImport: sourceOptions.dynamicImport.present,
|
|
122
125
|
needsImportMeta: sourceOptions.importMeta.present,
|
|
123
126
|
functorSource,
|
|
124
127
|
});
|