From 52d6266e1360982302c2a280c4ee4033291e43c6 Mon Sep 17 00:00:00 2001 From: mikana0918 Date: Mon, 18 Nov 2024 13:11:27 +0900 Subject: [PATCH 1/2] refactor: Update config.common.mjs to support ESM format and add compatibility banner --- backend-api/scripts/config.common.mjs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/backend-api/scripts/config.common.mjs b/backend-api/scripts/config.common.mjs index 25c7cd6..7da0482 100644 --- a/backend-api/scripts/config.common.mjs +++ b/backend-api/scripts/config.common.mjs @@ -10,6 +10,11 @@ export default { outdir: path.resolve(dirname, '../'), platform: 'node', target: 'node20', + format: 'esm', + banner: { + // commonjs用ライブラリをESMプロジェクトでbundleする際に生じることのある問題への対策 + js: 'import { createRequire } from "module"; import url from "url"; const require = createRequire(import.meta.url); const __filename = url.fileURLToPath(import.meta.url); const __dirname = url.fileURLToPath(new URL(".", import.meta.url));', + }, bundle: true, plugins: [nodeExternalsPlugin()], logLevel: 'info', From 3bae6d5e0f58d2bcb66f7d340e4501ab8c83d632 Mon Sep 17 00:00:00 2001 From: mikana0918 Date: Mon, 18 Nov 2024 13:12:27 +0900 Subject: [PATCH 2/2] refactor: Update target in config.common.mjs to node22 for improved compatibility --- backend-api/scripts/config.common.mjs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/backend-api/scripts/config.common.mjs b/backend-api/scripts/config.common.mjs index 7da0482..836b1f5 100644 --- a/backend-api/scripts/config.common.mjs +++ b/backend-api/scripts/config.common.mjs @@ -9,7 +9,7 @@ export default { entryPoints: [path.resolve(dirname, '../entrypoints/index.ts')], outdir: path.resolve(dirname, '../'), platform: 'node', - target: 'node20', + target: 'node22', format: 'esm', banner: { // commonjs用ライブラリをESMプロジェクトでbundleする際に生じることのある問題への対策