-
Notifications
You must be signed in to change notification settings - Fork 293
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
require.main === module
is different after ncc (again)
#748
Comments
Here is the PR fixing problem in my repo. It downgraded ncc from v0.29.0 to v0.27.0. v0.29.0 uses
Point is that, ncc v0.29.0 can build the minimal case |
I can verify that: test.js console.log(require.main === module); with So the question then is - under what conditions are you finding this fails? Looking at your code you are running this check in an ES module file - that may actually be the issue here in that There is a way to do this same check in ES modules in Node.js although it is a little bit complex: import { pathToFileURL } from 'url';
import process from 'process';
if (import.meta.url === pathToFileURL(process.argv[1]).href)
console.log('MAIN'); I just tested the above pattern in ncc, and unfortunately it appears that doesn't seem to be supported. In that case I'd suggest we treat this issue as a feature request for the above pattern to be supported rather. |
(the test is still present and working just fine at https://github.com/vercel/webpack-asset-relocator-loader/tree/main/test/unit/require-main) |
The reason @sokra are there any plans or ways to permit pass-through of |
Thank you! Your comment helped me a lot to clarify what is happening. How you found that the project is built as an ES module? Thanks again for your support! |
According to the
But in my project there is no |
@KengoTODA I think the TS bug is fixed in 0.31.0. Please give it a try, thanks! |
Thanks @styfle, I've confirmed I'll close this issue. @guybedford @styfle Thank you again :) 🙌 |
Thanks for sharing great tool to minify TS code, I'm using ncc so heavily for my GitHub Actions projects :)
Today I found an unexpected behavior same to the #224. I confirmed that v0.27.0 works fine but v0.28.0 doesn't, so there is a regression during 0.27.0...0.28.0 I guess.
I've investigated about why this regression comes again even though #229 added a unit test?
It seems that v0.14 has the test case but v0.15 does not have it, it seems that 8abb4ba (#264) removed the test case.
The text was updated successfully, but these errors were encountered: