astroturf icon indicating copy to clipboard operation
astroturf copied to clipboard

webpack 5 support

Open dreyks opened this issue 5 years ago • 14 comments

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?

dreyks avatar Oct 08 '19 12:10 dreyks

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

jquense avatar Oct 08 '19 13:10 jquense

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)

dreyks avatar Oct 08 '19 13:10 dreyks

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?

dreyks avatar Oct 12 '19 20:10 dreyks

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)

IAPark avatar Sep 15 '20 00:09 IAPark

I've been working on this, and it's a good bit more complicated than i would have hoped :/

jquense avatar Sep 15 '20 14:09 jquense

well, do tell us if we can help you in any way

dreyks avatar Sep 15 '20 14:09 dreyks

Isn't what webpack-virtual-modules does?

cahnory avatar Nov 09 '20 22:11 cahnory

Any workaround for now? Can we use Astroturf in Babel?

ai avatar Nov 26 '20 02:11 ai

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

jquense avatar Nov 26 '20 14:11 jquense

Isn't what webpack-virtual-modules does?

That's a fascinating project. It could potentially help.

@jquense what work were you referring to?

jsg2021 avatar Feb 05 '21 19:02 jsg2021

@jquense nevermind I found it. Though, I'd probably just prefer to wait on your 1.0.0 :)

jsg2021 avatar Feb 05 '21 19:02 jsg2021

you can use v1 now, I'm likely going to promote it to stable very soon, we use it in prod

jquense avatar Feb 05 '21 22:02 jquense

@jquense I tried it out. Looks like the v1 branch is missing this fix: https://github.com/4Catalyzer/astroturf/commit/8b01c126f499aba4b330cc52160f60954bde158a

jsg2021 avatar Feb 06 '21 19:02 jsg2021

@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. :)

jsg2021 avatar Feb 06 '21 20:02 jsg2021