JoviDeCroock / webpack-module-nomodule-plugin

Easily implement a module nomodule index.html

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Use it with create-react-app?

Menci opened this issue · comments

commented

I saw your PR in create-react-app. It is a pity that it was not merged and this another PR was forgetten over one year. Now I wonder if I can use this plugin in my CRA-based project?

Also, if you want to continue your work for CRA, maybe hacking it with react-app-rewired, if it's unable to be merged to mainline. If possible, I'm glad to test and debug with you with my CRA-based project.

It's possible to be used with an ejected config, see https://github.com/JoviDeCroock/POC-ModularLegacyBuild

So the basic ingredients are:

  • A babel config with a modern and legacy flavor
  • A webpack config that in production does two passes (modern and legacy)
  • In that production pass we use this plugin.

If you need any more information feel free to ping me, if you got a public repo I can try to wire it in.

commented

I don't eject my CRA since I don't want Webpack configuration files mess up my project. Are there any way without ejecting?

Not that I'm aware of, the purpose of CRA is to encapsulate the functionality of a basic React appliation so without ejecting there probably exists no way of injecting this without it being in there.

commented

Maybe I need to eject my CRA and mess my configuration up ...

Does it support Webpack 5?

commented

I ejected my CRA and got my Webpack config working. Now I'm trying to tell @babel/preset-env to build for modern (with { module: true } ?) and legacy (with package.browserslist).

Maybe I still need some runtime patches for the Babel config generated by babel-preset-react-app. The eject doesn't eject everything.

commented

Now I don't know how to make Babel work at all. The CRA's babel config files are in a mess. Even the exported functions of babel-preset-react-app/create.js and @babel/preset-env is NOT CALLED at all. Could you give a example of how to make babel-preset-react-app works on a ejected CRA project?

commented

Now I can make Babel build for modern browsers with package.json's browserslist changed, but I still don't know how to make Babel build for different targets.

commented

I think I found the way. Just patch the config like what your PR did should work.

commented

So I finally managed to get Babel works for both modern and legacy. But now I'm facing with another issue #21.