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

@agoric/bundle-source

Package Overview
Dependencies
Maintainers
5
Versions
224
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@agoric/bundle-source - npm Package Compare versions

Comparing version 1.1.4 to 1.1.5

12

CHANGELOG.md

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

## [1.1.5](https://github.com/Agoric/agoric-sdk/compare/@agoric/bundle-source@1.1.4...@agoric/bundle-source@1.1.5) (2020-05-17)
### Bug Fixes
* make output from bundleSource correspond to source map lines ([c1ddd4a](https://github.com/Agoric/agoric-sdk/commit/c1ddd4a0a27de9561b3bd827213562d9741e61a8))
* remove many build steps ([6c7d3bb](https://github.com/Agoric/agoric-sdk/commit/6c7d3bb0c70277c22f8eda40525d7240141a5434))
## [1.1.4](https://github.com/Agoric/agoric-sdk/compare/@agoric/bundle-source@1.1.3...@agoric/bundle-source@1.1.4) (2020-05-10)

@@ -8,0 +20,0 @@

14

package.json
{
"name": "@agoric/bundle-source",
"version": "1.1.4",
"version": "1.1.5",
"description": "Create source bundles from ES Modules",

@@ -20,5 +20,8 @@ "main": "src/index.js",

"dependencies": {
"@agoric/acorn-eventual-send": "^2.0.4",
"@agoric/evaluate": "^2.2.5",
"@agoric/acorn-eventual-send": "^2.0.5",
"@agoric/babel-parser": "^7.6.4",
"@agoric/evaluate": "^2.2.6",
"@agoric/harden": "^0.0.8",
"@agoric/transform-eventual-send": "^1.3.0",
"@babel/generator": "^7.6.4",
"@rollup/plugin-commonjs": "^11.0.2",

@@ -28,3 +31,4 @@ "@rollup/plugin-node-resolve": "^7.1.1",

"esm": "^3.2.5",
"rollup": "^1.32.0"
"rollup": "^1.32.0",
"source-map": "^0.7.3"
},

@@ -48,3 +52,3 @@ "keywords": [],

},
"gitHead": "41e9cd4b0475b0b0cc461e9c54c5dbec82994e3c"
"gitHead": "4cbbf2146ff4b47eaffd1bdf22f3fde8f184cc38"
}

@@ -5,5 +5,8 @@ import { rollup as rollup0 } from 'rollup';

import commonjs0 from '@rollup/plugin-commonjs';
import eventualSend from '@agoric/acorn-eventual-send';
import * as acorn from 'acorn';
import * as babelParser from '@agoric/babel-parser';
import babelGenerate from '@babel/generator';
import { makeTransform } from '@agoric/transform-eventual-send';
import { SourceMapConsumer } from 'source-map';
const DEFAULT_MODULE_FORMAT = 'nestedEvaluate';

@@ -17,2 +20,14 @@ const DEFAULT_FILE_PREFIX = '/bundled-source';

export function tildotPlugin() {
const transformer = makeTransform(babelParser, babelGenerate);
return {
transform(code, _id) {
return {
code: transformer(code),
map: null,
};
},
};
}
export default async function bundleSource(

@@ -39,4 +54,7 @@ startFilename,

external: ['@agoric/evaluate', '@agoric/harden', ...externals],
plugins: [resolvePlugin({ preferBuiltins: true }), commonjsPlugin()],
acornInjectPlugins: [eventualSend(acorn)],
plugins: [
resolvePlugin({ preferBuiltins: true }),
tildotPlugin(),
commonjsPlugin(),
],
});

@@ -61,7 +79,42 @@ const { output } = await bundle.generate({

}
let unmappedCode = code;
if (
moduleFormat === 'nestedEvaluate' &&
!fileName.startsWith('_virtual/')
) {
unmappedCode = '';
// eslint-disable-next-line no-await-in-loop
const consumer = await new SourceMapConsumer(chunk.map);
const genLines = code.split('\n');
let lastLine = 1;
for (let genLine = 0; genLine < genLines.length; genLine += 1) {
const pos = consumer.originalPositionFor({
line: genLine + 1,
column: 0,
});
const { line: origLine } = pos;
const srcLine = origLine === null ? lastLine : origLine;
const priorChar = unmappedCode[unmappedCode.length - 1];
if (
srcLine === lastLine &&
!['\n', ';', '{', undefined].includes(priorChar) &&
!['}'].includes(genLines[genLine][0])
) {
unmappedCode += `;`;
}
while (lastLine < srcLine) {
unmappedCode += `\n`;
lastLine += 1;
}
unmappedCode += genLines[genLine];
}
}
// Rewrite apparent import expressions so that they don't fail under SES.
// We also do apparent HTML comments.
const defangedCode = code
const defangedCode = unmappedCode
.replace(IMPORT_RE, '$1notreally')
.replace(HTML_COMMENT_RE, '<->');
// console.log(`<<<<<< ${fileName}\n${defangedCode}\n>>>>>>>>`);
sourceBundle[fileName] = defangedCode;

@@ -198,3 +251,3 @@ }

// log('evaluating', typeof nestedEvaluate, code);
// log('evaluating', code);
return nestedEvaluate(code)(contextRequire);

@@ -220,3 +273,3 @@ }

// Evaluate the entrypoint recursively.
return computeExports(entrypoint, { require, log(...args) { return console.log(...args); } });
return computeExports(entrypoint, { require });
}

@@ -223,0 +276,0 @@ ${sourceMap}`;

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