-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
rework build system #9710
rework build system #9710
Conversation
This is especially useful when using the main repo as a submodule for a different repository such as a Theia extension: My approach was to clone Theia as a submodule in the extension repo, then add
This PR also makes developing a bit more comfortable: only the minimal amount of work required is done, if you need more you need to explicitly trigger it. E.g. building a given app, linting, etc... |
618b1c2
to
0762ab1
Compare
This sounds like it goes some way to addressing some of the pain points described in #9153, as well. |
Could you detail in what way it does not play well with |
|
||
## Watching | ||
|
||
### Watch the TypeScript 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.
I'm not sure about the term "typescript packages". What would a non-typescript package be, for example?
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 mostly refers to TypeScript compilation which happens before bundling, so if we have a pure JS extension then there will be nothing to watch.
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 understand TypeScript package
as a package written using TypeScript and requiring transpilation.
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.
So it's really "typescript files", because some packages may container both *.js and *.ts files, right? Also, not sure how that works, exactly, but don't we have to reload the code when *.js files change, as well?
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.
In Theia the watch scripts are related to code transformations. There's basically two steps: TypeScript compilation and Webpack bundling. This documentation refers to the former. JavaScript sources don't require any change during the first step, but bundling still depends on them indeed.
All the times I remember doing Since we migrated to Webpack 5 maybe this won't be an issue anymore... So independently from that, this PR still simplifies the |
5abd78f
to
4f80f9f
Compare
|
||
### Watch the core and extension packages | ||
|
||
To rebuild each time a change is detected run: | ||
To rebuild _everything_ each time a change is detected run: |
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.
"Everything" being both the regular packages and the example applications?
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.
Yes, both steps: TypeScript compilation and the bundling of both examples.
@paul-marechal I'll review this, if you're still interested in getting this merged. Would you mind rebasing and fixing merge conflicts? |
146f79e
to
f899f7f
Compare
@msujew thanks for proposing! I just rebased. edit: I forgot to download the plugins, fixed. |
30ff600
to
637ea3b
Compare
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 really like the proposed changes, especially the newer watch options and the removal of yarn lint
from every build.
I also have an addition to propose: In my usual workflow when working on Theia I needed to start the server/electron app and watch both typescript and webpack. The latter two are now merged using yarn browser watch
and yarn electron watch
. I would like to see the former in there as well. Something like this:
"scripts": {
"start:watch": "concurrently --kill-others -n tsc,bundle,run -c red,yellow,green \"tsc -b -w --preserveWatchOutput\" \"yarn watch:bundle\" \"yarn start\""
}
What's your opinion on that?
fa34aff
to
4d25a63
Compare
Co-authored-by: Mark Sujew <mark.sujew@typefox.io>
cbbb102
to
02aa2e4
Compare
c55af33
to
a3cb5e0
Compare
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.
@paul-marechal Still fine with merging, everything looks good 👍
I'll just wait on CI to turn green... |
Follow up from #9710 When doing refactorings, one might end up renaming/deleting TypeScript source files. But if a build was run previously, the outputted JavaScript files will still be in the build output folder. Then extensions that depend on the refactored package will not fail to build because the old path still resolves to the lingering JavaScript files. Add `ts-clean` script that deletes all generated files without a corresponding source file. Add the missing compile script to most packages.
Really miss the easy |
@thegecko I think you should be able to run |
Confirmed, thanks! |
What it does
Fixes: #7275.
Simplify
scripts/compile-references.js
. TypeScript Server now properlyunderstand TypeScript references for navigation, so we can simplify our
tsconfig
setup.Rewrite some
npm/yarn
scripts to do less on install (yarn
oryarn install
). It will only run the requiredprepare
scripts across ourpackages, wire
tsconfig.json
files and build the TypeScript sources.To build the example applications you need to run one of
yarn browser build
,yarn electron build
oryarn build:examples
.Linting is done as part of CI, but it won't automatically run locally
anymore. You can run
yarn lint
to lint your code. For the bestexperience you should also enable the ESLint extension in your IDE.
How to test
Installation:
yarn
alone should not build the example applications anymore, nor should it lint.Building:
yarn build
should build TypeScript and both apps.yarn compile
should build TypeScript.yarn browser build
should build both TypeScript and the browser app.yarn electron build
should build both TypeScript and the electron app.yarn build:examples
should build both apps.Watching:
yarn watch
should watch TypeScript and both example apps.yarn watch:compile
should watch only TypeScript.yarn browser watch
should watch both TypeScript and the browser app.yarn electron watch
should watch both TypeScript and the electron app.Linting:
yarn lint
should lint TypeScript sources.Review checklist
Reminder for reviewers