From 8db0dfce92922108ad4db3eabb95ccc90496f157 Mon Sep 17 00:00:00 2001 From: LeoTM <1881059+leotm@users.noreply.github.com> Date: Mon, 20 Nov 2023 16:09:02 +0000 Subject: [PATCH] refactor(ses): split bundle variable (bundle, version) Resolve: https://github.com/endojs/endo/pull/1854#discussion_r1388392602 --- packages/ses/scripts/bundle.js | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/packages/ses/scripts/bundle.js b/packages/ses/scripts/bundle.js index c19519eb8e..dc061cb304 100644 --- a/packages/ses/scripts/bundle.js +++ b/packages/ses/scripts/bundle.js @@ -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); };