F1LT3R / babel-loader-lerna-cra

Transpile Create-React-App imports in Lerna projects.
MIT License
30 stars 9 forks source link

Bootstrap not working with react-scripts ^2.1.3 #5

Open andre-engelbrecht opened 5 years ago

andre-engelbrecht commented 5 years ago

Hi, I'm unable to run the bootstrap command when using react-script 2.1.3 or higher. This is because since v2.1.3 (or somewhere around there) the webpack.config scripts changed. There are no longer dev an prod config files and this makes the bootstrap command fail with:

ENOENT: no such file or directory, stat '...\monorepo-react\packages\react-app\node_modules\react-scripts\config\webpack.config.dev.js'

The following two config scripts now exist:

I know there was already a previous issue created for this very same issue, but it was closed without any real resolution: https://github.com/F1LT3R/babel-loader-lerna-cra/issues/4 Their solution was to roll-back to v2.0.5 (of react-scripts). I might do this as a temporary solution, but what are the odds you could update your utility to also support the new react-scripts configuration?

BTW, I think this utility is absolutely awesome, and I've not seen something similar yet. I really want HMR with my shared components, manually building them each time sucks.

kjgraham commented 5 years ago

i was able to get this issue to go away by manually creating a webpack.config.dev.js and webpack.config.prod.js (just did a [save as] on webpack.config.js).

However, although the script ran successfully, it still won't bypass the Module not found: Can't resolve '@my-project/comp-button' error message you see when you run the react app

F1LT3R commented 5 years ago

https://github.com/F1LT3R/cra-workspaces-poc

andre-engelbrecht commented 5 years ago

i was able to get this issue to go away by manually creating a webpack.config.dev.js and webpack.config.prod.js (just did a [save as] on webpack.config.js).

However, although the script ran successfully, it still won't bypass the Module not found: Can't resolve '@my-project/comp-button' error message you see when you run the react app

@kjgraham, I can help with that. There are a few tiny typos in the guide (https://f1lt3r.io/guide-multi-react-app-monorepo-with/)

Notice that in the package.json of comp-button the name (namespace) is setup as: "name": "@project/comp-button"

But then in the package.json from my-react-app the reference is setup as: "**@my-**project/comp-button": "*"

Notice the difference @project/... vs @my-project/...

And then also make sure your import is correct, not containing 'my-': import CompButton from '@my-project/comp-button';

andre-engelbrecht commented 5 years ago

https://github.com/F1LT3R/cra-workspaces-poc

@F1LT3R , thanks for the link, I will definitely try that out.

But I'm still wondering though, is there no way to tackle this problem in a way that would allow using the latest version(s) of CRA along with older versions, up to a specified version perhaps?

I really like what you did with the babel-loader-lerna-cra package, if there were only a way to make it work with newer versions of CRA as well (after they changed the config files around).

P.S. I'm actually not concerned with older versions of CRA, but people generally value backwards compatibility, so that's why I mentioned it. But support for older versions is not a requirement from my side.

I'd love to know your thoughts on this?

Best regards, @andre-engelbrecht

F1LT3R commented 5 years ago

You could make it work using the single webpack config, you could probably lift that from @f1lt3r/react-scripts.

For me to do this, it would be considerable effort for little gain as I'm using @f1lt3r/react-scripts with yarn Workspaces to bootstrap apps everyday. It's much cleaner.

Monkey patching things with babel-loader-lerna-cra every time you upgrade react or run yarn install may drive you crazy quicker than you realize.

If I was you, I would invest the time in running through the POC linked above. Unless there's something special about your situation, using a custom react-scripts is going to save you a lot of time overall.

On Fri, Feb 22, 2019, 2:51 AM André Engelbrecht notifications@github.com wrote:

https://github.com/F1LT3R/cra-workspaces-poc

@F1LT3R https://github.com/F1LT3R , thanks for the link, I will definitely try that out.

But I'm still wondering though, is there no way to tackle this problem in a way that would allow using the latest version(s) of CRA along with older versions, up to a specified version perhaps?

I really like what you did with the babel-loader-lerna-cra package, if there were only a way to make it work with newer versions of CRA as well (after they changed the config files around).

P.S. I'm actually not concerned with older versions of CRA, but people generally value backwards compatibility, so that's why I mentioned it. But support for older versions is not a requirement from my side.

I'd love to know your thoughts on this?

Best regards, @andre-engelbrecht https://github.com/andre-engelbrecht

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/F1LT3R/babel-loader-lerna-cra/issues/5#issuecomment-466306431, or mute the thread https://github.com/notifications/unsubscribe-auth/ABKXjouZ9QkO6T3GuBmJ28MfSFkNhD56ks5vP6FlgaJpZM4bHtUI .

andre-engelbrecht commented 5 years ago

@F1LT3R , I hear you, and no, there's no reason why I can't use your POC, It'll do the job just fine. I'm just nitpicky about not using the latest versions of things when I can. I'm not sure what changed from react-scripts v2.1.1 to v2.1.5, and I'm afraid of missing out on some important updates.

F1LT3R commented 5 years ago

If you can convince me why you need 2.1.5, I'll upgrade @f1lt3r/react-scripts.

andre-engelbrecht commented 5 years ago

@F1LT3R , I don't know if I can convince you to upgrade to 2.1.5, but I can see that 2.1.4 did include quite a number of tiny improvements: https://github.com/facebook/create-react-app/blob/master/CHANGELOG.md#214-february-10-2019

In the meantime I did find that you already have a version that's built on 2.1.3: https://www.npmjs.com/package/@f1lt3r/react-scripts. This is already better than 2.1.1.

Perhaps the sheer number of improvements in 2.1.4 could persuade you to upgrade, but while you're at it, rather just skip 2.1.4 and go straight to the latest version.

Anyway, I'm actually fine with using 2.1.3 for now, but it would be awesome if you'd consider upgrading to 2.1.5 eventually.

Best regards, André

andre-engelbrecht commented 5 years ago

So @F1LT3R, with the latest version of @f1lt3r/react-scripts - 2.1.3-e, how did you resolve this issue: https://github.com/facebook/create-react-app/issues/6214, or is this still an issue?

If I revert to v2.1.1-workspaces-04 all is fine.

Apologies, I could not find a repo for @f1lt3r/react-scripts, and I though it perhaps better to not create a new issue for a closely related issue.

d11ln commented 5 years ago

https://github.com/F1LT3R/cra-workspaces-poc

@F1LT3R this is awesome, thanks for this, it's going to save me a ton of time.

I'd like to add some weight to the request for an upgrade to include 2.1.5. I personally prefer using 2.1.5 for it's improvement allowing jest type ahead support and would be hard pressed to have to roll back.

Any chance you'd be willing to reconsider upgrading? I get that you might not need to for your own purposes but I think a lot of us are holding thumbs that you do.

Thanks for what you've offered thus far though, this utility is fantastic.

F1LT3R commented 5 years ago

@andre-engelbrecht I didn't. I'm using the old version Workspaces-004 whatever.

I was waiting until they released their new version before finishing the upgrade.

I'll try to get to it next week. Big crunch at work right now.

F1LT3R commented 5 years ago

@dcugh glad you find it useful.

What are you asking me to consider upgrading?

The custom react scripts that works with the POC? Or babel-lerna-loader-cra ?

andre-engelbrecht commented 5 years ago

Excellent, thanks @F1LT3R

uxxman commented 5 years ago

Any plan for upgrading it to v2@latest or v3?

tmaziere commented 5 years ago

Hi @F1LT3R,

It looks like we should now use react-workspaces-playground if we need CRA3, right?