Skip to content

Commit

Permalink
[fix] externalize middlewares.js when not using entryPoint (#2484)
Browse files Browse the repository at this point in the history
  • Loading branch information
Conduitry authored Sep 24, 2021
1 parent ea0e6e9 commit 84e0dec
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changeset/eight-hats-worry.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@sveltejs/adapter-node': patch
---

[fix] regression where builds not using `entryPoint` stopped having `middlewares.js` external
5 changes: 4 additions & 1 deletion packages/adapter-node/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 };
}
});
Expand Down

0 comments on commit 84e0dec

Please sign in to comment.