Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@endo/static-module-record

Package Overview
Dependencies
Maintainers
4
Versions
52
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@endo/static-module-record - npm Package Compare versions

Comparing version 0.6.7 to 0.6.8

15

CHANGELOG.md

@@ -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 @@

15

package.json
{
"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"
}

49

src/babelPlugin.js

@@ -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 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc