Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: improve resolveClient for DEV #998

Merged
merged 28 commits into from
Nov 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
a4007bf
fix: improve resolveClient for DEV
dai-shi Nov 11, 2024
b1b54f6
fix for build
dai-shi Nov 11, 2024
7993ba0
a fix
dai-shi Nov 11, 2024
375d6ed
not confident tho
dai-shi Nov 11, 2024
98536ad
Revert "not confident tho"
dai-shi Nov 12, 2024
c83da89
Merge branch 'main' into fix/improve/resolve-client-dev
dai-shi Nov 12, 2024
d182094
wip: experimenting
dai-shi Nov 13, 2024
3b07464
Merge branch 'main' into fix/improve/resolve-client-dev
dai-shi Nov 13, 2024
d3fcfae
resolve waku module in loadServerModuleMain
dai-shi Nov 14, 2024
31bd652
isAtFile
dai-shi Nov 14, 2024
aa589fe
Merge branch 'main' into fix/improve/resolve-client-dev
dai-shi Nov 14, 2024
3296e16
resolve at id
dai-shi Nov 14, 2024
5e79247
hack waku dist
dai-shi Nov 14, 2024
b8421b4
force at fs
dai-shi Nov 14, 2024
f2990e4
Merge branch 'main' into fix/improve/resolve-client-dev
dai-shi Nov 17, 2024
82a0e75
no need for two maps
dai-shi Nov 17, 2024
732c6d9
put back some logic that are needed
dai-shi Nov 17, 2024
3587d77
Merge branch 'main' into fix/improve/resolve-client-dev
dai-shi Nov 17, 2024
623b2eb
Merge branch 'main' into fix/improve/resolve-client-dev
dai-shi Nov 18, 2024
a6a13cf
do not use resolve map for src
dai-shi Nov 18, 2024
0d7ad5e
add failing test for #982
dai-shi Nov 18, 2024
03246b6
fix e2e
dai-shi Nov 18, 2024
844420f
standalone ssr-catch error e2e
dai-shi Nov 18, 2024
4738425
more hacks
dai-shi Nov 18, 2024
9e4634c
Merge branch 'main' into fix/improve/resolve-client-dev
dai-shi Nov 21, 2024
80cd918
@fs hack is no longer necessary
dai-shi Nov 21, 2024
99dc5cf
fix: Windows path (#1008)
himself65 Nov 21, 2024
cf5e19d
remove unused flow
dai-shi Nov 21, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions e2e/fixtures/ssr-catch-error/src/pages/index.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
import { ErrorBoundary } from 'react-error-boundary';
import { Link } from 'waku';

export default async function HomePage() {
return (
<div>
<p>Home Page</p>
<Link to="/invalid">Invalid page</Link>
<ErrorBoundary fallback={<div>Something went wrong</div>}>
Empty children
</ErrorBoundary>
</div>
);
}
Expand Down
22 changes: 22 additions & 0 deletions e2e/fixtures/ssr-catch-error/vite.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
export default ({ mode }: { mode: string }) => {
if (mode === 'development') {
return {
plugins: [
{
name: 'externalize-react-error-boundary',
configResolved(config: any) {
// TODO HACK temporary solution until v0.22.0
if (
config.cacheDir.endsWith(
'node_modules/.vite/waku-dev-server-main',
)
) {
config.ssr.noExternal = ['react-error-boundary'];
}
},
},
],
};
}
return {};
};
3 changes: 2 additions & 1 deletion e2e/fixtures/ssr-catch-error/waku.config.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
/** @type {import('waku/config').Config} */
export default {
middleware: () => [
import('waku/middleware/context'),
import('waku/middleware/dev-server'),
import('./src/middleware/validator.js'),
import('waku/middleware/rsc'),
import('waku/middleware/fallback'),
import('waku/middleware/ssr'),
],
/**
* Base path for HTTP requests to indicate RSC requests.
Expand Down
97 changes: 57 additions & 40 deletions e2e/ssr-catch-error.spec.ts
Original file line number Diff line number Diff line change
@@ -1,69 +1,86 @@
import { expect } from '@playwright/test';

Check failure on line 1 in e2e/ssr-catch-error.spec.ts

View workflow job for this annotation

GitHub Actions / E2E on macos-latest (Node 22.7.0) - (4/4)

Child Process Error

stderr: [plugin:vite:reporter] [plugin vite:reporter] (!) /Users/runner/work/_temp/waku-ssr-catch-error-xsHk7b/node_modules/waku/dist/middleware/context.js is dynamically imported by /Users/runner/work/_temp/waku-ssr-catch-error-xsHk7b/node_modules/waku/dist/lib/config.js, /Users/runner/work/_temp/waku-ssr-catch-error-xsHk7b/waku.config.ts but also statically imported by /Users/runner/work/_temp/waku-ssr-catch-error-xsHk7b/node_modules/waku/dist/server.js, dynamic import will not move module into another chunk.

Check failure on line 1 in e2e/ssr-catch-error.spec.ts

View workflow job for this annotation

GitHub Actions / E2E on macos-latest (Node 22.7.0) - (4/4)

Child Process Error

stderr: [plugin:vite:reporter] [plugin vite:reporter] (!) /Users/runner/work/_temp/waku-ssr-catch-error-uMT6Sx/node_modules/waku/dist/middleware/context.js is dynamically imported by /Users/runner/work/_temp/waku-ssr-catch-error-uMT6Sx/node_modules/waku/dist/lib/config.js, /Users/runner/work/_temp/waku-ssr-catch-error-uMT6Sx/waku.config.ts but also statically imported by /Users/runner/work/_temp/waku-ssr-catch-error-uMT6Sx/node_modules/waku/dist/server.js, dynamic import will not move module into another chunk.

Check failure on line 1 in e2e/ssr-catch-error.spec.ts

View workflow job for this annotation

GitHub Actions / E2E on macos-latest (Node 22.7.0) - (4/4)

Child Process Error

stderr: [plugin:vite:reporter] [plugin vite:reporter] (!) /Users/runner/work/_temp/waku-ssr-catch-error-LKxziG/node_modules/waku/dist/middleware/context.js is dynamically imported by /Users/runner/work/_temp/waku-ssr-catch-error-LKxziG/node_modules/waku/dist/lib/config.js, /Users/runner/work/_temp/waku-ssr-catch-error-LKxziG/waku.config.ts but also statically imported by /Users/runner/work/_temp/waku-ssr-catch-error-LKxziG/node_modules/waku/dist/server.js, dynamic import will not move module into another chunk.

Check failure on line 1 in e2e/ssr-catch-error.spec.ts

View workflow job for this annotation

GitHub Actions / E2E on windows-latest (Node 22.7.0) - (4/4)

Child Process Error

stderr: [plugin:vite:reporter] [plugin vite:reporter] (!) D:/a/_temp/waku-ssr-catch-error-ru6RrG/node_modules/waku/dist/middleware/context.js is dynamically imported by D:/a/_temp/waku-ssr-catch-error-ru6RrG/node_modules/waku/dist/lib/config.js, D:/a/_temp/waku-ssr-catch-error-ru6RrG/waku.config.ts but also statically imported by D:/a/_temp/waku-ssr-catch-error-ru6RrG/node_modules/waku/dist/server.js, dynamic import will not move module into another chunk.

Check failure on line 1 in e2e/ssr-catch-error.spec.ts

View workflow job for this annotation

GitHub Actions / E2E on windows-latest (Node 22.7.0) - (4/4)

Child Process Error

stderr: [plugin:vite:reporter] [plugin vite:reporter] (!) D:/a/_temp/waku-ssr-catch-error-nJrtfF/node_modules/waku/dist/middleware/context.js is dynamically imported by D:/a/_temp/waku-ssr-catch-error-nJrtfF/node_modules/waku/dist/lib/config.js, D:/a/_temp/waku-ssr-catch-error-nJrtfF/waku.config.ts but also statically imported by D:/a/_temp/waku-ssr-catch-error-nJrtfF/node_modules/waku/dist/server.js, dynamic import will not move module into another chunk.

Check failure on line 1 in e2e/ssr-catch-error.spec.ts

View workflow job for this annotation

GitHub Actions / E2E on windows-latest (Node 22.7.0) - (4/4)

Child Process Error

stderr: [plugin:vite:reporter] [plugin vite:reporter] (!) D:/a/_temp/waku-ssr-catch-error-vz55BQ/node_modules/waku/dist/middleware/context.js is dynamically imported by D:/a/_temp/waku-ssr-catch-error-vz55BQ/node_modules/waku/dist/lib/config.js, D:/a/_temp/waku-ssr-catch-error-vz55BQ/waku.config.ts but also statically imported by D:/a/_temp/waku-ssr-catch-error-vz55BQ/node_modules/waku/dist/server.js, dynamic import will not move module into another chunk.

Check failure on line 1 in e2e/ssr-catch-error.spec.ts

View workflow job for this annotation

GitHub Actions / E2E on ubuntu-latest (Node 22.7.0) - (4/4)

Child Process Error

stderr: [plugin:vite:reporter] [plugin vite:reporter] (!) /home/runner/work/_temp/waku-ssr-catch-error-C0eZLG/node_modules/waku/dist/middleware/context.js is dynamically imported by /home/runner/work/_temp/waku-ssr-catch-error-C0eZLG/node_modules/waku/dist/lib/config.js, /home/runner/work/_temp/waku-ssr-catch-error-C0eZLG/waku.config.ts but also statically imported by /home/runner/work/_temp/waku-ssr-catch-error-C0eZLG/node_modules/waku/dist/server.js, dynamic import will not move module into another chunk.

Check failure on line 1 in e2e/ssr-catch-error.spec.ts

View workflow job for this annotation

GitHub Actions / E2E on ubuntu-latest (Node 22.7.0) - (4/4)

Child Process Error

stderr: [plugin:vite:reporter] [plugin vite:reporter] (!) /home/runner/work/_temp/waku-ssr-catch-error-7XWikq/node_modules/waku/dist/middleware/context.js is dynamically imported by /home/runner/work/_temp/waku-ssr-catch-error-7XWikq/node_modules/waku/dist/lib/config.js, /home/runner/work/_temp/waku-ssr-catch-error-7XWikq/waku.config.ts but also statically imported by /home/runner/work/_temp/waku-ssr-catch-error-7XWikq/node_modules/waku/dist/server.js, dynamic import will not move module into another chunk.

Check failure on line 1 in e2e/ssr-catch-error.spec.ts

View workflow job for this annotation

GitHub Actions / E2E on ubuntu-latest (Node 22.7.0) - (4/4)

Child Process Error

stderr: [plugin:vite:reporter] [plugin vite:reporter] (!) /home/runner/work/_temp/waku-ssr-catch-error-iQhmZl/node_modules/waku/dist/middleware/context.js is dynamically imported by /home/runner/work/_temp/waku-ssr-catch-error-iQhmZl/node_modules/waku/dist/lib/config.js, /home/runner/work/_temp/waku-ssr-catch-error-iQhmZl/waku.config.ts but also statically imported by /home/runner/work/_temp/waku-ssr-catch-error-iQhmZl/node_modules/waku/dist/server.js, dynamic import will not move module into another chunk.

Check failure on line 1 in e2e/ssr-catch-error.spec.ts

View workflow job for this annotation

GitHub Actions / E2E on ubuntu-latest (Node 18.17.0) - (4/4)

Child Process Error

stderr: [plugin:vite:reporter] [plugin vite:reporter] (!) /home/runner/work/_temp/waku-ssr-catch-error-JE1l0d/node_modules/waku/dist/middleware/context.js is dynamically imported by /home/runner/work/_temp/waku-ssr-catch-error-JE1l0d/node_modules/waku/dist/lib/config.js, /home/runner/work/_temp/waku-ssr-catch-error-JE1l0d/waku.config.ts but also statically imported by /home/runner/work/_temp/waku-ssr-catch-error-JE1l0d/node_modules/waku/dist/server.js, dynamic import will not move module into another chunk.

Check failure on line 1 in e2e/ssr-catch-error.spec.ts

View workflow job for this annotation

GitHub Actions / E2E on ubuntu-latest (Node 18.17.0) - (4/4)

Child Process Error

stderr: [plugin:vite:reporter] [plugin vite:reporter] (!) /home/runner/work/_temp/waku-ssr-catch-error-SuV2p6/node_modules/waku/dist/middleware/context.js is dynamically imported by /home/runner/work/_temp/waku-ssr-catch-error-SuV2p6/node_modules/waku/dist/lib/config.js, /home/runner/work/_temp/waku-ssr-catch-error-SuV2p6/waku.config.ts but also statically imported by /home/runner/work/_temp/waku-ssr-catch-error-SuV2p6/node_modules/waku/dist/server.js, dynamic import will not move module into another chunk.

Check failure on line 1 in e2e/ssr-catch-error.spec.ts

View workflow job for this annotation

GitHub Actions / E2E on ubuntu-latest (Node 18.17.0) - (4/4)

Child Process Error

stderr: [plugin:vite:reporter] [plugin vite:reporter] (!) /home/runner/work/_temp/waku-ssr-catch-error-DhZLEa/node_modules/waku/dist/middleware/context.js is dynamically imported by /home/runner/work/_temp/waku-ssr-catch-error-DhZLEa/node_modules/waku/dist/lib/config.js, /home/runner/work/_temp/waku-ssr-catch-error-DhZLEa/waku.config.ts but also statically imported by /home/runner/work/_temp/waku-ssr-catch-error-DhZLEa/node_modules/waku/dist/server.js, dynamic import will not move module into another chunk.

Check failure on line 1 in e2e/ssr-catch-error.spec.ts

View workflow job for this annotation

GitHub Actions / E2E on ubuntu-latest (Node 20.8.0) - (4/4)

Child Process Error

stderr: [plugin:vite:reporter] [plugin vite:reporter] (!) /home/runner/work/_temp/waku-ssr-catch-error-knaj8S/node_modules/waku/dist/middleware/context.js is dynamically imported by /home/runner/work/_temp/waku-ssr-catch-error-knaj8S/node_modules/waku/dist/lib/config.js, /home/runner/work/_temp/waku-ssr-catch-error-knaj8S/waku.config.ts but also statically imported by /home/runner/work/_temp/waku-ssr-catch-error-knaj8S/node_modules/waku/dist/server.js, dynamic import will not move module into another chunk.

Check failure on line 1 in e2e/ssr-catch-error.spec.ts

View workflow job for this annotation

GitHub Actions / E2E on ubuntu-latest (Node 20.8.0) - (4/4)

Child Process Error

stderr: [plugin:vite:reporter] [plugin vite:reporter] (!) /home/runner/work/_temp/waku-ssr-catch-error-CVAxNB/node_modules/waku/dist/middleware/context.js is dynamically imported by /home/runner/work/_temp/waku-ssr-catch-error-CVAxNB/node_modules/waku/dist/lib/config.js, /home/runner/work/_temp/waku-ssr-catch-error-CVAxNB/waku.config.ts but also statically imported by /home/runner/work/_temp/waku-ssr-catch-error-CVAxNB/node_modules/waku/dist/server.js, dynamic import will not move module into another chunk.

Check failure on line 1 in e2e/ssr-catch-error.spec.ts

View workflow job for this annotation

GitHub Actions / E2E on ubuntu-latest (Node 20.8.0) - (4/4)

Child Process Error

stderr: [plugin:vite:reporter] [plugin vite:reporter] (!) /home/runner/work/_temp/waku-ssr-catch-error-X80vG1/node_modules/waku/dist/middleware/context.js is dynamically imported by /home/runner/work/_temp/waku-ssr-catch-error-X80vG1/node_modules/waku/dist/lib/config.js, /home/runner/work/_temp/waku-ssr-catch-error-X80vG1/waku.config.ts but also statically imported by /home/runner/work/_temp/waku-ssr-catch-error-X80vG1/node_modules/waku/dist/server.js, dynamic import will not move module into another chunk.

Check failure on line 1 in e2e/ssr-catch-error.spec.ts

View workflow job for this annotation

GitHub Actions / E2E on macos-latest (Node 22.7.0) - (3/4)

Child Process Error

stderr: [plugin:vite:reporter] [plugin vite:reporter] (!) /Users/runner/work/_temp/waku-ssr-catch-error-VVJuD0/node_modules/waku/dist/middleware/context.js is dynamically imported by /Users/runner/work/_temp/waku-ssr-catch-error-VVJuD0/node_modules/waku/dist/lib/config.js, /Users/runner/work/_temp/waku-ssr-catch-error-VVJuD0/waku.config.ts but also statically imported by /Users/runner/work/_temp/waku-ssr-catch-error-VVJuD0/node_modules/waku/dist/server.js, dynamic import will not move module into another chunk.

Check failure on line 1 in e2e/ssr-catch-error.spec.ts

View workflow job for this annotation

GitHub Actions / E2E on macos-latest (Node 22.7.0) - (3/4)

Child Process Error

stderr: [plugin:vite:reporter] [plugin vite:reporter] (!) /Users/runner/work/_temp/waku-ssr-catch-error-fjegQO/node_modules/waku/dist/middleware/context.js is dynamically imported by /Users/runner/work/_temp/waku-ssr-catch-error-fjegQO/node_modules/waku/dist/lib/config.js, /Users/runner/work/_temp/waku-ssr-catch-error-fjegQO/waku.config.ts but also statically imported by /Users/runner/work/_temp/waku-ssr-catch-error-fjegQO/node_modules/waku/dist/server.js, dynamic import will not move module into another chunk.

Check failure on line 1 in e2e/ssr-catch-error.spec.ts

View workflow job for this annotation

GitHub Actions / E2E on macos-latest (Node 22.7.0) - (3/4)

Child Process Error

stderr: [plugin:vite:reporter] [plugin vite:reporter] (!) /Users/runner/work/_temp/waku-ssr-catch-error-zq884s/node_modules/waku/dist/middleware/context.js is dynamically imported by /Users/runner/work/_temp/waku-ssr-catch-error-zq884s/node_modules/waku/dist/lib/config.js, /Users/runner/work/_temp/waku-ssr-catch-error-zq884s/waku.config.ts but also statically imported by /Users/runner/work/_temp/waku-ssr-catch-error-zq884s/node_modules/waku/dist/server.js, dynamic import will not move module into another chunk.

Check failure on line 1 in e2e/ssr-catch-error.spec.ts

View workflow job for this annotation

GitHub Actions / E2E on windows-latest (Node 22.7.0) - (3/4)

Child Process Error

stderr: [plugin:vite:reporter] [plugin vite:reporter] (!) D:/a/_temp/waku-ssr-catch-error-2HSOhk/node_modules/waku/dist/middleware/context.js is dynamically imported by D:/a/_temp/waku-ssr-catch-error-2HSOhk/node_modules/waku/dist/lib/config.js, D:/a/_temp/waku-ssr-catch-error-2HSOhk/waku.config.ts but also statically imported by D:/a/_temp/waku-ssr-catch-error-2HSOhk/node_modules/waku/dist/server.js, dynamic import will not move module into another chunk.

Check failure on line 1 in e2e/ssr-catch-error.spec.ts

View workflow job for this annotation

GitHub Actions / E2E on ubuntu-latest (Node 20.8.0) - (3/4)

Child Process Error

stderr: [plugin:vite:reporter] [plugin vite:reporter] (!) /home/runner/work/_temp/waku-ssr-catch-error-3pkHFQ/node_modules/waku/dist/middleware/context.js is dynamically imported by /home/runner/work/_temp/waku-ssr-catch-error-3pkHFQ/node_modules/waku/dist/lib/config.js, /home/runner/work/_temp/waku-ssr-catch-error-3pkHFQ/waku.config.ts but also statically imported by /home/runner/work/_temp/waku-ssr-catch-error-3pkHFQ/node_modules/waku/dist/server.js, dynamic import will not move module into another chunk.

Check failure on line 1 in e2e/ssr-catch-error.spec.ts

View workflow job for this annotation

GitHub Actions / E2E on windows-latest (Node 22.7.0) - (3/4)

Child Process Error

stderr: [plugin:vite:reporter] [plugin vite:reporter] (!) D:/a/_temp/waku-ssr-catch-error-bBae0h/node_modules/waku/dist/middleware/context.js is dynamically imported by D:/a/_temp/waku-ssr-catch-error-bBae0h/node_modules/waku/dist/lib/config.js, D:/a/_temp/waku-ssr-catch-error-bBae0h/waku.config.ts but also statically imported by D:/a/_temp/waku-ssr-catch-error-bBae0h/node_modules/waku/dist/server.js, dynamic import will not move module into another chunk.

Check failure on line 1 in e2e/ssr-catch-error.spec.ts

View workflow job for this annotation

GitHub Actions / E2E on ubuntu-latest (Node 20.8.0) - (3/4)

Child Process Error

stderr: [plugin:vite:reporter] [plugin vite:reporter] (!) /home/runner/work/_temp/waku-ssr-catch-error-nkF9i3/node_modules/waku/dist/middleware/context.js is dynamically imported by /home/runner/work/_temp/waku-ssr-catch-error-nkF9i3/node_modules/waku/dist/lib/config.js, /home/runner/work/_temp/waku-ssr-catch-error-nkF9i3/waku.config.ts but also statically imported by /home/runner/work/_temp/waku-ssr-catch-error-nkF9i3/node_modules/waku/dist/server.js, dynamic import will not move module into another chunk.

Check failure on line 1 in e2e/ssr-catch-error.spec.ts

View workflow job for this annotation

GitHub Actions / E2E on windows-latest (Node 22.7.0) - (3/4)

Child Process Error

stderr: [plugin:vite:reporter] [plugin vite:reporter] (!) D:/a/_temp/waku-ssr-catch-error-dY2kKU/node_modules/waku/dist/middleware/context.js is dynamically imported by D:/a/_temp/waku-ssr-catch-error-dY2kKU/node_modules/waku/dist/lib/config.js, D:/a/_temp/waku-ssr-catch-error-dY2kKU/waku.config.ts but also statically imported by D:/a/_temp/waku-ssr-catch-error-dY2kKU/node_modules/waku/dist/server.js, dynamic import will not move module into another chunk.

Check failure on line 1 in e2e/ssr-catch-error.spec.ts

View workflow job for this annotation

GitHub Actions / E2E on ubuntu-latest (Node 20.8.0) - (3/4)

Child Process Error

stderr: [plugin:vite:reporter] [plugin vite:reporter] (!) /home/runner/work/_temp/waku-ssr-catch-error-H4J4eA/node_modules/waku/dist/middleware/context.js is dynamically imported by /home/runner/work/_temp/waku-ssr-catch-error-H4J4eA/node_modules/waku/dist/lib/config.js, /home/runner/work/_temp/waku-ssr-catch-error-H4J4eA/waku.config.ts but also statically imported by /home/runner/work/_temp/waku-ssr-catch-error-H4J4eA/node_modules/waku/dist/server.js, dynamic import will not move module into another chunk.

Check failure on line 1 in e2e/ssr-catch-error.spec.ts

View workflow job for this annotation

GitHub Actions / E2E on ubuntu-latest (Node 18.17.0) - (3/4)

Child Process Error

stderr: [plugin:vite:reporter] [plugin vite:reporter] (!) /home/runner/work/_temp/waku-ssr-catch-error-MjaBtZ/node_modules/waku/dist/middleware/context.js is dynamically imported by /home/runner/work/_temp/waku-ssr-catch-error-MjaBtZ/node_modules/waku/dist/lib/config.js, /home/runner/work/_temp/waku-ssr-catch-error-MjaBtZ/waku.config.ts but also statically imported by /home/runner/work/_temp/waku-ssr-catch-error-MjaBtZ/node_modules/waku/dist/server.js, dynamic import will not move module into another chunk.

Check failure on line 1 in e2e/ssr-catch-error.spec.ts

View workflow job for this annotation

GitHub Actions / E2E on ubuntu-latest (Node 18.17.0) - (3/4)

Child Process Error

stderr: [plugin:vite:reporter] [plugin vite:reporter] (!) /home/runner/work/_temp/waku-ssr-catch-error-okg6JY/node_modules/waku/dist/middleware/context.js is dynamically imported by /home/runner/work/_temp/waku-ssr-catch-error-okg6JY/node_modules/waku/dist/lib/config.js, /home/runner/work/_temp/waku-ssr-catch-error-okg6JY/waku.config.ts but also statically imported by /home/runner/work/_temp/waku-ssr-catch-error-okg6JY/node_modules/waku/dist/server.js, dynamic import will not move module into another chunk.

Check failure on line 1 in e2e/ssr-catch-error.spec.ts

View workflow job for this annotation

GitHub Actions / E2E on ubuntu-latest (Node 18.17.0) - (3/4)

Child Process Error

stderr: [plugin:vite:reporter] [plugin vite:reporter] (!) /home/runner/work/_temp/waku-ssr-catch-error-blF72L/node_modules/waku/dist/middleware/context.js is dynamically imported by /home/runner/work/_temp/waku-ssr-catch-error-blF72L/node_modules/waku/dist/lib/config.js, /home/runner/work/_temp/waku-ssr-catch-error-blF72L/waku.config.ts but also statically imported by /home/runner/work/_temp/waku-ssr-catch-error-blF72L/node_modules/waku/dist/server.js, dynamic import will not move module into another chunk.

Check failure on line 1 in e2e/ssr-catch-error.spec.ts

View workflow job for this annotation

GitHub Actions / E2E on ubuntu-latest (Node 22.7.0) - (3/4)

Child Process Error

stderr: [plugin:vite:reporter] [plugin vite:reporter] (!) /home/runner/work/_temp/waku-ssr-catch-error-0jwZDZ/node_modules/waku/dist/middleware/context.js is dynamically imported by /home/runner/work/_temp/waku-ssr-catch-error-0jwZDZ/node_modules/waku/dist/lib/config.js, /home/runner/work/_temp/waku-ssr-catch-error-0jwZDZ/waku.config.ts but also statically imported by /home/runner/work/_temp/waku-ssr-catch-error-0jwZDZ/node_modules/waku/dist/server.js, dynamic import will not move module into another chunk.

Check failure on line 1 in e2e/ssr-catch-error.spec.ts

View workflow job for this annotation

GitHub Actions / E2E on ubuntu-latest (Node 22.7.0) - (3/4)

Child Process Error

stderr: [plugin:vite:reporter] [plugin vite:reporter] (!) /home/runner/work/_temp/waku-ssr-catch-error-EaiflK/node_modules/waku/dist/middleware/context.js is dynamically imported by /home/runner/work/_temp/waku-ssr-catch-error-EaiflK/node_modules/waku/dist/lib/config.js, /home/runner/work/_temp/waku-ssr-catch-error-EaiflK/waku.config.ts but also statically imported by /home/runner/work/_temp/waku-ssr-catch-error-EaiflK/node_modules/waku/dist/server.js, dynamic import will not move module into another chunk.

Check failure on line 1 in e2e/ssr-catch-error.spec.ts

View workflow job for this annotation

GitHub Actions / E2E on ubuntu-latest (Node 22.7.0) - (3/4)

Child Process Error

stderr: [plugin:vite:reporter] [plugin vite:reporter] (!) /home/runner/work/_temp/waku-ssr-catch-error-Zw9T9J/node_modules/waku/dist/middleware/context.js is dynamically imported by /home/runner/work/_temp/waku-ssr-catch-error-Zw9T9J/node_modules/waku/dist/lib/config.js, /home/runner/work/_temp/waku-ssr-catch-error-Zw9T9J/waku.config.ts but also statically imported by /home/runner/work/_temp/waku-ssr-catch-error-Zw9T9J/node_modules/waku/dist/server.js, dynamic import will not move module into another chunk.

Check failure on line 1 in e2e/ssr-catch-error.spec.ts

View workflow job for this annotation

GitHub Actions / E2E on macos-latest (Node 22.7.0) - (2/4)

Child Process Error

stderr: [plugin:vite:reporter] [plugin vite:reporter] (!) /Users/runner/work/_temp/waku-ssr-catch-error-9UfSeZ/node_modules/waku/dist/middleware/context.js is dynamically imported by /Users/runner/work/_temp/waku-ssr-catch-error-9UfSeZ/node_modules/waku/dist/lib/config.js, /Users/runner/work/_temp/waku-ssr-catch-error-9UfSeZ/waku.config.ts but also statically imported by /Users/runner/work/_temp/waku-ssr-catch-error-9UfSeZ/node_modules/waku/dist/server.js, dynamic import will not move module into another chunk.

Check failure on line 1 in e2e/ssr-catch-error.spec.ts

View workflow job for this annotation

GitHub Actions / E2E on macos-latest (Node 22.7.0) - (2/4)

Child Process Error

stderr: [plugin:vite:reporter] [plugin vite:reporter] (!) /Users/runner/work/_temp/waku-ssr-catch-error-e1x6ti/node_modules/waku/dist/middleware/context.js is dynamically imported by /Users/runner/work/_temp/waku-ssr-catch-error-e1x6ti/node_modules/waku/dist/lib/config.js, /Users/runner/work/_temp/waku-ssr-catch-error-e1x6ti/waku.config.ts but also statically imported by /Users/runner/work/_temp/waku-ssr-catch-error-e1x6ti/node_modules/waku/dist/server.js, dynamic import will not move module into another chunk.

Check failure on line 1 in e2e/ssr-catch-error.spec.ts

View workflow job for this annotation

GitHub Actions / E2E on ubuntu-latest (Node 22.7.0) - (2/4)

Child Process Error

stderr: [plugin:vite:reporter] [plugin vite:reporter] (!) /home/runner/work/_temp/waku-ssr-catch-error-EMorMZ/node_modules/waku/dist/middleware/context.js is dynamically imported by /home/runner/work/_temp/waku-ssr-catch-error-EMorMZ/node_modules/waku/dist/lib/config.js, /home/runner/work/_temp/waku-ssr-catch-error-EMorMZ/waku.config.ts but also statically imported by /home/runner/work/_temp/waku-ssr-catch-error-EMorMZ/node_modules/waku/dist/server.js, dynamic import will not move module into another chunk.

Check failure on line 1 in e2e/ssr-catch-error.spec.ts

View workflow job for this annotation

GitHub Actions / E2E on ubuntu-latest (Node 22.7.0) - (2/4)

Child Process Error

stderr: [plugin:vite:reporter] [plugin vite:reporter] (!) /home/runner/work/_temp/waku-ssr-catch-error-M7Rk7J/node_modules/waku/dist/middleware/context.js is dynamically imported by /home/runner/work/_temp/waku-ssr-catch-error-M7Rk7J/node_modules/waku/dist/lib/config.js, /home/runner/work/_temp/waku-ssr-catch-error-M7Rk7J/waku.config.ts but also statically imported by /home/runner/work/_temp/waku-ssr-catch-error-M7Rk7J/node_modules/waku/dist/server.js, dynamic import will not move module into another chunk.

Check failure on line 1 in e2e/ssr-catch-error.spec.ts

View workflow job for this annotation

GitHub Actions / E2E on ubuntu-latest (Node 20.8.0) - (2/4)

Child Process Error

stderr: [plugin:vite:reporter] [plugin vite:reporter] (!) /home/runner/work/_temp/waku-ssr-catch-error-4AC0qp/node_modules/waku/dist/middleware/context.js is dynamically imported by /home/runner/work/_temp/waku-ssr-catch-error-4AC0qp/node_modules/waku/dist/lib/config.js, /home/runner/work/_temp/waku-ssr-catch-error-4AC0qp/waku.config.ts but also statically imported by /home/runner/work/_temp/waku-ssr-catch-error-4AC0qp/node_modules/waku/dist/server.js, dynamic import will not move module into another chunk.

Check failure on line 1 in e2e/ssr-catch-error.spec.ts

View workflow job for this annotation

GitHub Actions / E2E on windows-latest (Node 22.7.0) - (1/4)

Child Process Error

stderr: [plugin:vite:reporter] [plugin vite:reporter] (!) D:/a/_temp/waku-ssr-catch-error-o0M9ue/node_modules/waku/dist/middleware/context.js is dynamically imported by D:/a/_temp/waku-ssr-catch-error-o0M9ue/node_modules/waku/dist/lib/config.js, D:/a/_temp/waku-ssr-catch-error-o0M9ue/waku.config.ts but also statically imported by D:/a/_temp/waku-ssr-catch-error-o0M9ue/node_modules/waku/dist/server.js, dynamic import will not move module into another chunk.

Check failure on line 1 in e2e/ssr-catch-error.spec.ts

View workflow job for this annotation

GitHub Actions / E2E on ubuntu-latest (Node 20.8.0) - (2/4)

Child Process Error

stderr: [plugin:vite:reporter] [plugin vite:reporter] (!) /home/runner/work/_temp/waku-ssr-catch-error-UoBWbU/node_modules/waku/dist/middleware/context.js is dynamically imported by /home/runner/work/_temp/waku-ssr-catch-error-UoBWbU/node_modules/waku/dist/lib/config.js, /home/runner/work/_temp/waku-ssr-catch-error-UoBWbU/waku.config.ts but also statically imported by /home/runner/work/_temp/waku-ssr-catch-error-UoBWbU/node_modules/waku/dist/server.js, dynamic import will not move module into another chunk.

Check failure on line 1 in e2e/ssr-catch-error.spec.ts

View workflow job for this annotation

GitHub Actions / E2E on ubuntu-latest (Node 18.17.0) - (2/4)

Child Process Error

stderr: [plugin:vite:reporter] [plugin vite:reporter] (!) /home/runner/work/_temp/waku-ssr-catch-error-BJerMd/node_modules/waku/dist/middleware/context.js is dynamically imported by /home/runner/work/_temp/waku-ssr-catch-error-BJerMd/node_modules/waku/dist/lib/config.js, /home/runner/work/_temp/waku-ssr-catch-error-BJerMd/waku.config.ts but also statically imported by /home/runner/work/_temp/waku-ssr-catch-error-BJerMd/node_modules/waku/dist/server.js, dynamic import will not move module into another chunk.

Check failure on line 1 in e2e/ssr-catch-error.spec.ts

View workflow job for this annotation

GitHub Actions / E2E on ubuntu-latest (Node 18.17.0) - (2/4)

Child Process Error

stderr: [plugin:vite:reporter] [plugin vite:reporter] (!) /home/runner/work/_temp/waku-ssr-catch-error-1I7i7T/node_modules/waku/dist/middleware/context.js is dynamically imported by /home/runner/work/_temp/waku-ssr-catch-error-1I7i7T/node_modules/waku/dist/lib/config.js, /home/runner/work/_temp/waku-ssr-catch-error-1I7i7T/waku.config.ts but also statically imported by /home/runner/work/_temp/waku-ssr-catch-error-1I7i7T/node_modules/waku/dist/server.js, dynamic import will not move module into another chunk.

Check failure on line 1 in e2e/ssr-catch-error.spec.ts

View workflow job for this annotation

GitHub Actions / E2E on macos-latest (Node 22.7.0) - (1/4)

Child Process Error

stderr: [plugin:vite:reporter] [plugin vite:reporter] (!) /Users/runner/work/_temp/waku-ssr-catch-error-GQUHVr/node_modules/waku/dist/middleware/context.js is dynamically imported by /Users/runner/work/_temp/waku-ssr-catch-error-GQUHVr/node_modules/waku/dist/lib/config.js, /Users/runner/work/_temp/waku-ssr-catch-error-GQUHVr/waku.config.ts but also statically imported by /Users/runner/work/_temp/waku-ssr-catch-error-GQUHVr/node_modules/waku/dist/server.js, dynamic import will not move module into another chunk.

Check failure on line 1 in e2e/ssr-catch-error.spec.ts

View workflow job for this annotation

GitHub Actions / E2E on ubuntu-latest (Node 18.17.0) - (1/4)

Child Process Error

stderr: [plugin:vite:reporter] [plugin vite:reporter] (!) /home/runner/work/_temp/waku-ssr-catch-error-SvWKKN/node_modules/waku/dist/middleware/context.js is dynamically imported by /home/runner/work/_temp/waku-ssr-catch-error-SvWKKN/node_modules/waku/dist/lib/config.js, /home/runner/work/_temp/waku-ssr-catch-error-SvWKKN/waku.config.ts but also statically imported by /home/runner/work/_temp/waku-ssr-catch-error-SvWKKN/node_modules/waku/dist/server.js, dynamic import will not move module into another chunk.

Check failure on line 1 in e2e/ssr-catch-error.spec.ts

View workflow job for this annotation

GitHub Actions / E2E on ubuntu-latest (Node 22.7.0) - (1/4)

Child Process Error

stderr: [plugin:vite:reporter] [plugin vite:reporter] (!) /home/runner/work/_temp/waku-ssr-catch-error-Aw8Dho/node_modules/waku/dist/middleware/context.js is dynamically imported by /home/runner/work/_temp/waku-ssr-catch-error-Aw8Dho/node_modules/waku/dist/lib/config.js, /home/runner/work/_temp/waku-ssr-catch-error-Aw8Dho/waku.config.ts but also statically imported by /home/runner/work/_temp/waku-ssr-catch-error-Aw8Dho/node_modules/waku/dist/server.js, dynamic import will not move module into another chunk.

Check failure on line 1 in e2e/ssr-catch-error.spec.ts

View workflow job for this annotation

GitHub Actions / E2E on ubuntu-latest (Node 20.8.0) - (1/4)

Child Process Error

stderr: [plugin:vite:reporter] [plugin vite:reporter] (!) /home/runner/work/_temp/waku-ssr-catch-error-nilRmJ/node_modules/waku/dist/middleware/context.js is dynamically imported by /home/runner/work/_temp/waku-ssr-catch-error-nilRmJ/node_modules/waku/dist/lib/config.js, /home/runner/work/_temp/waku-ssr-catch-error-nilRmJ/waku.config.ts but also statically imported by /home/runner/work/_temp/waku-ssr-catch-error-nilRmJ/node_modules/waku/dist/server.js, dynamic import will not move module into another chunk.

Check failure on line 1 in e2e/ssr-catch-error.spec.ts

View workflow job for this annotation

GitHub Actions / E2E on windows-latest (Node 22.7.0) - (2/4)

Child Process Error

stderr: [plugin:vite:reporter] [plugin vite:reporter] (!) D:/a/_temp/waku-ssr-catch-error-Q4WVvb/node_modules/waku/dist/middleware/context.js is dynamically imported by D:/a/_temp/waku-ssr-catch-error-Q4WVvb/node_modules/waku/dist/lib/config.js, D:/a/_temp/waku-ssr-catch-error-Q4WVvb/waku.config.ts but also statically imported by D:/a/_temp/waku-ssr-catch-error-Q4WVvb/node_modules/waku/dist/server.js, dynamic import will not move module into another chunk.

Check failure on line 1 in e2e/ssr-catch-error.spec.ts

View workflow job for this annotation

GitHub Actions / E2E on windows-latest (Node 22.7.0) - (2/4)

Child Process Error

stderr: [plugin:vite:reporter] [plugin vite:reporter] (!) D:/a/_temp/waku-ssr-catch-error-BnxaxP/node_modules/waku/dist/middleware/context.js is dynamically imported by D:/a/_temp/waku-ssr-catch-error-BnxaxP/node_modules/waku/dist/lib/config.js, D:/a/_temp/waku-ssr-catch-error-BnxaxP/waku.config.ts but also statically imported by D:/a/_temp/waku-ssr-catch-error-BnxaxP/node_modules/waku/dist/server.js, dynamic import will not move module into another chunk.
import { execSync, exec, ChildProcess } from 'node:child_process';
import { execSync, exec } from 'node:child_process';
import { fileURLToPath } from 'node:url';
import { cp, mkdtemp } from 'node:fs/promises';
import { join } from 'node:path';
import { tmpdir } from 'node:os';
import { createRequire } from 'node:module';
import waitPort from 'wait-port';
import { debugChildProcess, getFreePort, terminate, test } from './utils.js';
import { rm } from 'node:fs/promises';

const waku = fileURLToPath(
new URL('../packages/waku/dist/cli.js', import.meta.url),
);

const commands = [
{
command: 'dev',
},
{
build: 'build',
command: 'start',
},
];
import { debugChildProcess, getFreePort, terminate, test } from './utils.js';

const cwd = fileURLToPath(
let standaloneDir: string;
const fixtureDir = fileURLToPath(
new URL('./fixtures/ssr-catch-error', import.meta.url),
);
const wakuDir = fileURLToPath(new URL('../packages/waku', import.meta.url));
const { version } = createRequire(import.meta.url)(
join(wakuDir, 'package.json'),
);

async function run(isDev: boolean) {
const port = await getFreePort();
const cp = isDev
? exec(
`node ${join(standaloneDir, './node_modules/waku/dist/cli.js')} dev --port ${port}`,
{ cwd: standaloneDir },
)
: exec(
`node ${join(standaloneDir, './node_modules/waku/dist/cli.js')} build && node ${join(standaloneDir, './node_modules/waku/dist/cli.js')} start --port ${port}`,
{ cwd: standaloneDir },
);
debugChildProcess(cp, fileURLToPath(import.meta.url), [
/ExperimentalWarning: Custom ESM Loaders is an experimental feature and might change at any time/,
]);
await waitPort({ port });
return [port, cp.pid];
}

for (const { build, command } of commands) {
test.describe(`ssr-catch-error: ${command}`, () => {
let cp: ChildProcess;
let port: number;
test.beforeAll('remove cache', async () => {
await rm(`${cwd}/dist`, {
for (const isDev of [true, false]) {
test.describe(`ssr-catch-error: ${isDev ? 'DEV' : 'PRD'}`, () => {
test.beforeEach(async () => {
// GitHub Action on Windows doesn't support mkdtemp on global temp dir,
// Which will cause files in `src` folder to be empty.
// I don't know why
const tmpDir = process.env.TEMP_DIR ? process.env.TEMP_DIR : tmpdir();
standaloneDir = await mkdtemp(join(tmpDir, 'waku-ssr-catch-error-'));
await cp(fixtureDir, standaloneDir, {
filter: (src) => {
return !src.includes('node_modules') && !src.includes('dist');
},
recursive: true,
force: true,
});
});

test.beforeAll(async () => {
if (build) {
execSync(`node ${waku} ${build}`, { cwd });
}
port = await getFreePort();
cp = exec(`node ${waku} ${command} --port ${port}`, { cwd });
debugChildProcess(cp, fileURLToPath(import.meta.url), [
/ExperimentalWarning: Custom ESM Loaders is an experimental feature and might change at any time/,
]);
await waitPort({ port });
});

test.afterAll(async () => {
await terminate(cp.pid!);
execSync(`pnpm pack --pack-destination ${standaloneDir}`, {
cwd: wakuDir,
stdio: 'inherit',
});
const name = `waku-${version}.tgz`;
execSync(`npm install --force ${join(standaloneDir, name)}`, {
cwd: standaloneDir,
stdio: 'inherit',
});
});

test('access top page', async ({ page }) => {
const [port, pid] = await run(isDev);
await page.goto(`http://localhost:${port}/`);
await expect(page.getByText('Home Page')).toBeVisible();
await terminate(pid!);
});

test('access invalid page through client router', async ({ page }) => {
const [port, pid] = await run(isDev);
await page.goto(`http://localhost:${port}/`);
await page.getByText('Invalid page').click();
await expect(page.getByText('401')).toBeVisible();
await terminate(pid!);
});

test('access invalid page directly', async ({ page }) => {
const [port, pid] = await run(isDev);
await page.goto(`http://localhost:${port}/invalid`);
await expect(page.getByText('Unauthorized')).toBeVisible();
await terminate(pid!);
});
});
}
36 changes: 24 additions & 12 deletions packages/waku/src/lib/middleware/dev-server-impl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@ import { SRC_MAIN, SRC_ENTRIES } from '../constants.js';
import {
joinPath,
fileURLToFilePath,
encodeFilePathToAbsolute,
decodeFilePathFromAbsolute,
filePathToFileURL,
} from '../utils/path.js';
import { patchReactRefresh } from '../plugins/patch-react-refresh.js';
Expand Down Expand Up @@ -133,21 +131,29 @@ const createMainViteServer = (
return vite;
});

const wakuDist = joinPath(fileURLToFilePath(import.meta.url), '../../..');

const loadServerModuleMain = async (idOrFileURL: string) => {
const vite = await vitePromise;
if (idOrFileURL === 'waku' || idOrFileURL.startsWith('waku/')) {
let file = idOrFileURL.startsWith('file://')
? fileURLToFilePath(idOrFileURL)
: idOrFileURL;
if (file.startsWith(wakuDist)) {
file = 'waku' + file.slice(wakuDist.length).replace(/\.\w+$/, '');
}
if (file === 'waku' || file.startsWith('waku/')) {
// HACK `external: ['waku']` doesn't do the same
return import(/* @vite-ignore */ idOrFileURL);
}
const vite = await vitePromise;
if (
idOrFileURL.startsWith('file://') &&
idOrFileURL.includes('/node_modules/')
) {
// HACK node_modules should be externalized
const file = fileURLToFilePath(idOrFileURL);
const fileWithAbsolutePath = file.startsWith('/')
? file
: joinPath(vite.config.root, file);
const filePath = fileURLToFilePath(idOrFileURL.split('?')[0]!);
const fileWithAbsolutePath = filePath.startsWith('/')
? filePath
: joinPath(vite.config.root, filePath);
return import(/* @vite-ignore */ filePathToFileURL(fileWithAbsolutePath));
}
return vite.ssrLoadModule(
Expand Down Expand Up @@ -286,18 +292,24 @@ const createRscViteServer = (
config: { rootDir: string; basePath: string },
initialModules: ClonableModuleNode[],
) => {
let file = id.startsWith('file://')
? decodeFilePathFromAbsolute(fileURLToFilePath(id))
: id;
let file = id;
const isAtFsFile = file.startsWith('/@fs/');
if (isAtFsFile) {
file = file.slice('/@fs'.length);
}
for (const moduleNode of initialModules) {
if (moduleNode.file === file) {
return moduleNode.url;
}
}
if (file.startsWith(config.rootDir)) {
file = file.slice(config.rootDir.length + 1); // '+ 1' to remove '/'
} else if (isAtFsFile) {
file = '@fs' + file;
} else if (file.startsWith('/')) {
file = file.slice(1);
} else {
file = '@fs' + encodeFilePathToAbsolute(file);
file = '@id/' + file;
}
return config.basePath + file;
};
Expand Down
Loading
Loading