plugins icon indicating copy to clipboard operation
plugins copied to clipboard

Allow excluding manual chunks when using .generated

Open LarsDenBakker opened this issue 5 years ago โ€ข 8 comments

I am using the v5 .generated option, and I notice it doesn't allow excluding a chunk from compiling.

Parts of my project are already prebuilt, I just want to bundle this. I am using manual chunks to separating this code, it should be possible to exclude in the renderChunk phase using the chunk name. It works with rollup-plugin-terser too.

I realize this project is being moved to the plugins monorepo, will move the issue there when it's done.

LarsDenBakker avatar Apr 12 '20 08:04 LarsDenBakker

Could u create a repro case for this? Im not that well-versed in those advanced possibilities of Rollup and it would be easier for me to understand this if I could look at your input files, config and generated code

Andarist avatar Apr 12 '20 08:04 Andarist

This is an example setup: https://repl.it/repls/WigglySpiffyDatabase

I want to exclude big-library.js from babel and terser, since it's already es5 and minified. It's a huge library, it takes like 30sec to run through babel and terser :)

manualChunks allows telling rollup to keep it in a separate chunk, so that you can exclude it. Or so I thought, because unfortunately I see that the faceModuleId is not set for manual chunks, and the fileName is the minified filename. Terser's exclude logic doesn't work properly either because of this :(

LarsDenBakker avatar Apr 12 '20 08:04 LarsDenBakker

It seems that we should use the .name field for this. See: https://github.com/rollup/rollup/issues/3497

LarsDenBakker avatar Apr 13 '20 06:04 LarsDenBakker

Hm, filtering options have been on purpose not implemented for Babel output plugin by @lukastaegert: https://github.com/rollup/plugins/blob/2623f390c3385fcaf3a3072e8e6c0ec71f6ad114/packages/babel/src/index.js#L177-L182

Maybe he could shed some light if adding support for this is a good idea?

Andarist avatar May 10 '20 11:05 Andarist

The idea was that those options are meant to describe source files in the file system, and if those options worked, they could create the expectation that it is possible to exclude on source module level, which is impossible. Moreover at the point where transformations are applied, actual file names are not even known. Therefore, reusing those options does not really make sense. One could match a regular expression against the name property of a chunk, though, but I think it would only work properly for manual chunks. An entry chunk might just be a facade after all. So maybe just enable listing names of manual chunks?

lukastaegert avatar May 10 '20 11:05 lukastaegert

Also, not sure how one would want to run micromatch or picomatch on virtual files

lukastaegert avatar May 10 '20 11:05 lukastaegert

@LarsDenBakker would you like to take a stab at implementing this through new options that would need to be used for manual chunks case?

Andarist avatar May 11 '20 09:05 Andarist

I've got quite a lot of things pending currently, but I can definitely take a stab at this when I get the time :)

LarsDenBakker avatar May 11 '20 09:05 LarsDenBakker