From c35dbaa7c4c5998ec0febef112f7c3c3b715ff5a Mon Sep 17 00:00:00 2001 From: Hiroki Osame Date: Sat, 8 Jun 2024 12:04:03 +0900 Subject: [PATCH] chore: add note about esm cjs interop optimization --- src/esm/hook/load.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/esm/hook/load.ts b/src/esm/hook/load.ts index 81f51df66..374c46170 100644 --- a/src/esm/hook/load.ts +++ b/src/esm/hook/load.ts @@ -84,7 +84,11 @@ export const load: LoadHook = async ( * from the data: URL. * * This should pre-compile for the CJS loader to have a cache hit - * TODO: extract exports only? + * + * I considered extracting the CJS exports from esbuild via (0&&(module.exports={}) + * to minimize the data URL size but this only works for ESM->CJS and not CTS files + * which are already in CJS syntax. + * In CTS, module.exports can be written in any pattern. */ const transformed = transformSync( code,