Skip to content

Commit

Permalink
refactor(ses): split bundle variable (bundle, version)
Browse files Browse the repository at this point in the history
  • Loading branch information
leotm authored and kriskowal committed Dec 5, 2023
1 parent 949772d commit 8db0dfc
Showing 1 changed file with 12 additions and 10 deletions.
22 changes: 12 additions & 10 deletions packages/ses/scripts/bundle.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,28 +24,30 @@ const main = async () => {
const packageJson = JSON.parse(text);
const version = packageJson.version;

const bundle = `// ses@${version}\n${await makeBundle(
const bundle = await makeBundle(
read,
pathToFileURL(resolve('../index.js', import.meta.url)).toString(),
)}`;
const { code: terse } = await minify(bundle, {
);
const versionedBundle = `// ses@${version}\n${bundle}`;

const { code: terse } = await minify(versionedBundle, {
mangle: false,
keep_classnames: true,
});
assert.string(terse);

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

await fs.promises.mkdir('dist', { recursive: true });
await write('dist/ses.cjs', bundle);
await write('dist/ses.mjs', bundle);
await write('dist/ses.umd.js', bundle);
await write('dist/ses.cjs', versionedBundle);
await write('dist/ses.mjs', versionedBundle);
await write('dist/ses.umd.js', versionedBundle);
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.cjs', versionedBundle);
await write('dist/lockdown.mjs', versionedBundle);
await write('dist/lockdown.umd.js', versionedBundle);
await write('dist/lockdown.umd.min.js', terse);
};

Expand Down

0 comments on commit 8db0dfc

Please sign in to comment.