Skip to content

Commit

Permalink
feat: remove feature flag eszip (#50)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
EwanValentine committed Jun 21, 2022
1 parent 9d51843 commit da6377b
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 16 deletions.
23 changes: 13 additions & 10 deletions src/bundler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ interface BundleOptions {
onBeforeDownload?: LifecycleHook
}

// eslint-disable-next-line max-statements
const bundle = async (
sourceDirectories: string[],
distDirectory: string,
Expand Down Expand Up @@ -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(
Expand All @@ -78,6 +70,17 @@ const bundle = async (
functions,
}),
)
} else {
bundleOps.push(
bundleJS({
buildID,
debug,
deno,
distDirectory,
functions,
importMap,
}),
)
}

const bundles = await Promise.all(bundleOps)
Expand Down
10 changes: 4 additions & 6 deletions test/bundler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [
Expand All @@ -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 })
})
Expand Down

0 comments on commit da6377b

Please sign in to comment.