-
Notifications
You must be signed in to change notification settings - Fork 841
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
feat: hello, monorepo! #7736
feat: hello, monorepo! #7736
Conversation
d4f12cc
to
b90ae15
Compare
We should update https://github.com/elastic/eui/blob/main/wiki/contributing-to-eui/running-eui-locally.md to indicate at the top that everything is relative to the |
package.json
Outdated
"version": "1.0.0", | ||
"description": "Elastic Design System", | ||
"scripts": { | ||
"pre-push": "yarn --cwd packages/eui pre-push" |
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.
Can you explain why pre-push is kept at the project root?
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.
The way pre-push npm dependencies work is they replace the original (usually empty) .git/hooks/pre-push
file with their script calling a Node.js script handling executing scripts defined in package.json
and similar. There's one gotcha with this behavior - if a monorepo has multiple of these pre-push "managers" configured to initialize on yarn install
, they'll override each other. That's why I opted for a single, root-defined pre-push
library that will call child packages (like packages/eui
or packages/website
) instead.
@@ -0,0 +1,19 @@ | |||
{ | |||
"name": "@elastic/eui-monorepo", |
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.
Can you also explain why yarn.lock
needs to be at the root level?
It would seem to me that it must be at the same level as the package.json file. Otherwise, I don't understand how packages are properly kept isolated from one another. Theoretically, different packages could have different versions of different dependencies, and wouldn't a single yarn.lock file mess that up?
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.
From what I read all dependencies are hoisted to the root level and yarn workspaces requires a single yarn.lock
at the root, does that sound correct?
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.
That's correct! There can be only one yarn.lock
per project, and our project is now defined by the root-level private package. Yarn uses hoisting to store the dependencies at the root level and reuse them for all packages within the whole monorepo (assuming the semver of these packages matches).
There's a way to opt-out from this hoisting behavior in case of dependencies that specifically require being stored at the correct node_modules
directory, e.g., eslint-plugin-local
(it cannot resolve the correct .eslintplugin.js
when stored in the root node_modules
dir) or stylelint
(it cannot resolve customSyntax
dependencies).
yarn.lock
Outdated
resolved "https://registry.yarnpkg.com/react-focus-lock/-/react-focus-lock-2.9.5.tgz#8a82f4f0128cccc27b9e77a4472e8a22f1b52189" | ||
integrity sha512-h6vrdgUbsH2HeD5I7I3Cx1PPrmwGuKYICS+kB9m+32X/9xHRrAbxgvaBpG7BFBN9h3tO+C3qX1QAVESmi4CiIA== | ||
react-focus-lock@^2.9.4, react-focus-lock@^2.9.5: | ||
version "2.12.1" |
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.
Did you intend to update these version in yarn.lock?
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 was updated when I corrected the resolutions
field by moving it back to the root-level package.json
. I realized it doesn't work when defined at package level (e.g., packages/eui
).
The commit message of 14af611 explains that :)
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.
OK. I didn't really gather that from the commit message. So it is OK that our yarn.lock file is updating from the current version of 2.9.5
to 2.12.1
?
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.
You were right, this minor version bump caused that cypress test to fail. I fixed it in 03f8dc9
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 Snyk upgrade PR is related to this issue
Have you tested the publishing process yet? |
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
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.
Looks like everything is working well so this LGTM. Any idea why we have failing tests? Not sure if it could be related to the react-focus-on
update?
1) Cell focus utils
--
| correctly toggles the header cell actions on focus when tabbing back into the datagrid:
|
| Timed out retrying after 4000ms
| + expected - actual
|
| -'dataGridKeyboardShortcutsButton'
| +'dataGridHeaderCellActionButton-column'
|
| at assertFocusedHeaderActions (webpack://@elastic/eui/./src/components/datagrid/body/cell/focus_utils.spec.tsx:195:19)
| at Context.<anonymous> (webpack://@elastic/eui/./src/components/datagrid/body/cell/focus_utils.spec.tsx:222:4)
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.
Actually going to remove my approvals until we get the failing specs figured out
d408a55
to
c50ca1d
Compare
@JasonStoltz I updated |
…when testing and building EUI
…irectory for correct dependency version resolution
…curately on package level
…dcoded `../../.eslintplugin.js` module resolution
…tom syntax rules can be resolved properly
…n build` and `yarn start`
4ef8ba4
to
b817ed2
Compare
"pre-push": "yarn --cwd packages/eui pre-push" | ||
"pre-push": "yarn --cwd packages/eui pre-push", | ||
"preinstall": "echo \"\\x1b[K\\x1b[37;41mWarning: EUI has recently migrated to a monorepo structure. Please run EUI scripts like \\x1b[1;4myarn start\\x1b[0m\\x1b[37;41m or \\x1b[1;4myarn build\\x1b[0m\\x1b[37;41m from the \\x1b[1;4mpackages/eui\\x1b[0m\\x1b[37;41m directory instead!\n\nIf this is the first time you're running EUI after the monorepo migration, please run this first from the root repository's directory to clean up your local environment:\n \\x1b[1;4mrm -rf node_modules .cache-loader dist es lib optimize test-env types .eslintcache eui.d.ts && yarn\\x1b[0m\\x1b[37;41m\n\nInstall process will continue in 10 seconds...\\x1b[0m\"; sleep 10", | ||
"start": "echo '\\x1b[K\\x1b[37;41mPlease run this script from the \\x1b[1;4mpackages/eui\\x1b[0m\\x1b[37;41m directory instead\\x1b[0m'; exit 1", |
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.
Really nice thinking to add a warning here 🎉 Worked like a charm and caught me doing silly things! 🐟
Awesome work on the monorepo setup! 🎉
|
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.
LGTM
Preview staging links for this PR:
|
💚 Build Succeeded
History
cc @tkajtoch |
Summary
This PR moves all EUI source files to
packages/eui
(includingsrc-docs
) and enables yarn workspaces to link local versions of all EUI packages - which is currently one 🤣I recommend reviewing commit per commit due to Github's inefficiency in rendering lots of file moves.
The goal of this change is to allow the separation of EUI components into their own small packages in the (near) future. This has many benefits like independent versioning possibility, increased performance and developer experience, separation of concerns, and more.
QA
This PR should be reviewed as a major dependency upgrade due to the possibility of affecting dependency resolution.
packages/eui
yarn build
and ensure EUI builds with no errorsyarn test-unit
andyarn test-cypress
and ensure EUI passes all testsyarn lint
and ensure all lining tools work and the code passes testsyarn start
, wait for it to build, visit http://localhost:8030 and test the docs site works as expectedGeneral checklist
@default
if default values are missing) and playground toggles