Skip to content

Commit 09df51a

Browse files
authored
fix(dev): module resolution in monorepo setup (#1143)
- [x] add failing test - [x] fix it
1 parent dd38d08 commit 09df51a

File tree

7 files changed

+31
-0
lines changed

7 files changed

+31
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"name": "dummy-library",
3+
"type": "module",
4+
"version": "0.0.0",
5+
"description": "Dummy package for testing",
6+
"exports": {
7+
"./entry-point": {
8+
"types": "./src/index.d.ts",
9+
"import": "./src/index.js"
10+
}
11+
},
12+
"private": true
13+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
'use client';
2+
3+
export function Hello() {
4+
return 'hello';
5+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export declare function Hello(): string;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
// Do not add '.js' extension to reproduce the issue
2+
// https://github.com/dai-shi/waku/pull/1143
3+
export * from './client';

e2e/fixtures/monorepo/packages/waku-project/package.json

+1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
"start": "waku start"
1010
},
1111
"dependencies": {
12+
"dummy-library": "0.0.0",
1213
"react": "19.0.0",
1314
"react-dom": "19.0.0",
1415
"react-server-dom-webpack": "19.0.0"

e2e/fixtures/monorepo/packages/waku-project/src/pages/index.tsx

+4
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
import { Link } from 'waku';
2+
// @ts-expect-error no types
3+
// eslint-disable-next-line import/no-unresolved
4+
import { Hello } from 'dummy-library/entry-point';
25

36
import { Counter } from '../components/counter';
47

@@ -11,6 +14,7 @@ export default async function HomePage() {
1114
<h1 className="text-4xl font-bold tracking-tight" data-testid="header">
1215
{data.headline}
1316
</h1>
17+
<Hello />
1418
<p>{data.body}</p>
1519
<Counter />
1620
<Link to="/about" className="mt-4 inline-block underline">

packages/waku/src/lib/plugins/vite-plugin-rsc-transform.ts

+4
Original file line numberDiff line numberDiff line change
@@ -695,6 +695,10 @@ export function rscTransformPlugin(
695695
return (await this.resolve(id.slice('/@id/'.length), importer, options))
696696
?.id;
697697
}
698+
if (id.startsWith('/@fs/')) {
699+
return (await this.resolve(id.slice('/@fs'.length), importer, options))
700+
?.id;
701+
}
698702
const resolved = await this.resolve(id, importer, options);
699703
let srcId =
700704
importer && (id.startsWith('./') || id.startsWith('../'))

0 commit comments

Comments
 (0)