I've recently used ncc to bundle the output from a purescript project and 99% of it worked great! However, one of the libraries I'm using checks the value of module.require as part of determining if it is running in the browser or in node. It appears that ncc changes the value of module.require after building. I've reproduced the issue below:
drew:~/code/example$ cat index.js
if (module.require) {
console.log("yes!");
} else {
console.log("no!");
}
drew:~/code/example$ node index.js
yes!
drew:~/code/example$ ./node_modules/.bin/ncc build index.js
ncc: Version 0.18.5
ncc: Compiling file index.js
2kB dist/index.js
2kB [307ms] - ncc 0.18.5
drew:~/code/example$ node dist/index.js
no!
Other than this small issue, everything worked fantastic. Thanks so much for this project.
Glad to hear the project is working well for you!
Yes we should support this case, PR created for the asset loader in https://github.com/zeit/webpack-asset-relocator-loader/pull/42, and let's continue track the merge of that in this issue.
Will this be included in the next release? Thanks!
This should be now fixed in ncc @0.19.
Most helpful comment
Glad to hear the project is working well for you!
Yes we should support this case, PR created for the asset loader in https://github.com/zeit/webpack-asset-relocator-loader/pull/42, and let's continue track the merge of that in this issue.