-
-
Notifications
You must be signed in to change notification settings - Fork 130
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 Rollup for tests and examples #348
Conversation
Thanks for submitting your first pull request! You are awesome! 🤗 |
I'm opening this draft pull request with one package in order to catch any problems before extending to all of the other packages. I will soon also convert a single example from the examples folder to use rollup instead of webpack. |
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.
done self-reviewing
@@ -26,9 +26,9 @@ | |||
"api": "api-extractor run --local --verbose", | |||
"build": "npm run build:src && rollup -c", | |||
"build:src": "tsc --build", | |||
"build:test": "tsc --build tests && cd tests && webpack", | |||
"build:test": "npm run clean:test && tsc --build tests && cd tests && rollup -c", |
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 clean be part of the build step? If you don't run clean and delete the tests/tsconfig.tsbuildinfo
file then the build step will do nothing.
packages/algorithm/package.json
Outdated
"clean": "rimraf ./lib && rimraf *.tsbuildinfo && rimraf ./types && rimraf ./dist", | ||
"clean:test": "rimraf tests/build", | ||
"clean:test": "rimraf tests/lib && rimraf tests/tsconfig.tsbuildinfo", |
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.
Must delete the .tsbuildinfo
file or else the build command will do nothing.
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.
Done self-reviewing second commit (example-accordionpanel
)
@@ -1188,6 +1188,14 @@ | |||
estree-walker "^1.0.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.
All yarn.lock
changes should be related to the changes in the package.json files in this PR.
@@ -26,9 +26,9 @@ | |||
"api": "api-extractor run --local --verbose", | |||
"build": "npm run build:src && rollup -c", | |||
"build:src": "tsc --build", | |||
"build:test": "tsc --build tests && cd tests && webpack", | |||
"build:test": "npm run clean:test && tsc --build tests && cd tests && rollup -c", |
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 wasn't sure if I should add clean:test
here, but without it the build:test
script/command is not idempotent because it creates a tsconfig.tsbuildinfo
file, which I found prevents a second run of the build:test
command from picking up intervening changes in the test code.
Thanks @blink1073 for reviewing the test-related Rollup changes. I feel confident now extending my changes in @lumino/algorithm tests to the other packages' tests in the 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.
Thanks a lot @gabalafou
I added some suggestions before you move forward.
@@ -7400,6 +7509,13 @@ rollup@^2.77.2: | |||
optionalDependencies: | |||
fsevents "~2.3.2" | |||
|
|||
rollup@^2.77.3: |
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.
Before merging, we should check that this entry disappears as it should merge with the previous one. But it is not a blocker.
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.
Nope. Still hasn't disappeared.
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.
When I added Rollup to the package.json file for each example, it set: "rollup": "^2.77.3"
.
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.
Would you mind running yarn why rollup
to find why we have two versions?
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.
Here is my console log for yarn why rollup
:
yarn why rollup rollup
yarn why v1.22.19
[1/4] 🤔 Why do we have the module "rollup"...?
[2/4] 🚚 Initialising dependency graph...
[3/4] 🔍 Finding dependency...
[4/4] 🚡 Calculating file sizes...
=> Found "rollup@2.77.2"
info Has been hoisted to "rollup"
info Reasons this module exists
- "workspace-aggregator-511ef2db-8ac6-4e9e-8474-e5094676397f" depends on it
- Hoisted from "_project_#@lumino#algorithm#rollup"
- Hoisted from "_project_#@lumino#application#rollup"
- Hoisted from "_project_#@lumino#collections#rollup"
- Hoisted from "_project_#@lumino#commands#rollup"
- Hoisted from "_project_#@lumino#coreutils#rollup"
- Hoisted from "_project_#@lumino#datagrid#rollup"
- Hoisted from "_project_#@lumino#disposable#rollup"
- Hoisted from "_project_#@lumino#domutils#rollup"
- Hoisted from "_project_#@lumino#dragdrop#rollup"
- Hoisted from "_project_#@lumino#keyboard#rollup"
- Hoisted from "_project_#@lumino#messaging#rollup"
- Hoisted from "_project_#@lumino#polling#rollup"
- Hoisted from "_project_#@lumino#properties#rollup"
- Hoisted from "_project_#@lumino#signaling#rollup"
- Hoisted from "_project_#@lumino#virtualdom#rollup"
- Hoisted from "_project_#@lumino#widgets#rollup"
info Disk size without dependencies: "6.43MB"
info Disk size with unique dependencies: "6.43MB"
info Disk size with transitive dependencies: "6.43MB"
info Number of shared dependencies: 0
=> Found "@lumino/example-accordionpanel#rollup@2.77.3"
info This module exists because "_project_#@lumino#example-accordionpanel" depends on it.
info Disk size without dependencies: "6.43MB"
info Disk size with unique dependencies: "6.43MB"
info Disk size with transitive dependencies: "6.43MB"
info Number of shared dependencies: 0
=> Found "@lumino/example-datagrid#rollup@2.77.3"
info This module exists because "_project_#@lumino#example-datagrid" depends on it.
info Disk size without dependencies: "6.43MB"
info Disk size with unique dependencies: "6.43MB"
info Disk size with transitive dependencies: "6.43MB"
info Number of shared dependencies: 0
=> Found "@lumino/example-dockpanel#rollup@2.77.3"
info This module exists because "_project_#@lumino#example-dockpanel" depends on it.
info Disk size without dependencies: "6.43MB"
info Disk size with unique dependencies: "6.43MB"
info Disk size with transitive dependencies: "6.43MB"
info Number of shared dependencies: 0
✨ Done in 0.85s.
Co-authored-by: Frédéric Collonval <fcollonval@users.noreply.github.com>
@fcollonval, could you take a look at my last commit add2f47, is it something like what you had imagined? One question I have: should I move all of the rollup dependencies (the plugins) out of the various |
rollup.examples.config.js
Outdated
import nodeResolve from '@rollup/plugin-node-resolve'; | ||
import styles from 'rollup-plugin-styles'; | ||
|
||
const globals = id => |
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 copied this line from rollup.src.config because it fixed a warning or error message that I saw from the rollup
command.
@gabalafou it is better to let them in each package where they are used. |
import nodeResolve from '@rollup/plugin-node-resolve'; | ||
import styles from 'rollup-plugin-styles'; | ||
|
||
export const globals = id => |
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.
There's something I find a bit counter-intuitive about these base config files. For example, I tripped up here because I thought I could replace this line with an import like so:
import { globals } from './rollup.src.config';
But that caused the build script in the examples to fail. That's because importing from that other Rollup config brought along its dependencies, which are not included in the package.json for each of the example packages. In other words, for example, rollup-plugin-postcss
is not included as a dependency for any of the example-* packages, but is a dependency in the other 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.
This is expected - a solution would be to define a base config that only uses common dep. But here this is probably not worth the trouble just for the globals
definition.
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.
Thanks @gabalafou
We only have to figure out why there are still two versions of rollup in the yarn.lock. And we should be good to go.
@@ -7400,6 +7509,13 @@ rollup@^2.77.2: | |||
optionalDependencies: | |||
fsevents "~2.3.2" | |||
|
|||
rollup@^2.77.3: |
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.
Would you mind running yarn why rollup
to find why we have two versions?
import nodeResolve from '@rollup/plugin-node-resolve'; | ||
import styles from 'rollup-plugin-styles'; | ||
|
||
export const globals = id => |
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 expected - a solution would be to define a base config that only uses common dep. But here this is probably not worth the trouble just for the globals
definition.
Kicking the CI |
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.
thanks a lot @gabalafou
Closes #332.
Test plan
For each package, for example @lumino/algorithm:
cd packages/algorithm yarn build:test yarn test:firefox yarn test:firefox-headless yarn test:chrome yarn test:chrome-headless
One way to check that each package (not examples, not tests) builds exactly the same as before is to build the packages from the main branch, then build them with this PR and compare the two. You can leverage git to do it:
You'll see that the bundles for the examples and the tests have changed. That's to be expected because they were previously built with Webpack. But you shouldn't see any differences for the main packages, which were built with Rollup before this PR (and are still built with Rollup after this PR).