Skip to content
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

Merged
merged 31 commits into from
Oct 18, 2017
Merged

Use Yarn Workspaces #11252

merged 31 commits into from
Oct 18, 2017

Conversation

gaearon
Copy link
Collaborator

@gaearon gaearon commented Oct 17, 2017

Here’s an overview of what happened:

  • src/ is gone.
  • packages/* is now the source of truth.
  • Running yarn in the root sets up the symlinks in root node_modules.
  • Sources live in packages/*/src. I intentionally haven’t touched them.
  • Entry points in packages/*/*.js redirect to the sources. They are used for Jest and Rollup.
  • Entry points in packages/*/npm/*.js redirect to flat bundles. They are used for npm.
  • For now, you can still use Haste, but I plan to tighten it up (see future work below).
  • Internal fixtures now only work with Yarn, not npm. We depend on it anyway.
  • The +13K line diff is due to a bunch of lockfiles I added to fixtures.

Must Do

  • Move all code
  • Fix the build
  • Update all configs referencing src/
  • Why did some files get lost first time I committed? Any bad gitignores?
  • Fix release script
  • Fix fixtures now that NODE_PATH doesn't work

@gaearon gaearon force-pushed the new-struc branch 7 times, most recently from 712df01 to eae492d Compare October 17, 2017 22:47
@bvaughn bvaughn self-requested a review October 17, 2017 23:02
@gaearon gaearon changed the title [WIP] Move to Yarn Workspaces Use Yarn Workspaces Oct 17, 2017
@@ -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 ||
Copy link
Contributor

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)

Copy link
Collaborator Author

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.)

@gaearon gaearon requested review from bvaughn and trueadm and removed request for bvaughn October 18, 2017 09:56
Copy link
Contributor

@trueadm trueadm left a 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)?

Copy link
Contributor

@bvaughn bvaughn left a 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!


'use strict';

// TODO: This package is a lie. Maybe rename to react-native-renderer?
Copy link
Contributor

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',
Copy link
Contributor

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/*?
Copy link
Contributor

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).
Copy link
Contributor

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.
Copy link
Contributor

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.

@bvaughn bvaughn self-requested a review October 18, 2017 16:56
@gaearon gaearon force-pushed the new-struc branch 2 times, most recently from 5060247 to 228e270 Compare October 18, 2017 22:14
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.
@gaearon gaearon merged commit d9c1dbd into facebook:master Oct 18, 2017
@gaearon gaearon deleted the new-struc branch October 18, 2017 23:22
@blling
Copy link

blling commented Oct 19, 2017

Wow, really a lot of changs, great work!
but why to refrustructure it?

@gaearon
Copy link
Collaborator Author

gaearon commented Oct 19, 2017

So that package boundaries are clearer.

@anhuiliujun
Copy link

great work!

@flaviolivolsi
Copy link

flaviolivolsi commented Oct 21, 2017

I updated reactjs.org docs following this major change in the folder structure, feedbacks and improvements welcome :)

NMinhNguyen referenced this pull request in enzymejs/react-shallow-renderer Jan 29, 2020
* 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants