@endo/static-module-record
Advanced tools
Comparing version 0.6.6 to 0.6.7
@@ -6,2 +6,13 @@ # Change Log | ||
### [0.6.7](https://github.com/endojs/endo/compare/@endo/static-module-record@0.6.6...@endo/static-module-record@0.6.7) (2021-12-08) | ||
### Bug Fixes | ||
* Avoid eslint globs for Windows ([4b4f3cc](https://github.com/endojs/endo/commit/4b4f3ccaf3f5e8d53faefb4264db343dd603bf80)) | ||
* **static-module-record:** cleaner Babel codegen ([6e22569](https://github.com/endojs/endo/commit/6e22569b0c3f56e9f78d59943235b97ba0429921)) | ||
* **static-module-record:** minimise source changes with `recast` ([ce464ff](https://github.com/endojs/endo/commit/ce464ffddc9fbee27ab167b5cb06e0c788ae31e7)) | ||
### [0.6.6](https://github.com/endojs/endo/compare/@endo/static-module-record@0.6.5...@endo/static-module-record@0.6.6) (2021-11-16) | ||
@@ -8,0 +19,0 @@ |
{ | ||
"name": "@endo/static-module-record", | ||
"version": "0.6.6", | ||
"version": "0.6.7", | ||
"description": "Shim for the SES StaticModuleRecord and module-to-program transformer", | ||
@@ -33,13 +33,16 @@ "keywords": [ | ||
"lint:types": "tsc --build jsconfig.json", | ||
"lint:js": "eslint '**/*.js'", | ||
"lint-fix": "eslint --fix '**/*.js'", | ||
"lint:js": "eslint .", | ||
"lint-fix": "eslint --fix .", | ||
"test": "ava" | ||
}, | ||
"dependencies": { | ||
"@agoric/babel-standalone": "^7.14.3" | ||
"@agoric/babel-standalone": "^7.14.3", | ||
"@agoric/recast": "^0.20.6", | ||
"@babel/traverse": "^7.10.4", | ||
"@babel/types": "^7.10.4" | ||
}, | ||
"devDependencies": { | ||
"@ava/babel": "^1.0.1", | ||
"@endo/eslint-config": "^0.3.18", | ||
"@endo/ses-ava": "^0.2.11", | ||
"@endo/eslint-config": "^0.3.19", | ||
"@endo/ses-ava": "^0.2.12", | ||
"ava": "^3.12.1", | ||
@@ -55,3 +58,3 @@ "babel-eslint": "^10.0.3", | ||
"prettier": "^1.19.1", | ||
"ses": "^0.15.1", | ||
"ses": "^0.15.2", | ||
"typescript": "^4.0.5" | ||
@@ -83,3 +86,3 @@ }, | ||
}, | ||
"gitHead": "f445a041c413195f29c2e929e28f87c62a80d943" | ||
"gitHead": "26d991afb01cf824827db0c958c50970e038112f" | ||
} |
@@ -78,2 +78,16 @@ /* eslint max-lines: 0 */ | ||
const rewriteModules = pass => ({ types: t }) => { | ||
const replace = ( | ||
src, | ||
node = t.expressionStatement(t.identifier('null')), | ||
) => { | ||
node.loc = src.loc; | ||
node.comments = [...(src.leadingComments || [])]; | ||
t.inheritsComments(node, src); | ||
return node; | ||
}; | ||
const prependReplacements = (replacements, node) => { | ||
replacements.unshift(node); | ||
}; | ||
const allowedHiddens = new WeakSet(); | ||
@@ -243,3 +257,3 @@ const rewrittenDecls = new WeakSet(); | ||
const isConst = decl.kind === 'const'; | ||
const replace = rewriteVars( | ||
const replacements = rewriteVars( | ||
vids, | ||
@@ -252,3 +266,3 @@ isConst, | ||
if (replace.length > 0) { | ||
if (replacements.length > 0) { | ||
switch (decl.type) { | ||
@@ -258,7 +272,7 @@ case 'VariableDeclaration': { | ||
rewrittenDecls.add(decl); | ||
replace.unshift(decl); | ||
prependReplacements(replacements, decl); | ||
break; | ||
} | ||
case 'FunctionDeclaration': { | ||
replace.unshift(decl); | ||
prependReplacements(replacements, decl); | ||
break; | ||
@@ -270,6 +284,4 @@ } | ||
} | ||
path.replaceWithMultiple(replacements); | ||
} | ||
if (replace.length > 0) { | ||
path.replaceWithMultiple(replace); | ||
} | ||
}; | ||
@@ -398,3 +410,3 @@ | ||
path.replaceWithMultiple([ | ||
decl, | ||
replace(path.node, decl), | ||
t.expressionStatement(t.callExpression(callee, [decl.id])), | ||
@@ -407,8 +419,11 @@ ]); | ||
path.replaceWithMultiple([ | ||
t.variableDeclaration('const', [ | ||
t.variableDeclarator( | ||
t.objectPattern([t.objectProperty(id, cid)]), | ||
t.objectExpression([t.objectProperty(id, expr)]), | ||
), | ||
]), | ||
replace( | ||
path.node, | ||
t.variableDeclaration('const', [ | ||
t.variableDeclarator( | ||
t.objectPattern([t.objectProperty(id, cid)]), | ||
t.objectExpression([t.objectProperty(id, expr)]), | ||
), | ||
]), | ||
), | ||
t.expressionStatement(t.callExpression(callee, [cid])), | ||
@@ -577,3 +592,3 @@ ]); | ||
if (doTransform) { | ||
path.replaceWithMultiple(decl ? [decl] : []); | ||
path.replaceWithMultiple(decl ? [replace(path.node, decl)] : []); | ||
} | ||
@@ -580,0 +595,0 @@ }, |
@@ -0,1 +1,5 @@ | ||
import * as recastCJS from '@agoric/recast'; | ||
import traverseCJS from '@babel/traverse'; | ||
import typesCJS from '@babel/types'; | ||
import * as h from './hidden.js'; | ||
@@ -42,2 +46,3 @@ import makeModulePlugins from './babelPlugin.js'; | ||
'classPrivateMethods', | ||
'classPrivateProperties', | ||
// 'v8intrinsic', // we really don't want people to rely on platform powers | ||
@@ -52,25 +57,26 @@ 'partialApplication', | ||
const allowAwaitOutsideFunction = false; | ||
babel.transform(code, { | ||
parserOpts: { | ||
allowAwaitOutsideFunction, | ||
plugins: parserPlugins, | ||
const recast = recastCJS.default || recastCJS; | ||
const ast = recast.parse(code, { | ||
parser: { | ||
parse: source => | ||
babel.transform(source, { | ||
parserOpts: { | ||
allowAwaitOutsideFunction, | ||
tokens: true, | ||
plugins: parserPlugins, | ||
}, | ||
plugins: [analyzePlugin], | ||
ast: true, | ||
code: false, | ||
}).ast, | ||
}, | ||
generatorOpts: { | ||
retainLines: true, | ||
compact: false, | ||
}, | ||
plugins: [analyzePlugin], | ||
ast: false, | ||
code: false, | ||
}); | ||
({ code } = babel.transform(code, { | ||
parserOpts: { | ||
allowAwaitOutsideFunction, | ||
plugins: parserPlugins, | ||
}, | ||
generatorOpts: { | ||
retainLines: true, | ||
compact: false, | ||
}, | ||
plugins: [transformPlugin], | ||
const traverse = traverseCJS.default || traverseCJS; | ||
const types = typesCJS.default || typesCJS; | ||
traverse(ast, transformPlugin({ types }).visitor); | ||
({ code } = recast.print(ast, { | ||
wrapColumn: Infinity, | ||
reuseWhitespace: true, | ||
includeComments: true, | ||
retainLines: true, | ||
})); | ||
@@ -77,0 +83,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
51117
889
4
+ Added@agoric/recast@^0.20.6
+ Added@babel/traverse@^7.10.4
+ Added@babel/types@^7.10.4
+ Added@agoric/recast@0.20.10(transitive)
+ Added@babel/code-frame@7.26.2(transitive)
+ Added@babel/generator@7.26.3(transitive)
+ Added@babel/helper-string-parser@7.25.9(transitive)
+ Added@babel/helper-validator-identifier@7.25.9(transitive)
+ Added@babel/parser@7.26.3(transitive)
+ Added@babel/template@7.25.9(transitive)
+ Added@babel/traverse@7.26.4(transitive)
+ Added@babel/types@7.26.3(transitive)
+ Added@jridgewell/gen-mapping@0.3.8(transitive)
+ Added@jridgewell/resolve-uri@3.1.2(transitive)
+ Added@jridgewell/set-array@1.2.1(transitive)
+ Added@jridgewell/sourcemap-codec@1.5.0(transitive)
+ Added@jridgewell/trace-mapping@0.3.25(transitive)
+ Addeddebug@4.4.0(transitive)
+ Addedesprima@4.0.1(transitive)
+ Addedglobals@11.12.0(transitive)
+ Addedjs-tokens@4.0.0(transitive)
+ Addedjsesc@3.1.0(transitive)
+ Addedms@2.1.3(transitive)
+ Addedpicocolors@1.1.1(transitive)
+ Addedsource-map@0.6.1(transitive)
+ Addedtslib@2.8.1(transitive)