@endo/static-module-record
Advanced tools
Comparing version 0.6.12 to 0.6.13
@@ -6,2 +6,18 @@ # Change Log | ||
### [0.6.13](https://github.com/endojs/endo/compare/@endo/static-module-record@0.6.12...@endo/static-module-record@0.6.13) (2022-02-18) | ||
### Bug Fixes | ||
* Make jsconfigs less brittle ([861ca32](https://github.com/endojs/endo/commit/861ca32a72f0a48410fd93b1cbaaad9139590659)) | ||
* Make sure lint:type runs correctly in CI ([a520419](https://github.com/endojs/endo/commit/a52041931e72cb7b7e3e21dde39c099cc9f262b0)) | ||
* Unify TS version to ~4.2 ([5fb173c](https://github.com/endojs/endo/commit/5fb173c05c9427dca5adfe66298c004780e8b86c)) | ||
### Reverts | ||
* Revert "Revert "fix(static-module-record): minimise source changes with `recast`"" ([ce53158](https://github.com/endojs/endo/commit/ce5315849ffcb71794f3264871b371eb5ae6d00c)) | ||
### [0.6.12](https://github.com/endojs/endo/compare/@endo/static-module-record@0.6.11...@endo/static-module-record@0.6.12) (2022-01-31) | ||
@@ -8,0 +24,0 @@ |
{ | ||
"name": "@endo/static-module-record", | ||
"version": "0.6.12", | ||
"version": "0.6.13", | ||
"description": "Shim for the SES StaticModuleRecord and module-to-program transformer", | ||
@@ -32,3 +32,3 @@ "keywords": [ | ||
"lint": "yarn lint:types && yarn lint:js", | ||
"lint:types": "tsc --build jsconfig.json", | ||
"lint:types": "tsc -p jsconfig.json", | ||
"lint:js": "eslint .", | ||
@@ -40,8 +40,11 @@ "lint-fix": "eslint --fix .", | ||
"@agoric/babel-standalone": "^7.14.3", | ||
"ses": "^0.15.7" | ||
"@babel/traverse": "^7.10.4", | ||
"@babel/types": "^7.10.4", | ||
"recast": "agoric-labs/recast#Agoric-built", | ||
"ses": "^0.15.8" | ||
}, | ||
"devDependencies": { | ||
"@ava/babel": "^1.0.1", | ||
"@endo/eslint-config": "^0.4.2", | ||
"@endo/ses-ava": "^0.2.17", | ||
"@endo/eslint-config": "^0.4.3", | ||
"@endo/ses-ava": "^0.2.18", | ||
"ava": "^3.12.1", | ||
@@ -57,3 +60,3 @@ "babel-eslint": "^10.0.3", | ||
"prettier": "^1.19.1", | ||
"typescript": "^4.2.3" | ||
"typescript": "~4.5.5" | ||
}, | ||
@@ -85,3 +88,3 @@ "files": [ | ||
}, | ||
"gitHead": "96df4cf238b245cc92c78e4af4667f405b8cf4f0" | ||
"gitHead": "9d2f88ab47f546bc59b6b6e7340482209b3cee56" | ||
} |
@@ -41,18 +41,2 @@ /* 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) { | ||
@@ -95,2 +79,16 @@ 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(); | ||
@@ -260,3 +258,3 @@ const rewrittenDecls = new WeakSet(); | ||
const isConst = decl.kind === 'const'; | ||
const replace = rewriteVars( | ||
const replacements = rewriteVars( | ||
vids, | ||
@@ -269,3 +267,3 @@ isConst, | ||
if (replace.length > 0) { | ||
if (replacements.length > 0) { | ||
switch (decl.type) { | ||
@@ -275,7 +273,7 @@ case 'VariableDeclaration': { | ||
rewrittenDecls.add(decl); | ||
prependReplacements(replace, decl); | ||
prependReplacements(replacements, decl); | ||
break; | ||
} | ||
case 'FunctionDeclaration': { | ||
prependReplacements(replace, decl); | ||
prependReplacements(replacements, decl); | ||
break; | ||
@@ -287,6 +285,4 @@ } | ||
} | ||
path.replaceWithMultiple(replacements); | ||
} | ||
if (replace.length > 0) { | ||
path.replaceWithMultiple(replace); | ||
} | ||
}; | ||
@@ -415,3 +411,3 @@ | ||
path.replaceWithMultiple([ | ||
displayAsExport(decl), | ||
replace(path.node, decl), | ||
t.expressionStatement(t.callExpression(callee, [decl.id])), | ||
@@ -424,3 +420,4 @@ ]); | ||
path.replaceWithMultiple([ | ||
displayAsExport( | ||
replace( | ||
path.node, | ||
t.variableDeclaration('const', [ | ||
@@ -596,3 +593,3 @@ t.variableDeclarator( | ||
if (doTransform) { | ||
path.replaceWithMultiple(decl ? [displayAsExport(decl)] : []); | ||
path.replaceWithMultiple(decl ? [replace(path.node, decl)] : []); | ||
} | ||
@@ -599,0 +596,0 @@ }, |
@@ -0,1 +1,5 @@ | ||
import * as recastCJS from '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
GitHub dependency
Supply chain riskContains a dependency which resolves to a GitHub URL. Dependencies fetched from GitHub specifiers are not immutable can be used to inject untrusted code or reduce the likelihood of a reproducible install.
Found 1 instance in 1 package
Manifest confusion
Supply chain riskThis package has inconsistent metadata. This could be malicious or caused by an error when publishing the package.
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
57235
894
5
1
1
+ Added@babel/traverse@^7.10.4
+ Added@babel/types@^7.10.4
+ 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)
+ 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)
Updatedses@^0.15.8