How to prevent NPM package from being loaded/ran twice in the client build?
My Nuxt app relies on
prosemirror-state
which is supposed to be a singleton module, but it appears that Nuxt is loading it twice at least in the dev server: Once from /node_modules/prosemirror-state/dist/index.js
and the 2nd time from /_nuxt/node_modules/prosemirror-state/dist/index.js
.
I've added prosemirror packages to build.transpile
in the nuxt config, but this doesn't appear to have changed anything.9 Replies
Does it load twice on build?
@Fabian B. seems to be loading twice in a prod build as well, yes
How do you load this module in your code?
And how is it installed? Anything special?
not really, it's an indirect dependency that tiptap (a text editor) relies on, that's what I'm using directly
so whenever I import tiptap, somewhere down the line prosemirror is loaded
ah yeah I see. TipTap is great 🚀 stuff. I guess there isn't much to do then. How much kb is it?
I just noticed that there's actually only 1 file being downloaded, I'm guessing it shows up as 2 in the search because of sourcemaps or something? But this single .js file seems to have the entire
prosemirror-state
package appearing twice2 different lines with the same content essentially, weird
i'll try and look into why it's being bundled in twice