-
Notifications
You must be signed in to change notification settings - Fork 520
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
Project files not found, but npm install seemed to have worked? #97
Comments
Looks like this particular binary makes an assumption about the filesystem layout that doesn't hold under Bazel. |
I'm working on this with @hectim. We've been able to get the binary to execute properly(?), but it's like react-scripts can't actually transpile the code. The config that gets generated and used by webpack, within react-scripts looks like: (this was just commented out just before running the webpack compiler)
The nodejs_binary:
What happens when we run the generated binary (bazel run :reactscripts build) is a module parse error:
|
I want to mention that I've tried Parcel bundler as well as rollup now and have similar issues. There is something fundamentally wrong with how we're doing this in regards to the node_modules / paths but we're pretty stuck as to where we're going wrong. |
Don't have time to repro right now, you'll have to debug some more to find
then we'll figure out how to adjust one of those to make the resolution succeed. |
Sorry I wasn't able to help with this, I'm closing the issue as it seems stale and I don't know how to repro. Please comment or open a new issue if you have a repro. |
Since I debugged something similar today with a colleague, here's what we found: https://github.com/facebook/create-react-app/blob/d36603979591f37eed6f7a3efcba136e7547e75d/packages/react-scripts/bin/react-scripts.js#L32-L38 spawns the build.js script in a new Line 33 above should have been Also the react-scripts file doesn't do a great job erroring when the subprocess fails... I don't know if that's your issue, but it might at least help in tracking down some things or being able to reproduce. |
@MarkusTeufelberger Which version of rules_nodejs are you using? The |
We used a custom written rule, but got an error pattern that looked very similar to the one reported here. Maybe modifying the PATH already fixes the reported issue too (it definitely would have fixed ours). It was just something that caused a relatively large amount of head scratching (it works on one machine but not the other) and I thought it might be useful to contribute the cause here too, in case it was something you didn't yet consider or try when reproducing/fixing. |
Just want to chime in that we abandoned this issue (and react-scripts) in favor of writing our own webpack and typescript build process. Took a lot of work but we've got Bazel working for us (with the exception of a decent local dev server as of yet) for our front end projects. |
@gunn4r care to open source or blog about the build process you got setup? |
I've been trying to get a simple create-react-app@2.0 running in bazel and have run across a couple things, but am still blocked. First, the cra expects cwd to be the project root. I've ejected my scratch cra app and modified the config and scripts folders to use __dirname relative paths. Second, bazel is monkey patching the require function, but babel is using the npm resolve module to load plugins. Since resolve doesn't have the patches, babel ignores the plugins and tosses errors because it doesn't transpile jsx. See babel/babel#7952 and #211 I'm ok with the __dirname change, but this babel using resolve issue is still blocking me. I'm trying to get it working with a minimal change to the ejected webpack config, but its a bit slow going. I'll follow up if I figure out a solution. |
Fixes bazel-contrib#89 Closes bazel-contrib#97 PiperOrigin-RevId: 178165727
Fixes bazel-contrib#89 Closes bazel-contrib#97 PiperOrigin-RevId: 178165727
Attempting to build a React project with Bazel. I was able to get it working if I handle the node_modules myself, but when I try to have Bazel auto-manage them I run into errors. Was wondering if you could point me in the right direction.
WORKSPACE
BUILD.bazel
bazel run :react start
throws an errorwhereas
bazel run :react install
gives a valid responseSo it seems that the node_modules were correctly installed but the script I'm referencing can't seem to find the project files where it usually looks. Is this simply a consequence of react-scripts not being familiar with the file locations or am I missing something necessary in the build file? Any help in the right direction would be appreciated.
edit: example repo here
The text was updated successfully, but these errors were encountered: