JoviDeCroock / webpack-module-nomodule-plugin

Easily implement a module nomodule index.html
82 stars 6 forks source link

Use it with create-react-app? #20

Closed Menci closed 3 years ago

Menci commented 3 years ago

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.

JoviDeCroock commented 3 years ago

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

So the basic ingredients are:

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

Menci commented 3 years ago

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

JoviDeCroock commented 3 years ago

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.

Menci commented 3 years ago

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

Does it support Webpack 5?

Menci commented 3 years ago

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.

Menci commented 3 years ago

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?

Menci commented 3 years ago

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.

Menci commented 3 years ago

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

Menci commented 3 years ago

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