Skip to content

Commit

Permalink
feat: use node-loader again (#103)
Browse files Browse the repository at this point in the history
* feat: use node-loader again

* update CHANGELOG

* missing RSDW node-loader

* update docs
  • Loading branch information
dai-shi authored Jul 15, 2023
1 parent 624dd11 commit b682a9c
Show file tree
Hide file tree
Showing 8 changed files with 27 additions and 22 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
## [Unreleased]
### Changed
- fix: partially for css modules #98
- feat: use node-loader again #103

## [0.13.0] - 2023-07-06
### Changed
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ yarn create waku
```

```bash
pnpm create waku # pnpm not working for now
pnpm create waku
```

## Work in progress
Expand Down
5 changes: 5 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,11 @@
"require": "./dist/cjs/main.js",
"default": "./dist/main.js"
},
"./node-loader": {
"types": "./dist/node-loader.d.ts",
"require": "./dist/cjs/node-loader.js",
"default": "./dist/node-loader.js"
},
"./config": {
"types": "./dist/config.d.ts",
"require": "./dist/cjs/config.js",
Expand Down
14 changes: 0 additions & 14 deletions src/lib/builder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,11 +59,6 @@ const analyzeEntries = async (entriesFile: string) => {
(id) => serverEntryFileSet.add(id)
),
],
ssr: {
noExternal: /^(?!node:)/,
// FIXME this is very adhoc.
external: ["react", "minimatch"],
},
resolve: {
conditions: ["react-server"],
},
Expand Down Expand Up @@ -103,15 +98,6 @@ const buildServerBundle = async (
) => {
const serverBuildOutput = await viteBuild({
...configFileConfig,
ssr: {
noExternal: Object.values(clientEntryFiles).map(
// FIXME this might not work with pnpm
(fname) =>
path
.relative(path.join(config.root, "node_modules"), fname)
.split("/")[0]!
),
},
resolve: {
conditions: ["react-server"],
},
Expand Down
9 changes: 8 additions & 1 deletion src/lib/middleware/rsc/worker-api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,14 @@ import type {
} from "../../../server.js";

const worker = new Worker(new URL("worker-impl.js", import.meta.url), {
execArgv: ["--conditions", "react-server"],
execArgv: [
"--experimental-loader",
"waku/node-loader",
"--experimental-loader",
"react-server-dom-webpack/node-loader",
"--conditions",
"react-server",
],
});

export type BuildOutput = {
Expand Down
5 changes: 0 additions & 5 deletions src/lib/middleware/rsc/worker-impl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,11 +108,6 @@ const vitePromise = viteCreateServer({
parentPort!.postMessage(mesg);
}),
],
ssr: {
noExternal: /^(?!node:)/,
// FIXME this is very adhoc.
external: ["react", "minimatch", "react-server-dom-webpack"],
},
resolve: {
conditions: ["react-server"],
},
Expand Down
11 changes: 11 additions & 0 deletions src/node-loader.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
export async function load(url: string, context: any, nextLoad: any) {
const result = await nextLoad(url, context, nextLoad);
if (result.format === "module") {
let { source } = result;
if (typeof source !== "string") {
source = source.toString();
}
return { ...result, source };
}
return result;
}
2 changes: 1 addition & 1 deletion website/src/routes/docs/installing.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { CodeBlock } from "../../components/Code.js";

const code1 = `npm create waku@latest
yarn create waku
pnpm create waku # pnpm not working for now`;
pnpm create waku`;

export default function Layout() {
return (
Expand Down

1 comment on commit b682a9c

@vercel
Copy link

@vercel vercel bot commented on b682a9c Jul 15, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

waku – ./

waku-daishi.vercel.app
waku-git-main-daishi.vercel.app
waku.gg
waku.vercel.app
www.waku.gg

Please sign in to comment.