-
Notifications
You must be signed in to change notification settings - Fork 261
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
Using ncc
to build dist/index
causes __dirname
to end up in "browser bundle"
#784
Comments
Hi @sjchmiela thanks for noticing this, I'm curious how are you using styled-jsx in your project. Are you playing it without webpack so that it causes an error? A code example will be super helpful |
Ah, that's a story on its own! 😃 At Glow we're bundling a React project with esbuild while using I decided to support
|
@huozhi what this error looks like for us with Webpack 4 building and then running in a Chrome extension
We also define // webpack.config.js
module.exports = {
...
node: {
__dirname: false
}
} |
After bumping webpack@4 to [email protected], this issue is no longer present in my project. |
@sjchmiela Are you using webpack 5? Not sure if it works for your case |
Thanks for the suggestion! We're using |
Will close it for now as webpack 5 should be able to handle this and there's workaround for the original case. Feel free to comment if you have any further issues with it |
I had the same problem with vite. How to solve it? |
|
Do you want to request a feature or report a bug?
A bug.
What is the current behavior?
styled-jsx/dist/index/index.js
includes reference to__dirname
. As far as I can tell it's there becausencc
is used to compiledist/index
andncc
is designed to support Node.js runtime.Maybe it's expected that every JS bundler removes
__dirname
while bundling for the browser?Reproduce steps
Download https://registry.npmjs.org/styled-jsx/-/styled-jsx-5.0.0.tgz and open
package/dist/index/index.js
. Search for__dirname
(it's in the line 733).I can also provide a full project a bundler configured etc., but since it has a couple of moving pieces (ESBuild, Babel) I decided to leave it off. Let me know if it would help!
What is the expected behavior?
Bundle to be used in the browser doesn't use
__dirname
since it's not available there?Environment (include versions)
next.js
Did this work in previous versions?
Until #770
index.js
was being built withbabel
.The text was updated successfully, but these errors were encountered: