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

build: Use NPM Workspace instead of Lerna to bootstrap #1142

Merged
merged 15 commits into from
Mar 24, 2023

Conversation

darryltec
Copy link
Contributor

@darryltec darryltec commented Mar 20, 2023

Motivations

Lerna is planning to deprecate bootstrap on their V7 since NPM can do it in a much better way. With the Node 18 upgrade, the need to move has become more apparent since it totally broke the way it worked for us.

Known issues

  • It'll throw a dependency warning and that's related to storybook upgrade. That comes later.

Changes

Added

Changed

  • Switch Lerna magic to NPM Workspace
    • In doing so, we can delete the packages package-lock.json since they're managed on the root now. No more confusing package-lock changes
  • Had to work around NPM's lack of topological order when bootstrapping

Deprecated

Removed

Fixed

Security

Testing

  • Run nvm use
  • Run npm ci successfully with no error. Warning is fine.
  • Run npm start and storybook runs locally

In Atlantis we use Github's built in pull request reviews.

Random photo of Atlantis

JOB-63633

Darryl Tec added 3 commits March 20, 2023 16:23
Basically, npm would run `prepare` on each packages in alphabetical order but components need design to be built first.

This works around that limitation by firing the scripts manually through `npm run [script] -w` which respects the order under `workspaces`

npm/rfcs#548
@cloudflare-workers-and-pages
Copy link

cloudflare-workers-and-pages bot commented Mar 21, 2023

Deploying with  Cloudflare Pages  Cloudflare Pages

Latest commit: 4947ff9
Status:🚫  Build failed.

View logs

@darryltec darryltec force-pushed the use-npm-workspace-instead-of-lerna branch from ea33080 to ef2dba8 Compare March 21, 2023 12:55
@darryltec darryltec force-pushed the use-npm-workspace-instead-of-lerna branch from a595a3a to cf32562 Compare March 21, 2023 13:04
@rodrigoeidelvein
Copy link
Contributor

rodrigoeidelvein commented Mar 22, 2023

@darryltec running npm ci is throwing the following error for me:
npm ERR! Cannot read property '@std-proposal/temporal' of undefined

I deleted all node_modules and I still got the error

nvm, just had to run nvm use, thanks @darryltec

@rodrigoeidelvein
Copy link
Contributor

I think Cloudfare failed because the build command is set to npm run build-storybook instead of storybook:build, we may have to ask @kingstonfung to change it once we land this PR.

@MichaelParadis MichaelParadis self-requested a review March 22, 2023 19:07
@darryltec
Copy link
Contributor Author

@rodrigoeidelvein cloudflare failed becauase it's building on node 18 which it can't haha. Cloudflare fires npm run build

Copy link
Contributor

@rodrigoeidelvein rodrigoeidelvein left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm going to make a list of things that I noticed here, just to see if I understood correctly:

  • Removed the sum_lockfiles because there's no package-lock.json in packages/* anymore? Are they all in the root package-lock?
  • --no-optional == -omit=optional?
  • You reorganized the npm command in the root package.json, and renamed some of them, but the only thing that changed inside the commands is the export NODE_OPTIONS=--openssl-legacy-provider in Storybook?
  • Why did some snapshots change?
  • Loved the bonus refactor on FormatRelativeDateTime tests, was it failing?

@darryltec
Copy link
Contributor Author

  • Removed the sum_lockfiles because there's no package-lock.json in packages/* anymore? Are they all in the root package-lock?

Yup

  • --no-optional == -omit=optional?

Yup

  • You reorganized the npm command in the root package.json, and renamed some of them, but the only thing that changed inside the commands is the export NODE_OPTIONS=--openssl-legacy-provider in Storybook?

Sorted alphabetically. Yes and also this

"postinstall": "npm run bootstrap --workspaces --if-present",

  • Why did some snapshots change?

Normally happens on node update

  • Loved the bonus refactor on FormatRelativeDateTime tests, was it failing?

.forEach on tests removes the ability for the test to run cleanup automatically. Which broke the test. Writing it properly fixes it. And yeah, totally broke and threw weird errors.

Copy link
Contributor

@rodrigoeidelvein rodrigoeidelvein left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Niiiice! Looks good to me!

  • npm ci works
  • storybook runs and builds

I just would like an approval from @MichaelParadis too

@jobbiebot jobbiebot bot added the approved label Mar 24, 2023
Copy link
Contributor

@MichaelParadis MichaelParadis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@darryltec darryltec merged commit 76337c4 into upgrade-to-node-18 Mar 24, 2023
@darryltec darryltec deleted the use-npm-workspace-instead-of-lerna branch March 24, 2023 14:25
darryltec pushed a commit that referenced this pull request Mar 24, 2023
* build: update nvmrc to use 18

* build: repackage package locks

* build: temporarily set legacy-peer-deps to true

* build: Use NPM Workspace instead of Lerna to bootstrap (#1142)

* build: use NPM workspace instead of Lerna

* fix: workaround npm's lack of topological oder

Basically, npm would run `prepare` on each packages in alphabetical order but components need design to be built first.

This works around that limitation by firing the scripts manually through `npm run [script] -w` which respects the order under `workspaces`

npm/rfcs#548

* fix: reorder scripts for my own sanity

* build: update circle to not look for lock files

* build: use node 18 image on circle ci

* fix: js and css linters

* build: use -omit=optional

* fix: update time test work on node 18

* fix: don't update snaps

* fix: update some snaps

* build: make storybook run on node 18

Thanks @rodrigoeidelvein for the workaround!

* fix: reinstall ts-node

* chore: use lerna recommended setting for symlink

* fix: refix storybook by using js file

* fix: match * on preventManualRelease check

* docs: Node 18 update readme (#1149)

* Update versions in readme

* Update engines in package.json

* fix: reset package-lock

* chore: strict engine and package lock

* docs: Fix cloudflare Pages deploy (#1150)

* Trying build

* Correcting variables

* Removed resource class

Co-authored-by: Darryl Tec <darryl.t@getjobber.com>

---------

Co-authored-by: Kingston Fung <kingstonfung@gmail.com>
Co-authored-by: Darryl Tec <darryl.t@getjobber.com>

* fix: update package-lock.json

---------

Co-authored-by: Michael Paradis <michael.p@getjobber.com>
Co-authored-by: Kingston Fung <kingstonfung@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging this pull request may close these issues.

3 participants