nitro icon indicating copy to clipboard operation
nitro copied to clipboard

rollupConfig and nitro config for externals does not work together

Open Llois41 opened this issue 1 year ago • 1 comments

Environment

  • Nitro 2.9.5
  • Node.js 18.19.1

Reproduction

Hopefully this is understandable by my description of the bug. If not, I can make a simple reproduction later on.

Describe the bug

Using

rollupConfig: {
      external: ['@unhead/vue'],
    },

instead of

externals: {
      external: ['@unhead/vue'],
    },

inside the nitro config (inside the nuxt.config.ts) does have different outputs. Using the rollupConfig only prevents the dependency from getting inlined but the nuxt/nitro build seems to ignore this. In the build output package.json and in the node_modules folder the dependency is missing.

Using the nitro configuration's external.externals field does not cause this behaviour. This is very un-intuitive (pun un-intended). Why would there be a very similiar field to the rollup one? And why is this not even documented?

I would expect that nuxt's/nitro's build (I'm not quite sure where to draw the line between those but I guess this is a nitro behavior) respects the given rollup config fully and not doing some strange things that causes bugs. The bug would be the missing dependency in the output so after trying to install the package that was build like that would fail.

Thanks for having a look into this.

Cheers, Luis

Additional context

No response

Logs

No response

Llois41 avatar Apr 02 '24 18:04 Llois41

Hi. Please share a runnable (Nitro not Nuxt) reproduction app and also why you would need to use rollupConfig instead?

pi0 avatar Apr 02 '24 19:04 pi0

This issue had been open for a long time without reproduction. If you still have the same issue and can reproduce it, please feel free to comment and reopen 👍🏼

pi0 avatar Nov 08 '24 11:11 pi0