Skip to content

Commit

Permalink
feat: read Deno config behind feature flag (#258)
Browse files Browse the repository at this point in the history
  • Loading branch information
eduardoboucas committed Dec 13, 2022
1 parent 436e10e commit 5dc562a
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 7 deletions.
3 changes: 3 additions & 0 deletions node/bundler.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
16 changes: 9 additions & 7 deletions node/bundler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
1 change: 1 addition & 0 deletions node/feature_flags.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
const defaultFlags: Record<string, boolean> = {
edge_functions_cache_deno_dir: false,
edge_functions_config_export: false,
edge_functions_read_deno_config: false,
}

type FeatureFlag = keyof typeof defaultFlags
Expand Down

0 comments on commit 5dc562a

Please sign in to comment.