-
Notifications
You must be signed in to change notification settings - Fork 96
Rollup Dependencies that Use Node Globals #163
Comments
Are you sure you didn't forget about this? import replace from 'rollup-plugin-replace';
replace({
'process.env.NODE_ENV': JSON.stringify('production')
}) |
@TrySound That's for strings? I have things using |
To further elaborate. This plugin has an option: Because I have devDependencies pointing to packages with the appropriate names: So I'm trying to find a way to be able to use |
Try this for |
I have tried that. What ends up happening is that the implicit uses of |
I have the same problem when building for node.js (I am just trying to build a single .min.js file so that I don't have to manage node_modules in production) - I have preferBuiltins: true and I still get a Buffer shim in my output, so I end up with 2 implementations of Buffer depending how you use it. |
This ended being a case-sensitivity issue - I have a Buffer shim called buffer in my node_modules (because someone required it). So when bundling for node.js this shim gets included even with preferBuiltins: true. Adding "Buffer" to externals doesn't change anything, but adding "buffer" solves the issue. |
its OK, because npm package name can be only in lowercase. Can it be closed for now? |
Fwiw you can use rollup-plugin-inject to generate explicit imports for implicit dependencies on buffer and process. |
Closing this issue as I believe the original question has been answered. |
I have third party dependencies that use node globals like
process
. They don't explicitly require the module usingvar process = require('process');
so Rollup cannot find them.I have a
process
shim in my devDependencies. And for the dependencies that do in fact usevar process = require('process');
it works and rewrites them to getting theprocess
shim. However it renames the object tobrowser
for some reason.How do I do either:
process
be namedprocess
instead of being namedbrowser
ORprocess
to be resolved to theprocess
shim (in this case currently namedbrowser
in the UMD module)?The text was updated successfully, but these errors were encountered: