-
-
Notifications
You must be signed in to change notification settings - Fork 129
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: mock __non_webpack_require__ #579
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
This pull request is automatically built and testable in CodeSandbox. To see build info of the built libraries, click here or the icon next to each commit SHA. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
8369eed
to
84edf83
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the workaround. We need some tweaks.
@@ -19,6 +19,7 @@ import { | |||
fileURLToFilePath, | |||
} from '../utils/path.js'; | |||
import { encodeInput, hasStatusCode } from './utils.js'; | |||
import { createRequire } from 'node:module'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This file is used in non-Node runtime, so we can't import it here. Any hacks to avoid it?
This fixed my problem with sqlite - thanks! |
only for the DEV mode - it will break in BUILD Mode:
and here some code to replicate the error on import { Link } from 'waku';
import { Counter } from '../components/counter.js';
import sqlite from "better-sqlite3";
const db = sqlite("main.db");
export const HomePage = async () => {
const data = await getData();
return (
<div>
<title>{data.title}</title>
<h1 className="text-4xl font-bold tracking-tight">{data.headline}</h1>
<p>{data.body}</p>
<Counter />
<Link to="/about" className="mt-4 inline-block underline">
Learn more
</Link>
</div>
);
};
const getData = async () => {
db.exec(`CREATE TABLE IF NOT EXISTS user (
id TEXT NOT NULL PRIMARY KEY
)`);
const data = {
title: 'Waku',
headline: 'Waku',
body: 'Hello world!',
};
return data;
}; |
I feel this is more like a upstream issue which didn't handle ESM/CJS, or webpack environment correctly |
Here is my working setup to use
It works but it shows that there might be a need to add plugins to WAKU build process without modifications of the source of build.ts |
closing, see #707 |
close #579 - [x] prd - [x] dev --------- Co-authored-by: Mohammad Bagher Abiyat <zorofight94@gmail.com>
No description provided.