-
Notifications
You must be signed in to change notification settings - Fork 47k
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
Add CodeSandbox CI Config #17175
Add CodeSandbox CI Config #17175
Conversation
.codesandbox/ci.json
Outdated
@@ -0,0 +1,9 @@ | |||
{ | |||
"packages": ["packages/react", "packages/react-dom"], | |||
"buildCommand": "build react/index,react-dom/index", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"buildCommand": "build react/index,react-dom/index", | |
"buildCommand": "build --type=UMD,NODE react/index,react-dom/index", |
The other bundles won't be published anyway due to the publishDirectory.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't need UMD, though
.codesandbox/ci.json
Outdated
"buildCommand": "build react/index,react-dom/index", | ||
"publishDirectory": { | ||
"react": "build/node_modules/react", | ||
"react-dom": "build/node_modules/react-dom" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's do Scheduler, too.
We already build all the packages and store them as CircleCI artifacts. Is there some way we could leverage those instead of building twice? Then we don't have to worry about them getting out of sync. These are also the same artifacts we publish to npm. Perhaps by waiting for CircleCI to finish first, and then downloading the tarball from there? |
"publishDirectory": { | ||
"react": "build/node_modules/react", | ||
"react-dom": "build/node_modules/react-dom", | ||
"scheduler": "build/node_modules/scheduler" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this will cause the same issue as mui/material-ui#17976 (comment):
react-dom
declares a dependency on scheduler
with the newly created version but codesandbox thinks this version is on the npm registry.
I guess this applies regardless of whether scheduler
is built in the codesandbox CI or not.
The way we handle this with our prerelease builds is we have a post-build step to rewrite the package jsons to update the version numbers to point to each other: react/scripts/release/utils.js Lines 192 to 200 in 3497ccc
So then the result looks like:
We can do the same in the build script for CodeSandbox CI. (Also this is one of the reasons I wanted to pull from the CircleCI artifacts, so subtle stuff like this stays in sync.) Seems like it could be a cool feature for CodeSandbox CI to support, too :) |
Yeah I tried this too but the issue is that codesandbox looks for this version on the npm registry. Unless you publish the PR build to npm codesandbox won't find it. Unless they changed it in the last days. The key difference is that react-dom is declared in the package.json of the codesandbox as a url not a version string. |
Ah yeah that's exactly the same I issue I ran into when I tried to do a version of this myself. I was using tarball URLs and the top level dependencies loaded fine, but the transitive dependencies didn't because CodeSandbox tried to pull them from npm. This is a blocker for us being able to use it, unfortunately |
It should resolve the package with the same version number (regardless of the source, npm or csb), since we use the node file resolver for finding packages. If that's not happening we encountered a bug, I'll take a look at that today! I really like the idea of version rewriting, I'll take a look at that today as well! |
I added version rewriting to the CI service, it should go live in a couple hours. This should make it easier for packages that require eachother to resolve eachother. I also found why we resolve other dependency versions for transitive dependencies, it's interesting, because |
You can see the current version of the PR in action in CodeSandbox CI here: |
Thanks so much for this PR, @CompuIves! And for CodeSandbox! Excited to merge this tomorrow |
Everything should be working as expected now! I'm super excited for this 😄 😄 |
Ok let's go! Thank you again! |
I'll need to ask the OSS team at Facebook to approve the GitHub app. But I don't expect that will be an issue :) |
* Add CodeSandbox CI Config * Add default sandbox to build * Make build more efficient and add scheduler * Force build * Add scheduler image * Add scheduler/tracing to the build * Force another build
This will enable CodeSandbox CI on the React repo. To have a better idea of what CodeSandbox CI does you can read more about it here: https://u2edh.csb.app/. I recommend merging this PR first before installing the GitHub App, to ensure that all future PRs will work from the get-go.
The gist of it is:
The goal of this app is to make it easier for you to test your library without publishing to npm yet. Since CodeSandbox is already used for bug reports we wanted to make it possible to also test the PR version of your library with the existing bug reports.
In an ideal flow, it would work like this:
This way you will only have to open the generated sandbox to confirm that the fix works. No need to clone, install or test locally.