Mastodev, webpack help needed? 

Hi! I'm having a weird issue with : basically, whenever webpack is called with NODE_ENV=test, it doesn't create chunks for dynamically-imported modules (with the webpackChunkName comments), regardless of mode or optimization.nodeEnv.
I'm not sure what could be causing this and I'm not able to find any documentation regarding this. This occurs only with NODE_ENV=test, anything else works fine, including production, development, and entirely made-up things.

See: github.com/tootsuite/mastodon/

Mastodev, webpack help needed? 

@Thib I don’t know the chunk name plugin but maybe it’s a configuration option on its side? I’d assume they disable code splitting in tests to make easier to test without having to simulate dynamic imports ?

re: Mastodev, webpack help needed? 

@Eramdam idk, we set both chunkFilename and optimization.splitChunks exactly the same way in both production and test environments, and I can't find anything mentioning NODE_ENV=test in those things' documentation :/

re: Mastodev, webpack help needed? 

@Thib weird.. or maybe it’s a weird thing that webpacker does? (Idk how much webpacker adds to a regular webpack config, if anything)

re: Mastodev, webpack help needed? 

@Eramdam basically webpacker sets up env variables and calls webpack on the proper config file, also it adds RoR glue but that's not relevant for the compilation step… so, no, it doesn't really add anything here

calling webpack directly on the config file doesn't do the same thing depending on NODE_ENV, and I haven't been able to figure out why yet…

(for the time being, I submitted a fix that… simply uses “tests” instead of “test” for NODE_ENV, and it works just fine 🤷)

re: Mastodev, webpack help needed? 

@Thib 😅 Also, fwiw, the fact that haml templates references chunks by name directly looks like a code smell that'll randomly bite y'all in the ass in the future... but i dont have all the context so there must be a reason why it's done that way

Follow

re: Mastodev, webpack help needed? 

@Eramdam well it does so through something that looks up in the manifest, so it's kinda like webpack-generated HTML anyway 🤷

re: Mastodev, webpack help needed? 

@Thib ah, i see

Sign in to participate in the conversation
Mastodon (instance perso)

This is a small personal instance running on a couple small ARM servers at home.