From da6377bd6b2ed57215c64f185526e8b881522b1b Mon Sep 17 00:00:00 2001 From: Ewan Valentine Date: Tue, 21 Jun 2022 12:10:05 +0100 Subject: [PATCH] feat: remove feature flag eszip (#50) * chore: remove eszip feature flag * chore: remove eszip feature flag * chore: fixed tests * chore: refactored to reduce statement limit * chore: disable max line limit eslint rule --- src/bundler.ts | 23 +++++++++++++---------- test/bundler.ts | 10 ++++------ 2 files changed, 17 insertions(+), 16 deletions(-) diff --git a/src/bundler.ts b/src/bundler.ts index 27a2895c..4c096bcc 100644 --- a/src/bundler.ts +++ b/src/bundler.ts @@ -24,6 +24,7 @@ interface BundleOptions { onBeforeDownload?: LifecycleHook } +// eslint-disable-next-line max-statements const bundle = async ( sourceDirectories: string[], distDirectory: string, @@ -56,16 +57,7 @@ const bundle = async ( // if any. const importMap = new ImportMap(importMaps) const functions = await findFunctions(sourceDirectories) - const bundleOps = [ - bundleJS({ - buildID, - debug, - deno, - distDirectory, - functions, - importMap, - }), - ] + const bundleOps = [] if (featureFlags.edge_functions_produce_eszip) { bundleOps.push( @@ -78,6 +70,17 @@ const bundle = async ( functions, }), ) + } else { + bundleOps.push( + bundleJS({ + buildID, + debug, + deno, + distDirectory, + functions, + importMap, + }), + ) } const bundles = await Promise.all(bundleOps) diff --git a/test/bundler.ts b/test/bundler.ts index d92a9708..9445ce9e 100644 --- a/test/bundler.ts +++ b/test/bundler.ts @@ -38,7 +38,7 @@ test('Produces a JavaScript bundle and a manifest file', async (t) => { await fs.rmdir(tmpDir.path, { recursive: true }) }) -test('Produces an additional ESZIP bundle when the `edge_functions_produce_eszip` feature flag is set', async (t) => { +test('Produces only a ESZIP bundle when the `edge_functions_produce_eszip` feature flag is set', async (t) => { const sourceDirectory = resolve(dirname, '..', 'fixtures', 'project_1', 'functions') const tmpDir = await tmp.dir() const declarations = [ @@ -55,18 +55,16 @@ test('Produces an additional ESZIP bundle when the `edge_functions_produce_eszip const generatedFiles = await fs.readdir(tmpDir.path) t.is(result.functions.length, 1) - t.is(generatedFiles.length, 3) + t.is(generatedFiles.length, 2) // eslint-disable-next-line unicorn/prefer-json-parse-buffer const manifestFile = await fs.readFile(resolve(tmpDir.path, 'manifest.json'), 'utf8') const manifest = JSON.parse(manifestFile) const { bundles } = manifest - t.is(bundles.length, 2) - t.is(bundles[0].format, 'js') + t.is(bundles.length, 1) + t.is(bundles[0].format, 'eszip2') t.true(generatedFiles.includes(bundles[0].asset)) - t.is(bundles[1].format, 'eszip2') - t.true(generatedFiles.includes(bundles[1].asset)) await fs.rmdir(tmpDir.path, { recursive: true }) })