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

Yarn v3 upgrade fixes #4029

Merged
merged 14 commits into from
Jul 18, 2022
Merged

Yarn v3 upgrade fixes #4029

merged 14 commits into from
Jul 18, 2022

Conversation

IgorNadj
Copy link
Contributor

@IgorNadj IgorNadj commented Jul 14, 2022

Followup fixes to yarn v1 -> v3 upgrade #3994

  • Cleans up __tests__ dirs for consistency
  • Upgrade nohoist for meditrak-app
  • Move default babel config flags to base package:build:js script
  • Each package cleans their dist before building
  • Use standard test runners and builders for consistency

IgorNadj added 5 commits July 14, 2022 13:07
testUtilities are used by other packages, so should be compiled into dist, __tests__ should not be in dist
Previous way of defining ignored paths in build flags no longer works in yarn 3 way.
Moved ignore paths to .babelrc files
Make it consistent with all other ts packages
Copy link
Contributor

@biaoli0 biaoli0 left a comment

Choose a reason for hiding this comment

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

LGTM! Seems like there is a testing error in web-config-server from codeship, wanna have a quick fix?

@IgorNadj IgorNadj changed the title Remove tests from dist Yarn v3 upgrade fixes Jul 15, 2022
@@ -34,7 +34,7 @@
"test-all": "node ./scripts/node/testAll --silent",
"validate": "./scripts/bash/validate.sh",
"package:build:ts": "cd $INIT_CWD && tsc -p tsconfig-build.json",
"package:build:js": "cd $INIT_CWD && babel src --out-dir dist --source-maps --config-file \"../../babel.config.json\"",
"package:build:js": "cd $INIT_CWD && babel src --out-dir dist --source-maps --config-file \"../../babel.config.json\" --copy-files --no-copy-ignored --ignore \"**/__tests__\",\"**/__mocks__\"",
Copy link
Contributor Author

Choose a reason for hiding this comment

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

These flags are the default now

@@ -15,7 +15,7 @@
"types": "dist/index.d.ts",
"private": true,
"scripts": {
"build": "npm run --prefix ../../ package:build:ts",
"build": "rm -rf dist && npm run --prefix ../../ package:build:ts",
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Every package cleans their dist before building to avoid issues with stale files

"build:types": "npm run --prefix ../../ package:build:types",
"build-dev": "npm run build",
"test": "nyc --reporter=lcov mocha",
"test-coverage": "cross-env NODE_ENV=test nyc mocha"
"test": "yarn package:test",
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Use standard test runner (jest) instead of mocha

@@ -13,7 +13,7 @@
"types": "dist/index.d.ts",
"scripts": {
"build": "rm -rf dist && run-p -c \"build:* {@}\" --",
"build:src": "yarn package:build:js --ignore \"**src/database/migrations\",\"src/tests/**\" --copy-files --no-copy-ignored",
"build:src": "yarn package:build:js",
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Uses standard build. The ignore flags are different... so central server outputs test files and migrations to dist now, but it shouldn't be too much of an issue since central-server is never imported by another package.

Copy link
Contributor

Choose a reason for hiding this comment

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

Can we ignore them to make the bundle file smaller?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I came back to this with a fresh head and moved these flags to the .babelrc.js file. This way we can use the standard build script as well as customise the build babel config for central-server.

We are now back to 9MB builds, 3MB smaller (same as dev), and as fast as dev.

@@ -0,0 +1 @@
nmHoistingLimits: workspaces
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixes an issue Andrew found with building meditrak-app locally.
Screen Shot 2022-07-15 at 1 23 06 PM

yarn v3 doesn't support nohoist, but instead we have to say don't hoist anything.

@@ -20,4 +20,4 @@ export {
} from './orchestrator';
export * from './types';
export * from './models';
export { TestableServer } from './__tests__/utilities';
export { TestableServer } from './testUtilities';
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Moved testUtilities out of __tests__ because __tests__ doesn't get ouput into dist, and other packages need these testUtilities.

@@ -12,7 +12,7 @@
"main": "dist/index.js",
"types": "dist/index.d.ts",
"scripts": {
"build": "rm -rf dist && tsc",
"build": "rm -rf dist && npm run --prefix ../../ package:build:ts",
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Use standard ts build script

@@ -4,8 +4,11 @@
*
*/

import { parseChartConfig } from '../parseChartConfig';
import { CHART_COLOR_PALETTE, EXPANDED_CHART_COLOR_PALETTE } from '../constants';
import { parseChartConfig } from '../../../components/Chart/parseChartConfig';
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Update ui-components folder structure to put all tests under __tests__ instead of alongside each component for consistency with all other packages.

"build:types": "npm run --prefix ../../ package:build:types",
"build-dev": "npm run build",
"test": "nyc --reporter=lcov mocha",
"test-coverage": "cross-env NODE_ENV=test nyc mocha"
"test": "yarn package:test",
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Use standard test runner

@IgorNadj
Copy link
Contributor Author

IgorNadj commented Jul 15, 2022

@billli0 Went too far in my original changes, had to roll back some packages. I was hoping we could get our old packages like web-config-server to use the normal build and test configs, but they have special needs so I rolled them back to use their old custom build and test scripts. Ready for re-review.

@IgorNadj IgorNadj requested a review from biaoli0 July 15, 2022 06:12
Copy link
Contributor

@biaoli0 biaoli0 left a comment

Choose a reason for hiding this comment

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

New changes look good, thanks for the fix. Definitely it would be nice to have web-config-server updated to be more standardised as other packages.
You mentioned the web-config-server have its own needs, what would that be? Will it be a big one for us the refactor?

@IgorNadj
Copy link
Contributor Author

New changes look good, thanks for the fix. Definitely it would be nice to have web-config-server updated to be more standardised as other packages. You mentioned the web-config-server have its own needs, what would that be? Will it be a big one for us the refactor?

There are still a few packages that use mocha. To get these to use the standard test runner (jest) we will need to go through all tests and migrate them, some of the syntax is different, like expect().to.be instead of expect().toBe or something like that. Not too big but I thought it is probably out of scope for this PR.

IgorNadj added 2 commits July 18, 2022 15:01
Go back to ignoring test,migration files for building
@biaoli0
Copy link
Contributor

biaoli0 commented Jul 18, 2022

There are still a few packages that use mocha. To get these to use the standard test runner (jest) we will need to go through all tests and migrate them, some of the syntax is different, like expect().to.be instead of expect().toBe or something like that. Not too big but I thought it is probably out of scope for this PR.

Yeah I'm just a little bit curious. It is definitely out of scope.
I was working on web-config-server unit test and I'm not really satisfied with mocha.. I have some interest to migrate that, will see how that goes.

@IgorNadj IgorNadj merged commit ad9f0a7 into dev Jul 18, 2022
@IgorNadj IgorNadj deleted the remove-tests-from-dist branch July 18, 2022 05:59
@IgorNadj IgorNadj mentioned this pull request Jul 18, 2022
@biaoli0 biaoli0 mentioned this pull request Jul 25, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants