From c114621af63ecebea610576a4930029bb2a9fdcf Mon Sep 17 00:00:00 2001 From: Jacob Ebey Date: Tue, 15 Aug 2023 10:34:32 -0700 Subject: [PATCH] chore: preserve dynamic import for remix-serve (#7173) --- .changeset/v2-serve-dynamic-import.md | 5 +++++ packages/remix-serve/rollup.config.js | 11 +++++++++++ 2 files changed, 16 insertions(+) create mode 100644 .changeset/v2-serve-dynamic-import.md diff --git a/.changeset/v2-serve-dynamic-import.md b/.changeset/v2-serve-dynamic-import.md new file mode 100644 index 00000000000..f3cd5159f11 --- /dev/null +++ b/.changeset/v2-serve-dynamic-import.md @@ -0,0 +1,5 @@ +--- +"@remix-run/serve": major +--- + +Preserve dynamic imports in remix-serve for external bundle diff --git a/packages/remix-serve/rollup.config.js b/packages/remix-serve/rollup.config.js index 59886138ce2..5ed2ee66468 100644 --- a/packages/remix-serve/rollup.config.js +++ b/packages/remix-serve/rollup.config.js @@ -38,6 +38,17 @@ module.exports = function rollup() { extensions: [".ts", ".tsx"], }), nodeResolve({ extensions: [".ts", ".tsx"] }), + // Allow dynamic imports in CJS code to allow us to utilize + // ESM modules as part of the compiler. + { + name: "dynamic-import-polyfill", + renderDynamicImport() { + return { + left: "import(", + right: ")", + }; + }, + }, copy({ targets: [ { src: "LICENSE.md", dest: [outputDir, sourceDir] },