From e14203bd408d1f143c1102865ff802344f111557 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Eduardo=20Bou=C3=A7as?= Date: Tue, 13 Dec 2022 10:21:34 +0000 Subject: [PATCH] feat: read Deno config behind feature flag --- node/bundler.test.ts | 3 +++ node/bundler.ts | 16 +++++++++------- node/feature_flags.ts | 1 + 3 files changed, 13 insertions(+), 7 deletions(-) diff --git a/node/bundler.test.ts b/node/bundler.test.ts index 44664052..bb91e09c 100644 --- a/node/bundler.test.ts +++ b/node/bundler.test.ts @@ -27,6 +27,9 @@ test('Produces an ESZIP bundle', async () => { const result = await bundle([userDirectory, internalDirectory], distPath, declarations, { basePath, configPath: join(internalDirectory, 'config.json'), + featureFlags: { + edge_functions_read_deno_config: true, + }, }) const generatedFiles = await fs.readdir(distPath) diff --git a/node/bundler.ts b/node/bundler.ts index 9be6839c..f13d76fe 100644 --- a/node/bundler.ts +++ b/node/bundler.ts @@ -85,15 +85,17 @@ const bundle = async ( importMap.add(deployConfig.importMap) } - // Look for a Deno config file and read it if one exists. - const denoConfig = await getDenoConfig(basePath) + if (featureFlags.edge_functions_read_deno_config) { + // Look for a Deno config file and read it if one exists. + const denoConfig = await getDenoConfig(basePath) - // If the Deno config file defines an import map, read the file and add the - // imports to the global import map. - if (denoConfig?.importMap) { - const importMapFile = await readImportMapFile(denoConfig.importMap) + // If the Deno config file defines an import map, read the file and add the + // imports to the global import map. + if (denoConfig?.importMap) { + const importMapFile = await readImportMapFile(denoConfig.importMap) - importMap.add(importMapFile) + importMap.add(importMapFile) + } } const functions = await findFunctions(sourceDirectories) diff --git a/node/feature_flags.ts b/node/feature_flags.ts index 84531ff5..fdf670e9 100644 --- a/node/feature_flags.ts +++ b/node/feature_flags.ts @@ -1,6 +1,7 @@ const defaultFlags: Record = { edge_functions_cache_deno_dir: false, edge_functions_config_export: false, + edge_functions_read_deno_config: false, } type FeatureFlag = keyof typeof defaultFlags