Skip to content

Commit

Permalink
feat(ses): Replace Rollup with Endo bundler
Browse files Browse the repository at this point in the history
  • Loading branch information
kriskowal committed May 10, 2021
1 parent 59190cc commit 291a688
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 40 deletions.
6 changes: 4 additions & 2 deletions packages/ses/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,14 +48,15 @@
"test": "yarn build && yarn ava",
"qt": "yarn ava",
"test:platform-compatability": "node test/package/test.cjs",
"build": "rollup --config rollup.config.js && (cd dist; cp ses.cjs lockdown.cjs; cp ses.mjs lockdown.mjs; cp ses.umd.js lockdown.umd.js; cp ses.umd.min.js lockdown.umd.min.js)",
"build": "mkdir -p dist && node scripts/bundle.js",
"demo": "http-server -o /demos"
},
"dependencies": {
"@agoric/make-hardener": "^0.1.2"
},
"devDependencies": {
"@agoric/babel-standalone": "^7.9.5",
"@agoric/compartment-mapper": "^0.2.4",
"@agoric/eslint-config": "^0.1.0",
"@agoric/test262-runner": "~0.1.0",
"@endo/static-module-record": "^0.1.0",
Expand All @@ -66,7 +67,8 @@
"http-server": "^0.12.1",
"prettier": "^1.19.1",
"rollup-plugin-terser": "^5.1.3",
"sinon": "8.0.4"
"sinon": "8.0.4",
"terser": "^4.8.0"
},
"ava": {
"files": [
Expand Down
38 changes: 0 additions & 38 deletions packages/ses/rollup.config.js

This file was deleted.

33 changes: 33 additions & 0 deletions packages/ses/scripts/bundle.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import 'ses';
import fs from 'fs';
import { makeBundle } from '@agoric/compartment-mapper';
import prettier from 'prettier';
import terser from 'terser';

const resolve = (rel, abs) => new URL(rel, abs).toString();
const root = resolve('..', import.meta.url);

const read = async location => fs.promises.readFile(new URL(location).pathname);
const write = async (target, content) => {
const location = resolve(target, root);
await fs.promises.writeFile(new URL(location).pathname, content);
}

(async () => {
const bundle = await makeBundle(read, resolve('../index.js', import.meta.url));
const pretty = prettier.format(bundle);
const { code: terse } = terser.minify(bundle);

console.log(`Bundle size: ${pretty.length} bytes`);
console.log(`Minified bundle size: ${terse.length} bytes`);

await write('dist/ses.cjs', pretty);
await write('dist/ses.mjs', pretty);
await write('dist/ses.umd.js', pretty);
await write('dist/ses.umd.min.js', terse);

await write('dist/lockdown.cjs', pretty);
await write('dist/lockdown.mjs', pretty);
await write('dist/lockdown.umd.js', pretty);
await write('dist/lockdown.umd.min.js', terse);
})();

0 comments on commit 291a688

Please sign in to comment.