-
Notifications
You must be signed in to change notification settings - Fork 47.6k
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
Use Yarn Workspaces #11252
Use Yarn Workspaces #11252
Conversation
712df01
to
eae492d
Compare
@@ -1,6 +1,18 @@ | |||
'use strict'; | |||
|
|||
var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; | |||
var _extends = | |||
Object.assign || |
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.
Hmm noticed this, does this assume a object.assign polyfill (can use useBuiltIns
option if so)
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.
It doesn't assume it. (This is very rarely used code though and doesn't matter for majority of users. So we just checked in a compiled version.)
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.
Everything looks good to me. Two things though:
- There was lots of file moving/renaming, we should be careful we don't lose any git history as I've had issues with this in the past (maybe a non-issue, but wanted to flag it anyway).
- Can we block NPM usage so contributors don't run into issues (as this is all tied to Yarn now)?
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.
This looks great Dan!
packages/react-native/index.js
Outdated
|
||
'use strict'; | ||
|
||
// TODO: This package is a lie. Maybe rename to react-native-renderer? |
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.
👍
// Internal forwarding modules | ||
'packages/*/*.js', | ||
// Source files | ||
'packages/*/src/**/*.js', |
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.
Should we also include packages/*/npm/*.js
to ensure the NPM entry points stay formatted?
Nevermind. Looks like these are covered below in scripts
@@ -2,6 +2,7 @@ | |||
|
|||
const dependencies = ['fbjs', 'object-assign', 'prop-types']; | |||
|
|||
// TODO: enumerate all non-private package folders in packages/*? |
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 like this.
We could actually enumerate all package folders (so we increment version numbers) but just only publish non-private ones.
return Promise.resolve(); | ||
} | ||
if (fs.existsSync(to)) { | ||
// We already created this package (e.g. due to another entry point). |
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.
Are we concerned about a partial copy? (Like maybe something failed from a previous run?)
Nevermind. Looks like the main rollup/build
script calls rimraf
before createBundle
.
return Promise.resolve(); | ||
} | ||
// TODO: verify that all copied files are either in the "files" | ||
// whitelist or implicitly published by npm. |
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.
This is something the release script could do too, if it makes more sense there.
5060247
to
228e270
Compare
This makes the test pass again, but breaks the build because npm/ folders aren't used yet. I'm not sure if we'll keep this structure--I'll just keep working and fix the build after it settles down.
Note that this is currently broken because Jest ignores node_modules, and so Yarn linking makes Jest skip React source when transforming.
It is now unnecessary. Some tests fail though.
Jest sees node_modules and thinks it's third party code. This is a hacky way to teach Jest to still transform anything in node_modules/react* if it resolves outside of node_modules (such as to our packages/*) folder. I'm not very happy with this and we should revisit.
It's not super clear how to organize this properly yet.
I didn't change this file but Flow started complaining. Caleb said this annotation was unnecessarily using $Abstract though so I removed it.
Use file: instead of NODE_PATH since NODE_PATH. NODE_PATH trick only worked because we had no react/react-dom in root node_modules, but now we do. file: dependency only works as I expect in Yarn, so I moved the packaging fixtures to use Yarn and committed lockfiles. Verified that the page shows up.
Wow, really a lot of changs, great work! |
So that package boundaries are clearer. |
great work! |
I updated reactjs.org docs following this major change in the folder structure, feedbacks and improvements welcome :) |
* Enable Yarn workspaces for packages/* * Move src/isomorphic/* into packages/react/src/* * Create index.js stubs for all packages in packages/* This makes the test pass again, but breaks the build because npm/ folders aren't used yet. I'm not sure if we'll keep this structure--I'll just keep working and fix the build after it settles down. * Put FB entry point for react-dom into packages/* * Move src/renderers/testing/* into packages/react-test-renderer/src/* Note that this is currently broken because Jest ignores node_modules, and so Yarn linking makes Jest skip React source when transforming. * Remove src/node_modules It is now unnecessary. Some tests fail though. * Add a hacky workaround for Jest/Workspaces issue Jest sees node_modules and thinks it's third party code. This is a hacky way to teach Jest to still transform anything in node_modules/react* if it resolves outside of node_modules (such as to our packages/*) folder. I'm not very happy with this and we should revisit. * Add a fake react-native package * Move src/renderers/art/* into packages/react-art/src/* * Move src/renderers/noop/* into packages/react-noop-renderer/src/* * Move src/renderers/dom/* into packages/react-dom/src/* * Move src/renderers/shared/fiber/* into packages/react-reconciler/src/* * Move DOM/reconciler tests I previously forgot to move * Move src/renderers/native-*/* into packages/react-native-*/src/* * Move shared code into packages/shared It's not super clear how to organize this properly yet. * Add back files that somehow got lost * Fix the build * Prettier * Add missing license headers * Fix an issue that caused mocks to get included into build * Update other references to src/ * Re-run Prettier * Fix lint * Fix weird Flow violation I didn't change this file but Flow started complaining. Caleb said this annotation was unnecessarily using $Abstract though so I removed it. * Update sizes * Fix stats script * Fix packaging fixtures Use file: instead of NODE_PATH since NODE_PATH. NODE_PATH trick only worked because we had no react/react-dom in root node_modules, but now we do. file: dependency only works as I expect in Yarn, so I moved the packaging fixtures to use Yarn and committed lockfiles. Verified that the page shows up. * Fix art fixture * Fix reconciler fixture * Fix SSR fixture * Rename native packages
Here’s an overview of what happened:
src/
is gone.packages/*
is now the source of truth.yarn
in the root sets up the symlinks in rootnode_modules
.packages/*/src
. I intentionally haven’t touched them.packages/*/*.js
redirect to the sources. They are used for Jest and Rollup.packages/*/npm/*.js
redirect to flat bundles. They are used for npm.Must Do
src/
NODE_PATH
doesn't work