@endo/module-source 1.2.0 → 1.3.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@endo/module-source",
3
- "version": "1.2.0",
3
+ "version": "1.3.0",
4
4
  "description": "Ponyfill for the SES ModuleSource and module-to-program transformer",
5
5
  "keywords": [
6
6
  "ses",
@@ -42,11 +42,11 @@
42
42
  "test:xs": "node scripts/generate-test-xs.js && xst tmp/test-xs.js"
43
43
  },
44
44
  "dependencies": {
45
- "@agoric/babel-generator": "^7.17.6",
46
- "@babel/parser": "^7.23.6",
47
- "@babel/traverse": "^7.23.6",
48
- "@babel/types": "^7.24.0",
49
- "ses": "^1.11.0"
45
+ "@babel/generator": "^7.26.3",
46
+ "@babel/parser": "~7.26.2",
47
+ "@babel/traverse": "~7.25.9",
48
+ "@babel/types": "~7.26.0",
49
+ "ses": "^1.12.0"
50
50
  },
51
51
  "devDependencies": {
52
52
  "ava": "^6.1.3",
@@ -89,5 +89,5 @@
89
89
  "typeCoverage": {
90
90
  "atLeast": 40.33
91
91
  },
92
- "gitHead": "e0683e0bfdbfc84351af332c9e78813d7b67ef89"
92
+ "gitHead": "9b6784831d37db948cdd61f6da1f3489e8f97906"
93
93
  }
@@ -53,4 +53,4 @@ declare function makeModulePlugins(options: any): {
53
53
  };
54
54
  };
55
55
  };
56
- //# sourceMappingURL=babelPlugin.d.ts.map
56
+ //# sourceMappingURL=babel-plugin.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"babel-plugin.d.ts","sourceRoot":"","sources":["babel-plugin.js"],"names":[],"mappings":";AAwCA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA+kBC"}
@@ -1 +1 @@
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"}
1
+ {"version":3,"file":"transform-analyze.d.ts","sourceRoot":"","sources":["transform-analyze.js"],"names":[],"mappings":"AA0HO,+DA7GM,MAAM,0DACN,OAAO;;;;;;;;;GA+GnB;AAEM;;EA6DN;6BApL0B,oBAAoB"}
@@ -1,6 +1,6 @@
1
1
  // @ts-nocheck XXX Babel types
2
- import { makeTransformSource } from './transformSource.js';
3
- import makeModulePlugins from './babelPlugin.js';
2
+ import { makeTransformSource } from './transform-source.js';
3
+ import makeModulePlugins from './babel-plugin.js';
4
4
 
5
5
  import * as h from './hidden.js';
6
6
 
@@ -72,7 +72,7 @@ const makeCreateStaticRecord = transformSource =>
72
72
  .map(
73
73
  src =>
74
74
  `[${js(src)}, [${Object.entries(isrc[src])
75
- .map(([exp, upds]) => `[${js(exp)}, [${upds.join(',')}]]`)
75
+ .map(([exp, upds]) => `[${js(exp)},[${upds.join(',')}]]`)
76
76
  .join(',')}]]`,
77
77
  )
78
78
  .join(',')}]);`;
@@ -81,9 +81,7 @@ const makeCreateStaticRecord = transformSource =>
81
81
  let src = '';
82
82
  if (cvname) {
83
83
  // It's a function assigned to, so set its name property.
84
- src = `Object.defineProperty(${cvname}, 'name', {value: ${js(
85
- vname,
86
- )}});`;
84
+ src = `Object.defineProperty(${cvname},'name',{value:${js(vname)}});`;
87
85
  }
88
86
  const hDeclId = isOnce ? h.HIDDEN_ONCE : h.HIDDEN_LIVE;
89
87
  src += `${hDeclId}.${vname}(${cvname || ''});`;
@@ -100,15 +98,9 @@ const makeCreateStaticRecord = transformSource =>
100
98
  // well.
101
99
  // Relies on the evaluator to ensure these functions are strict.
102
100
  let functorSource = `\
103
- ({ \
104
- imports: ${h.HIDDEN_IMPORTS}, \
105
- liveVar: ${h.HIDDEN_LIVE}, \
106
- onceVar: ${h.HIDDEN_ONCE}, \
107
- import: ${h.HIDDEN_IMPORT}, \
108
- importMeta: ${h.HIDDEN_META}, \
109
- }) => (function () { 'use strict'; \
110
- ${preamble} \
111
- ${scriptSource}
101
+ ({imports:${h.HIDDEN_IMPORTS},liveVar:${h.HIDDEN_LIVE},onceVar:${h.HIDDEN_ONCE},import:${h.HIDDEN_IMPORT},importMeta:${h.HIDDEN_META}})=>(function(){'use strict';\
102
+ ${preamble}\
103
+ ${scriptSource}
112
104
  })()
113
105
  `;
114
106
 
@@ -0,0 +1,2 @@
1
+ export function makeTransformSource(makeModulePlugins: any, babel?: null): (source: any, sourceOptions?: {}) => string;
2
+ //# sourceMappingURL=transform-source.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"transform-source.d.ts","sourceRoot":"","sources":["transform-source.js"],"names":[],"mappings":"AAeO,uHAmDN"}
@@ -1,6 +1,6 @@
1
1
  // @ts-nocheck XXX Babel types
2
2
  import * as babelParser from '@babel/parser';
3
- import babelGenerate from '@agoric/babel-generator';
3
+ import babelGenerate from '@babel/generator';
4
4
  import babelTraverse from '@babel/traverse';
5
5
  import * as babelTypes from '@babel/types';
6
6
 
@@ -26,7 +26,11 @@ export const makeTransformSource = (makeModulePlugins, babel = null) => {
26
26
  const { sourceUrl, sourceMapUrl, sourceType, sourceMap, sourceMapHook } =
27
27
  sourceOptions;
28
28
 
29
- const ast = parseBabel(source, { sourceType });
29
+ const ast = parseBabel(source, {
30
+ sourceType,
31
+ tokens: true,
32
+ createParenthesizedExpressions: true,
33
+ });
30
34
 
31
35
  traverseBabel(ast, visitorFromPlugin(analyzePlugin));
32
36
  traverseBabel(ast, visitorFromPlugin(transformPlugin));
@@ -34,14 +38,19 @@ export const makeTransformSource = (makeModulePlugins, babel = null) => {
34
38
  const sourceMaps = sourceOptions.sourceMapHook !== undefined;
35
39
 
36
40
  const { code: transformedSource, map: transformedSourceMap } =
37
- generateBabel(ast, {
38
- sourceFileName: sourceMapUrl,
39
- sourceMaps,
40
- inputSourceMap: sourceMap,
41
- retainLines: true,
42
- compact: true,
43
- verbatim: true,
44
- });
41
+ generateBabel(
42
+ ast,
43
+ {
44
+ sourceFileName: sourceMapUrl,
45
+ sourceMaps,
46
+ inputSourceMap: sourceMap,
47
+ experimental_preserveFormat: true,
48
+ preserveFormat: true,
49
+ retainLines: true,
50
+ verbatim: true,
51
+ },
52
+ source,
53
+ );
45
54
 
46
55
  if (sourceMaps) {
47
56
  sourceMapHook(transformedSourceMap, {
@@ -1 +0,0 @@
1
- {"version":3,"file":"babelPlugin.d.ts","sourceRoot":"","sources":["babelPlugin.js"],"names":[],"mappings":";AAwCA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA+kBC"}
@@ -1,2 +0,0 @@
1
- export function makeTransformSource(makeModulePlugins: any, babel?: null): (source: any, sourceOptions?: {}) => any;
2
- //# sourceMappingURL=transformSource.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"transformSource.d.ts","sourceRoot":"","sources":["transformSource.js"],"names":[],"mappings":"AAeO,oHA0CN"}
File without changes