@endo/module-source
Advanced tools
Comparing version
{ | ||
"name": "@endo/module-source", | ||
"version": "1.1.2", | ||
"version": "1.2.0", | ||
"description": "Ponyfill for the SES ModuleSource and module-to-program transformer", | ||
@@ -25,3 +25,6 @@ "keywords": [ | ||
"exports": { | ||
".": "./index.js", | ||
".": { | ||
"xs": "./src-xs/index.js", | ||
"default": "./index.js" | ||
}, | ||
"./shim.js": "./shim.js", | ||
@@ -39,3 +42,4 @@ "./package.json": "./package.json" | ||
"lint-fix": "eslint --fix .", | ||
"test": "ava" | ||
"test": "ava", | ||
"test:xs": "node scripts/generate-test-xs.js && xst tmp/test-xs.js" | ||
}, | ||
@@ -47,3 +51,3 @@ "dependencies": { | ||
"@babel/types": "^7.24.0", | ||
"ses": "^1.10.0" | ||
"ses": "^1.11.0" | ||
}, | ||
@@ -91,3 +95,3 @@ "devDependencies": { | ||
}, | ||
"gitHead": "5486ed1f238104716b6a8321b977fbc508ef80e1" | ||
"gitHead": "e0683e0bfdbfc84351af332c9e78813d7b67ef89" | ||
} |
@@ -77,2 +77,11 @@ # ModuleSource | ||
## XS Specific Variant | ||
With the `xs` condition, `@endo/module-source` will not entrain Babel and will | ||
just adapt the native `ModuleSource` to the older interface presented by this | ||
package. | ||
That is, the XS native `bindings` will be translated to `imports`, `exports`, | ||
and `reexports` getters. | ||
This form of `ModuleSource` ignores all options. | ||
## Bug Disclosure | ||
@@ -79,0 +88,0 @@ |
/* global globalThis */ | ||
import { ModuleSource } from './index.js'; | ||
// We are using a reflexive import to make sure we pass through the conditional | ||
// export in package.json. | ||
// Eslint does not yet seem to have a carve-out for package-reflexive imports. | ||
// eslint-disable-next-line import/no-extraneous-dependencies | ||
import { ModuleSource } from '@endo/module-source'; | ||
@@ -5,0 +9,0 @@ Object.defineProperty(globalThis, 'ModuleSource', { |
@@ -52,2 +52,3 @@ /* eslint max-lines: 0 */ | ||
importMeta, | ||
dynamicImport, | ||
} = options; | ||
@@ -290,2 +291,3 @@ | ||
if (path.node.callee.type === 'Import') { | ||
dynamicImport.present = true; | ||
path.node.callee = hiddenIdentifier(h.HIDDEN_IMPORT); | ||
@@ -292,0 +294,0 @@ } |
@@ -65,2 +65,3 @@ /** | ||
__fixedExportMap__: any; | ||
__needsImport__: boolean; | ||
__needsImportMeta__: boolean; | ||
@@ -67,0 +68,0 @@ } |
@@ -85,2 +85,3 @@ /* eslint no-underscore-dangle: ["off"] */ | ||
exportAlls, | ||
needsImport, | ||
needsImportMeta, | ||
@@ -101,2 +102,3 @@ } = analyzeModule(source, opts); | ||
this.__fixedExportMap__ = fixedExportMap; | ||
this.__needsImport__ = needsImport; | ||
this.__needsImportMeta__ = needsImportMeta; | ||
@@ -103,0 +105,0 @@ freeze(this); |
@@ -7,2 +7,3 @@ export function makeModuleAnalyzer(babel: any): (moduleSource: string, { sourceUrl, sourceMapUrl, sourceMap, sourceMapHook }?: Options) => Readonly<{ | ||
reexportMap: any; | ||
needsImport: boolean; | ||
needsImportMeta: boolean; | ||
@@ -9,0 +10,0 @@ functorSource: string; |
@@ -44,2 +44,3 @@ // @ts-nocheck XXX Babel types | ||
importDecls: [], | ||
dynamicImport: { present: false }, | ||
// enables passing import.meta usage hints up. | ||
@@ -107,2 +108,3 @@ importMeta: { present: false }, | ||
onceVar: ${h.HIDDEN_ONCE}, \ | ||
import: ${h.HIDDEN_IMPORT}, \ | ||
importMeta: ${h.HIDDEN_META}, \ | ||
@@ -124,2 +126,3 @@ }) => (function () { 'use strict'; \ | ||
reexportMap: freeze(sourceOptions.reexportMap), | ||
needsImport: sourceOptions.dynamicImport.present, | ||
needsImportMeta: sourceOptions.importMeta.present, | ||
@@ -126,0 +129,0 @@ functorSource, |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
63558
1.67%1141
1.15%95
10.47%Updated