From e60c6cff5f3fa6b945f86b86b3346f685ee8f3c1 Mon Sep 17 00:00:00 2001 From: Nicola Krumschmidt Date: Thu, 27 Apr 2023 23:20:55 +0200 Subject: [PATCH] Remove extension config import workaround (#18349) * Remove extension config import workaround * Add changeset --------- Co-authored-by: Rijk van Zanten --- .changeset/quiet-eagles-reflect.md | 5 +++++ .../extensions-sdk/src/cli/commands/helpers/load-config.ts | 4 +--- 2 files changed, 6 insertions(+), 3 deletions(-) create mode 100644 .changeset/quiet-eagles-reflect.md diff --git a/.changeset/quiet-eagles-reflect.md b/.changeset/quiet-eagles-reflect.md new file mode 100644 index 0000000000..953a195327 --- /dev/null +++ b/.changeset/quiet-eagles-reflect.md @@ -0,0 +1,5 @@ +--- +'@directus/extensions-sdk': patch +--- + +Removed extension config import workaround that is no longer necessary since we are building to ESM diff --git a/packages/extensions-sdk/src/cli/commands/helpers/load-config.ts b/packages/extensions-sdk/src/cli/commands/helpers/load-config.ts index ba50cbf3ac..52dae16ed6 100644 --- a/packages/extensions-sdk/src/cli/commands/helpers/load-config.ts +++ b/packages/extensions-sdk/src/cli/commands/helpers/load-config.ts @@ -5,8 +5,6 @@ import path from 'path'; import { fileURLToPath } from 'url'; import type { Config } from '../../types.js'; -// This is needed to work around Typescript always transpiling import() to require() for CommonJS targets. -const _import = new Function('url', 'return import(url)'); const __dirname = path.dirname(fileURLToPath(import.meta.url)); export default async function loadConfig(): Promise { @@ -14,7 +12,7 @@ export default async function loadConfig(): Promise { const fileName = `extension.config.${ext}`; if (await fse.pathExists(fileName)) { - const configFile = await _import(pathToRelativeUrl(path.resolve(fileName), __dirname)); + const configFile = await import(pathToRelativeUrl(path.resolve(fileName), __dirname)); return configFile.default; }