-
-
Notifications
You must be signed in to change notification settings - Fork 26.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Forbid running any scripts when webpack/jest/babel are installed directly #3638
Comments
Alternatively we should probably be more resilient in how we resolve dependencies so that installing incompatible versions can't break us. I'll need to think more about this. |
how about packaging react-scripts using https://github.com/zeit/pkg? will it solve the problem? |
Potentially, and maybe help performance too. I’m interested in seeing a proof of concept. |
I've experimented with it before, but couldn't make it work... IIRC something to do with dynamic requires. Will bundling react-scripts into one file using webpack / rollup achieve similar results? |
tried using webpack, it also complains about dynamic requires |
Wouldn't that make it really impractical to work with |
can you share more about the monorepos use case? I think the duplication does not matter because react-scripts should be self-contained and free of outside interference. Right now you can even modify webpack.config.dev.js from the outside and call scripts/build.js. This is what i did in my project: // build.js, call node build.js instead of react-scripts build
process.env.NODE_ENV = 'production';
const config = require('react-scripts/config/webpack.config.prod');
const RollbarSourceMapPlugin = require('rollbar-sourcemap-webpack-plugin');
config.plugins.push(
new RollbarSourceMapPlugin({
accessToken: process.env.REACT_APP_ROLLBAR_SOURCEMAP_ID,
version: process.env.REACT_APP_GIT_SHA,
publicPath: config.output.publicPath,
}),
);
require('react-scripts/scripts/build'); This breaks the guarantee of upgradable react-scripts but a convenient way to have an "almost standard" setup. Packaging react-scripts would break this use case and even react-app-rewired, but make it more resilient to outside interference. So yeah, packaging would be an extreme decision to make. 😄 Is there any other way to make the react-scripts always work in the jungle of different environments and interference? |
Mostly it's just having the client and server in the same place so I can work on them both or share packages between the two. It's also useful in libraries to have an I think duplication does matter, but I'm a bit of a fanatic when it comes to deduplication, though, so take what I have to say on the matter with a grain of salt. As far as modifying the internals, couldn't you just do what they did with |
Yes! I admire your work on deduplicating dependencies :) The problem is it's quite common for server-side code to use dynamic requires, they were expected to run in node/commonjs environment which allows variable to be used as the argument for require. It's sad that it makes it harder for the consuming project to bundle their code because it can't be statically analyzed to be bundled together. |
After playing around with pkg a bit more I can see that it turns out to be easier to config the file glob for dynamic requires! You just need
But it chokes on non-standard js file with .js extension: 😢
|
I was thinking about this today. What would the story be about ejecting with this? |
@wtgtybhertgeghgtwtg I think we can just copy / create the the source to the user folder? Opened #3704 for the POC work on this |
The problem with bundling is it will break semi-supported use cases like |
For this problem I think the more immediate solution is to figure out what breaks when user installs Jest/Babel/ESLint/Webpack themselves and fix it. Ideally we should just ignore them. |
I think the most straight forward solution is the best, check if webpack/jest/babel are installed directly, or unsupported versions are being pulled because of other dependencies. An engineering solution to this is bound to bring up it's own complexity and problems, is it worth it? |
And with |
We could check but it seems like the root of the issue is that we incorrectly resolve dependencies somewhere. Just installing something at the project root shouldn’t break the build. |
Sure, it should be unacceptable to break your build just because you wanted to install something like |
Here's a use case and I'm not sure how it would fit in here:
I guess I don't care about installing I'm also not sure |
Again, that is exactly my point. Since |
Just realized we already have an issue tracking this. |
Fixed by #3771. |
We get too many issues with people trying to update these tools manually and completely breaking setups. We should just check for those dependencies and immediately crash with an explanation that it's not supported to declare them explicitly without ejecting.
The text was updated successfully, but these errors were encountered: