From c2d70404d81812869bda62a664a69d394aff4608 Mon Sep 17 00:00:00 2001 From: Simon H <5968653+dummdidumm@users.noreply.github.com> Date: Wed, 19 Oct 2022 15:58:11 +0200 Subject: [PATCH] [fix] take into account deep exports for external packages (#7311) Fixes #7216 --- .changeset/fuzzy-walls-teach.md | 5 +++++ packages/adapter-node/index.js | 5 ++++- 2 files changed, 9 insertions(+), 1 deletion(-) create mode 100644 .changeset/fuzzy-walls-teach.md diff --git a/.changeset/fuzzy-walls-teach.md b/.changeset/fuzzy-walls-teach.md new file mode 100644 index 000000000000..4f1bfde077e1 --- /dev/null +++ b/.changeset/fuzzy-walls-teach.md @@ -0,0 +1,5 @@ +--- +'@sveltejs/adapter-node': patch +--- + +[fix] take into account deep exports for external packages diff --git a/packages/adapter-node/index.js b/packages/adapter-node/index.js index e39513692c24..9913432d81ec 100644 --- a/packages/adapter-node/index.js +++ b/packages/adapter-node/index.js @@ -60,7 +60,10 @@ export default function (opts = {}) { index: `${tmp}/index.js`, manifest: `${tmp}/manifest.js` }, - external: [...Object.keys(pkg.dependencies || {})], + external: [ + // dependencies could have deep exports, so we need a regex + ...Object.keys(pkg.dependencies || {}).map((d) => new RegExp(`^${d}(\\/.*)?$`)) + ], plugins: [nodeResolve({ preferBuiltins: true }), commonjs(), json()] });