Closed GerkinDev closed 6 years ago
Whoa, sorry, somehow I didn't notice this in my inbox!
This plugin is pretty straightforward. It just simulates a filesystem, either as a replacement for the real one or (if allowFallthrough
is set to true
) as an overlay.
That is to say, if you're using this plugin with allowFallthrough
, then when Rollup tries to read certain files, the reads will be intercepted and the files' contents substituted with whatever you like, be that export default {};
or anything else.
For instance:
// rollup.config.js
import nodeResolve from 'rollup-plugin-node-resolve';
import hypothetical from 'rollup-plugin-hypothetical';
export default {
entry: './source/main.js',
plugins: [
hypothetical({
allowFallthrough: true,
files: {
'some-external-module/': `
export default {};
`
}
}),
nodeResolve()
]
};
With that, any import 'some-external-module'
will resolve to a file export default {};
, since it will be intercepted before it can get to rollup-plugin-node-resolve.
It works well, thank you! I did not understand that it was possible to totally ignore a module from node_modules
using that syntax. Sorry for the silly question ^^ and thank you again for your work!
Hi there!
I'm trying to ignore some modules with rollup, and this rollup issue says that your plugin can do the work. The problem is that I don't understand how to make it replace some module inclusions with an export of an empty object, or anything that can discard the module & its dependencies.
Are you able to explain a bit more in you documentation what you plugin do, and how to achieve that?
Thank you for your time, cheers!