astroturf
astroturf copied to clipboard
webpack 5 support
trying webpack 5 alpha, getting Module not found
for astroturf virtual files. probably something has changed in the way we should insert virtual modules into the compilation?
likely, i've not had a chance to try out v5 yet, but given how invasive the virtual module plugin is it seems likely something broke. Not sure tho if it makes sense to wait until dev on v5 is more settled before working on support
sounds fair. let's leave this issue here as a reference and maybe i can find time to dive into the virtual module (or to see if i even have what it takes to swim there :D)
so my first suspect was this place https://github.com/4Catalyzer/astroturf/blob/b4cdd9492044a3cd44f4f5e8b20f0e134086a3b2/src/VirtualModulePlugin.js#L21-L31
and I was right :)
webpack 5 has changed it to just cache
the immediate fix is easy but maybe we should try using a resolver plugin?
If it helps, I think I get a different error when I try to upgrade to the now beta:
Module build failed (from ./node_modules/astroturf/loader.js):
TypeError: Cannot read property 'set' of undefined
at styles.forEach.style (/home/<....>/code/<....>/node_modules/astroturf/loader.js:239:34)
at Array.forEach (<anonymous>:null:null)
at Promise.all.then (/home/<....>/code/<....>/node_modules/astroturf/loader.js:237:12)
I've been working on this, and it's a good bit more complicated than i would have hoped :/
well, do tell us if we can help you in any way
Isn't what webpack-virtual-modules does?
Any workaround for now? Can we use Astroturf in Babel?
Sorry most dev is on the v1 branch. I'm hoping to get some time to get caught up very soon, or if someone wants to back port the fix, it's pretty straightforward and atomic to pull out
Isn't what webpack-virtual-modules does?
That's a fascinating project. It could potentially help.
@jquense what work were you referring to?
@jquense nevermind I found it. Though, I'd probably just prefer to wait on your 1.0.0 :)
you can use v1 now, I'm likely going to promote it to stable very soon, we use it in prod
@jquense I tried it out. Looks like the v1 branch is missing this fix: https://github.com/4Catalyzer/astroturf/commit/8b01c126f499aba4b330cc52160f60954bde158a
@jquense After applying the patch to v1 locally, I can compile... ~~however, my usage of styled & css tags aren't getting compiled now. (getting the runtime fallback exception) Did the babel plugin change somehow?~~ Found it. allowGlobal
. :)