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.15 to 0.7.0

13

CHANGELOG.md

@@ -6,2 +6,15 @@ # Change Log

## [0.7.0](https://github.com/endojs/endo/compare/@endo/static-module-record@0.6.15...@endo/static-module-record@0.7.0) (2022-03-07)
### ⚠ BREAKING CHANGES
* **static-module-record:** remove dependencies on `@babel/standalone`
### Bug Fixes
* **static-module-record:** remove dependencies on `@babel/standalone` ([1a1d1a4](https://github.com/endojs/endo/commit/1a1d1a4f5a7094f32d3e1edfc620e64065771efa))
### [0.6.15](https://github.com/endojs/endo/compare/@endo/static-module-record@0.6.14...@endo/static-module-record@0.6.15) (2022-03-02)

@@ -8,0 +21,0 @@

15

package.json
{
"name": "@endo/static-module-record",
"version": "0.6.15",
"version": "0.7.0",
"description": "Shim for the SES StaticModuleRecord and module-to-program transformer",

@@ -38,9 +38,12 @@ "keywords": [

"dependencies": {
"@agoric/babel-standalone": "^7.14.3",
"ses": "^0.15.10"
"@agoric/babel-generator": "^7.17.6",
"@babel/parser": "^7.17.3",
"@babel/traverse": "^7.17.3",
"@babel/types": "^7.17.0",
"ses": "^0.15.11"
},
"devDependencies": {
"@ava/babel": "^1.0.1",
"@endo/eslint-config": "^0.4.5",
"@endo/ses-ava": "^0.2.20",
"@endo/eslint-config": "^0.4.6",
"@endo/ses-ava": "^0.2.21",
"ava": "^3.12.1",

@@ -83,3 +86,3 @@ "babel-eslint": "^10.0.3",

},
"gitHead": "08973d4fc6358a58d733251b051b2812bb4c651a"
"gitHead": "9ddd58b4a26755cdba9403b0cb042b2067c69832"
}

4

src/static-module-record.js
/* eslint no-underscore-dangle: ["off"] */
// import babel from '@agoric/babel-standalone';
import * as babelStar from '@agoric/babel-standalone';
import { makeModuleAnalyzer } from './transform-analyze.js';

@@ -33,3 +31,3 @@

const analyzeModule = makeModuleAnalyzer(babelStar.default || babelStar);
const analyzeModule = makeModuleAnalyzer();

@@ -36,0 +34,0 @@ /**

@@ -0,1 +1,6 @@

import * as babelParser from '@babel/parser';
import babelGenerate from '@agoric/babel-generator';
import babelTraverse from '@babel/traverse';
import babelTypes from '@babel/types';
import * as h from './hidden.js';

@@ -6,78 +11,39 @@ import makeModulePlugins from './babelPlugin.js';

export const getParserPlugins = sourceType => {
// Transform the script/expression source for import expressions.
const parserPlugins = [];
if (sourceType === 'module') {
parserPlugins.push(
'exportDefaultFrom',
'exportNamespaceFrom',
'importMeta',
const parseBabel = babelParser.default
? babelParser.default.parse
: babelParser.parse || babelParser;
const visitorFromPlugin = plugin => plugin({ types: babelTypes }).visitor;
const traverseBabel = babelTraverse.default || babelTraverse;
const generateBabel = babelGenerate.default || babelGenerate;
const makeTransformSource = (babel = null) => {
if (babel !== null) {
throw new Error(
`transform-analyze.js no longer allows injecting babel; use \`null\``,
);
}
// This list taken and amended from:
// https://github.com/prettier/prettier/tree/master/src/language-js/parser-babylon.js#L21
parserPlugins.push(
'eventualSend',
'doExpressions',
'objectRestSpread',
'classProperties',
// 'exportDefaultFrom', // only for modules, above
// 'exportNamespaceFrom', // only for modules, above
'asyncGenerators',
'functionBind',
'functionSent',
'dynamicImport', // needed for our rewrite
'numericSeparator',
// 'importMeta', // only for modules, above
'optionalCatchBinding',
'optionalChaining',
'classPrivateProperties',
['pipelineOperator', { proposal: 'minimal' }],
'nullishCoalescingOperator',
'bigInt',
'throwExpressions',
'logicalAssignment',
'classPrivateMethods',
'classPrivateProperties',
// 'v8intrinsic', // we really don't want people to rely on platform powers
'partialApplication',
['decorators', { decoratorsBeforeExport: false }],
);
return parserPlugins;
};
const transformSource = (code, sourceOptions = {}) => {
// console.log(`transforming`, sourceOptions, code);
const { analyzePlugin, transformPlugin } = makeModulePlugins(sourceOptions);
const makeTransformSource = babel =>
function transformSource(code, sourceOptions = {}) {
const parserPlugins = getParserPlugins(sourceOptions.sourceType);
const ast = parseBabel(code, { sourceType: sourceOptions.sourceType });
// console.log(`transforming`, sourceOptions, code);
const { analyzePlugin, transformPlugin } = makeModulePlugins(sourceOptions);
// TODO top-level-await https://github.com/endojs/endo/issues/306
const allowAwaitOutsideFunction = false;
babel.transform(code, {
parserOpts: {
allowAwaitOutsideFunction,
plugins: parserPlugins,
},
plugins: [analyzePlugin],
ast: false,
code: false,
traverseBabel(ast, visitorFromPlugin(analyzePlugin));
traverseBabel(ast, visitorFromPlugin(transformPlugin));
const { code: transformedCode } = generateBabel(ast, {
retainLines: true,
compact: true,
verbatim: true,
});
const { code: transformedCode } = babel.transform(code, {
parserOpts: {
allowAwaitOutsideFunction,
plugins: parserPlugins,
},
generatorOpts: {
retainLines: true,
compact: true,
},
plugins: [transformPlugin],
});
// console.log(`transformed to`, output.code);
// console.log(`transformed`, transformedCode);
return transformedCode;
};
return transformSource;
};
const makeCreateStaticRecord = transformSource =>

@@ -84,0 +50,0 @@ function createStaticRecord(moduleSource, url) {

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