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.
No description
9 Replies
Fabian B.
Fabian B.2y ago
Does it load twice on build?
FabiansGeikinsSpeckle
@Fabian B. seems to be loading twice in a prod build as well, yes
Fabian B.
Fabian B.2y ago
How do you load this module in your code? And how is it installed? Anything special?
FabiansGeikinsSpeckle
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
Fabian B.
Fabian B.2y ago
ah yeah I see. TipTap is great 🚀 stuff. I guess there isn't much to do then. How much kb is it?
FabiansGeikinsSpeckle
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 twice
FabiansGeikinsSpeckle
2 different lines with the same content essentially, weird i'll try and look into why it's being bundled in twice
Want results from more Discord servers?
Add your server