diff --git a/.changeset/eight-hats-worry.md b/.changeset/eight-hats-worry.md new file mode 100644 index 000000000000..db436be21124 --- /dev/null +++ b/.changeset/eight-hats-worry.md @@ -0,0 +1,5 @@ +--- +'@sveltejs/adapter-node': patch +--- + +[fix] regression where builds not using `entryPoint` stopped having `middlewares.js` external diff --git a/packages/adapter-node/index.js b/packages/adapter-node/index.js index ef4dfce45cf1..d651385f6ca0 100644 --- a/packages/adapter-node/index.js +++ b/packages/adapter-node/index.js @@ -90,8 +90,11 @@ export default function ({ name: 'fix-middlewares-exclude', setup(build) { // Match an import of "middlewares.js" and mark it as external + const internal_middlewares_path = resolve('.svelte-kit/node/middlewares.js'); + const build_middlewares_path = resolve(out, 'middlewares.js'); build.onResolve({ filter: /\/middlewares\.js$/ }, ({ path, resolveDir }) => { - if (resolve(resolveDir, path) === resolve(out, 'middlewares.js')) { + const resolved = resolve(resolveDir, path); + if (resolved === internal_middlewares_path || resolved === build_middlewares_path) { return { path: './middlewares.js', external: true }; } });