@endo/static-module-record
Advanced tools
Comparing version 0.6.7 to 0.6.8
@@ -6,2 +6,17 @@ # Change Log | ||
### [0.6.8](https://github.com/endojs/endo/compare/@endo/static-module-record@0.6.7...@endo/static-module-record@0.6.8) (2021-12-14) | ||
### Bug Fixes | ||
* **static-module-record:** Account for unlocated nodes in displayAsExport ([d8770d1](https://github.com/endojs/endo/commit/d8770d1dceacd6298ed0b228b9552fc6cf8ba07b)) | ||
### Reverts | ||
* Revert "build(deps): add a patched version of `recast`" ([1d800ef](https://github.com/endojs/endo/commit/1d800ef6bba28b575bb38f44c9e8f85de7246997)) | ||
* Revert "fix(static-module-record): minimise source changes with `recast`" ([9c76633](https://github.com/endojs/endo/commit/9c7663388576ab93d9f4a3b7fb55d3e20c4e9b45)) | ||
### [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) | ||
@@ -8,0 +23,0 @@ |
{ | ||
"name": "@endo/static-module-record", | ||
"version": "0.6.7", | ||
"version": "0.6.8", | ||
"description": "Shim for the SES StaticModuleRecord and module-to-program transformer", | ||
@@ -38,11 +38,8 @@ "keywords": [ | ||
"dependencies": { | ||
"@agoric/babel-standalone": "^7.14.3", | ||
"@agoric/recast": "^0.20.6", | ||
"@babel/traverse": "^7.10.4", | ||
"@babel/types": "^7.10.4" | ||
"@agoric/babel-standalone": "^7.14.3" | ||
}, | ||
"devDependencies": { | ||
"@ava/babel": "^1.0.1", | ||
"@endo/eslint-config": "^0.3.19", | ||
"@endo/ses-ava": "^0.2.12", | ||
"@endo/eslint-config": "^0.3.20", | ||
"@endo/ses-ava": "^0.2.13", | ||
"ava": "^3.12.1", | ||
@@ -58,3 +55,3 @@ "babel-eslint": "^10.0.3", | ||
"prettier": "^1.19.1", | ||
"ses": "^0.15.2", | ||
"ses": "^0.15.3", | ||
"typescript": "^4.0.5" | ||
@@ -86,3 +83,3 @@ }, | ||
}, | ||
"gitHead": "26d991afb01cf824827db0c958c50970e038112f" | ||
"gitHead": "8e55edd7840870ec8a78016e1871f056e20145fb" | ||
} |
@@ -41,2 +41,18 @@ /* eslint max-lines: 0 */ | ||
const prependReplacements = (replacements, node) => { | ||
const lastReplace = replacements[replacements.length - 1]; | ||
if (lastReplace) { | ||
lastReplace.trailingComments = node.trailingComments; | ||
node.trailingComments = undefined; | ||
} | ||
replacements.unshift(node); | ||
}; | ||
const displayAsExport = node => { | ||
if (node.loc) { | ||
node.loc.prependText = '/*EX*/ '; | ||
} | ||
return node; | ||
}; | ||
function makeModulePlugins(options) { | ||
@@ -79,16 +95,2 @@ const { | ||
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(); | ||
@@ -258,3 +260,3 @@ const rewrittenDecls = new WeakSet(); | ||
const isConst = decl.kind === 'const'; | ||
const replacements = rewriteVars( | ||
const replace = rewriteVars( | ||
vids, | ||
@@ -267,3 +269,3 @@ isConst, | ||
if (replacements.length > 0) { | ||
if (replace.length > 0) { | ||
switch (decl.type) { | ||
@@ -273,7 +275,7 @@ case 'VariableDeclaration': { | ||
rewrittenDecls.add(decl); | ||
prependReplacements(replacements, decl); | ||
prependReplacements(replace, decl); | ||
break; | ||
} | ||
case 'FunctionDeclaration': { | ||
prependReplacements(replacements, decl); | ||
prependReplacements(replace, decl); | ||
break; | ||
@@ -285,4 +287,6 @@ } | ||
} | ||
path.replaceWithMultiple(replacements); | ||
} | ||
if (replace.length > 0) { | ||
path.replaceWithMultiple(replace); | ||
} | ||
}; | ||
@@ -411,3 +415,3 @@ | ||
path.replaceWithMultiple([ | ||
replace(path.node, decl), | ||
displayAsExport(decl), | ||
t.expressionStatement(t.callExpression(callee, [decl.id])), | ||
@@ -420,4 +424,3 @@ ]); | ||
path.replaceWithMultiple([ | ||
replace( | ||
path.node, | ||
displayAsExport( | ||
t.variableDeclaration('const', [ | ||
@@ -593,3 +596,3 @@ t.variableDeclarator( | ||
if (doTransform) { | ||
path.replaceWithMultiple(decl ? [replace(path.node, decl)] : []); | ||
path.replaceWithMultiple(decl ? [displayAsExport(decl)] : []); | ||
} | ||
@@ -596,0 +599,0 @@ }, |
@@ -1,5 +0,1 @@ | ||
import * as recastCJS from '@agoric/recast'; | ||
import traverseCJS from '@babel/traverse'; | ||
import typesCJS from '@babel/types'; | ||
import * as h from './hidden.js'; | ||
@@ -46,3 +42,2 @@ import makeModulePlugins from './babelPlugin.js'; | ||
'classPrivateMethods', | ||
'classPrivateProperties', | ||
// 'v8intrinsic', // we really don't want people to rely on platform powers | ||
@@ -57,26 +52,25 @@ 'partialApplication', | ||
const allowAwaitOutsideFunction = false; | ||
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, | ||
babel.transform(code, { | ||
parserOpts: { | ||
allowAwaitOutsideFunction, | ||
plugins: parserPlugins, | ||
}, | ||
generatorOpts: { | ||
retainLines: true, | ||
compact: false, | ||
}, | ||
plugins: [analyzePlugin], | ||
ast: false, | ||
code: false, | ||
}); | ||
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, | ||
({ code } = babel.transform(code, { | ||
parserOpts: { | ||
allowAwaitOutsideFunction, | ||
plugins: parserPlugins, | ||
}, | ||
generatorOpts: { | ||
retainLines: true, | ||
compact: false, | ||
}, | ||
plugins: [transformPlugin], | ||
})); | ||
@@ -83,0 +77,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
51338
1
887
- Removed@agoric/recast@^0.20.6
- Removed@babel/traverse@^7.10.4
- Removed@babel/types@^7.10.4
- Removed@agoric/recast@0.20.10(transitive)
- Removed@babel/code-frame@7.26.2(transitive)
- Removed@babel/generator@7.26.3(transitive)
- Removed@babel/helper-string-parser@7.25.9(transitive)
- Removed@babel/helper-validator-identifier@7.25.9(transitive)
- Removed@babel/parser@7.26.3(transitive)
- Removed@babel/template@7.25.9(transitive)
- Removed@babel/traverse@7.26.4(transitive)
- Removed@babel/types@7.26.3(transitive)
- Removed@jridgewell/gen-mapping@0.3.8(transitive)
- Removed@jridgewell/resolve-uri@3.1.2(transitive)
- Removed@jridgewell/set-array@1.2.1(transitive)
- Removed@jridgewell/sourcemap-codec@1.5.0(transitive)
- Removed@jridgewell/trace-mapping@0.3.25(transitive)
- Removeddebug@4.4.0(transitive)
- Removedesprima@4.0.1(transitive)
- Removedglobals@11.12.0(transitive)
- Removedjs-tokens@4.0.0(transitive)
- Removedjsesc@3.1.0(transitive)
- Removedms@2.1.3(transitive)
- Removedpicocolors@1.1.1(transitive)
- Removedsource-map@0.6.1(transitive)
- Removedtslib@2.8.1(transitive)