-
Notifications
You must be signed in to change notification settings - Fork 71
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
refactor(ses): Replace Rollup with Endo bundle #715
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import '../index.js'; | ||
import fs from 'fs'; | ||
import { makeBundle } from '@agoric/compartment-mapper'; | ||
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 { code: terse } = terser.minify(bundle, { | ||
mangle: false, | ||
keep_classnames: true, | ||
}); | ||
|
||
console.log(`Bundle size: ${bundle.length} bytes`); | ||
console.log(`Minified bundle size: ${terse.length} bytes`); | ||
|
||
await write('dist/ses.cjs', bundle); | ||
await write('dist/ses.mjs', bundle); | ||
await write('dist/ses.umd.js', bundle); | ||
await write('dist/ses.umd.min.js', terse); | ||
|
||
await write('dist/lockdown.cjs', bundle); | ||
await write('dist/lockdown.mjs', bundle); | ||
await write('dist/lockdown.umd.js', bundle); | ||
await write('dist/lockdown.umd.min.js', terse); | ||
Comment on lines
+28
to
+36
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The fact that there are only two, but with eight names, is amusing. No change suggested. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. True. This is the effect of architectural drift in this case. Before I changed the SES shim to effect its API strictly using globals, there was a difference between the CJS, MJS, and UMD treatments. Rollup continued to emphasize the difference in its configuration options, but the difference amounted to nothing except a vestigial |
||
})(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should adopt some convention that we can check, for making sources of static authority stand out in our source files. Just noting. No change suggested at this time. Attn @dckc
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should also be a script that we run with Endo instead of Node, and it should be counted a design goal for Endo to accommodate injection of an attenuated FS and a decent DX for granting that capability to the script. For example, there might be some reasonable default filesystem attenuation for any Endo script run in the context of developer tools for a package, or at least a convenient piece of boilerplate we can add to package.json to grant that limited authority.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"DX"?