Skip to content

Commit

Permalink
Add env var to deny dynamic imports (#407)
Browse files Browse the repository at this point in the history
Signed-off-by: Marcos Candeia <marrcooos@gmail.com>
  • Loading branch information
mcandeia authored Feb 16, 2024
1 parent b56175d commit ec3aaab
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion decohub/mod.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ export interface State {
apps: DynamicApp[];
}

const DENY_DYNAMIC_IMPORT = Deno.env.get("DENY_DYNAMIC_IMPORT") === "true";
/**
* @title Deco Hub
*/
Expand All @@ -28,7 +29,7 @@ export default async function App(
): Promise<App<Manifest, State>> {
const resolvedImport = import.meta.resolve("../admin/mod.ts");
const baseImportMap = buildImportMap(manifest);
const appModules = await Promise.all(
const appModules = DENY_DYNAMIC_IMPORT ? [] : await Promise.all(
(state?.apps ?? []).filter(Boolean).map(async (app) => {
const appMod = await import(app.importUrl).catch((err) => {
console.error("error when importing app", app.name, app.importUrl, err);
Expand Down

0 comments on commit ec3aaab

Please sign in to comment.