Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: read Deno config behind feature flag #258

Merged
merged 1 commit into from
Dec 13, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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