-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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: enable TypeScript project references #5155
Conversation
04fc521
to
e90fad4
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.
Thank you @raymondfeng for starting this initiative, I am looking forward to have project references enabled 👏
Did you run the steps listed in How to test infrastructure changes? Are there any issues to be aware of?
Please make sure to update that section of our dev docs to accurately describe the new setup.
What is the impact of this change on the build time?
- Full build from clean?
npm run clean && time npm run build
- Incremental build after no (or a small) change was made?
time npm run build
With project references in place, we should get rid of top-level manually-written index.js
, index.d.ts
and index.ts
files. Their purpose is to trick IDE into treating the entire monorepo as a single TypeScript project. That's no longer desirable, we want each package to be treated as its own project. Those index files are also causing slow build times. As I shown in #2613, we can speed up our build by getting rid of them.
e90fad4
to
6c9a2f5
Compare
Some smoke test results for performance:
The improvement is significant. |
e5560f2
to
8afd076
Compare
I would like to defer this change to a follow-up PR. One of the caveats listed in the project references is that we have to run |
Yes. I did. |
ef10c7f
to
04728a0
Compare
This is awesome, even better than I expected.
Yeah, I was thinking about deferring this part too. The current PR is large enough, it's better to work incrementally. I am happy to take a look at index changes myself after this PR is landed.
Cool 👏 Did you find any issues? Does everything work as before? |
|
||
/** | ||
* `tsc -b` only accepts valid arguments. `npm run build -- --<other-arg>` may | ||
* pass in extra arguments. We need to remove such arguments. |
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.
What kind of arguments are getting in via npm run build -- --<other-arg>
? If they are provided by the user (either on command line or via their package.json) then we must let them know about the problem and especially which parameters are removed by lb-tsc
.
Personally, I don't think it's a good idea to add such parameter-modifications to lb-tsc
, I am concerned about support and maintenance costs. IMO, we should let tsc
fail the build and expect the user to fix the parameters passed tolb-tsc
/tsc
.
BTW, |
The removal of invalid options is for npm script composition as other npm runs can trigger npm run build but npm always pass extra args to all commands. |
I see, do you have any example? I am concerned that some day, a developer will add a new option to |
It can reproduced by There are |
I'm not sure why Travis build fails for some of the acceptance tests - https://github.com/strongloop/loopback-next/pull/5155/checks?check_run_id=603795936. |
Interesting! I always thought that npm does not pass the extra arguments to
Are you referring to the following line? I find the message rather cryptic, how about something like this: debug('Using the following args for tsc -b', validArgs);
I quickly checked the error log and don't see any obvious problem 🤔 |
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, but we need to fix CI before this can be landed.
- improve package.json to update project refs and clean *.tsbuildinfo - fix travis script to allow `tsc -b`
04728a0
to
649db01
Compare
In #5155, we reworked our typescript setup to leverage composite mode and project references. This breaks our example applications when they are checked out standalone, typically via `lb4 example`. ```sh $ lb4 example todo (...) $ cd loopback4-example-todo $ npm t (...) > lb-tsc error TS6053: File '/private/packages/http-caching-proxy/tsconfig.json' not found. error TS6053: File '/private/packages/testlab/tsconfig.json' not found. (...) Found 10 errors. ``` This commit fixes the problem by introducing a new step to `lb4 example` command where we remove `references` and `compilerOptions.composite` field from `tsconfig.json` file. Signed-off-by: Miroslav Bajtoš <[email protected]>
In #5155, we reworked our typescript setup to leverage composite mode and project references. This breaks our example applications when they are checked out standalone, typically via `lb4 example`. ```sh $ lb4 example todo (...) $ cd loopback4-example-todo $ npm t (...) > lb-tsc error TS6053: File '/private/packages/http-caching-proxy/tsconfig.json' not found. error TS6053: File '/private/packages/testlab/tsconfig.json' not found. (...) Found 10 errors. ``` This commit fixes the problem by introducing a new step to `lb4 example` command where we remove `references` and `compilerOptions.composite` field from `tsconfig.json` file. Signed-off-by: Miroslav Bajtoš <[email protected]>
In #5155, we reworked our typescript setup to leverage composite mode and project references. This breaks our example applications when they are checked out standalone, typically via `lb4 example`. ```sh $ lb4 example todo (...) $ cd loopback4-example-todo $ npm t (...) > lb-tsc error TS6053: File '/private/packages/http-caching-proxy/tsconfig.json' not found. error TS6053: File '/private/packages/testlab/tsconfig.json' not found. (...) Found 10 errors. ``` This commit fixes the problem by introducing a new step to `lb4 example` command where we remove `references` and `compilerOptions.composite` field from `tsconfig.json` file. Signed-off-by: Miroslav Bajtoš <[email protected]>
In #5155, we reworked our typescript setup to leverage composite mode and project references. This breaks our example applications when they are checked out standalone, typically via `lb4 example`. ```sh $ lb4 example todo (...) $ cd loopback4-example-todo $ npm t (...) > lb-tsc error TS6053: File '/private/packages/http-caching-proxy/tsconfig.json' not found. error TS6053: File '/private/packages/testlab/tsconfig.json' not found. (...) Found 10 errors. ``` This commit fixes the problem by introducing a new step to `lb4 example` command where we remove `references` field from `tsconfig.json` file and set the field `compilerOptions.composite` to `false`. Signed-off-by: Miroslav Bajtoš <[email protected]>
In #5155, we reworked our typescript setup to leverage composite mode and project references. This breaks our example applications when they are checked out standalone, typically via `lb4 example`. ```sh $ lb4 example todo (...) $ cd loopback4-example-todo $ npm t (...) > lb-tsc error TS6053: File '/private/packages/http-caching-proxy/tsconfig.json' not found. error TS6053: File '/private/packages/testlab/tsconfig.json' not found. (...) Found 10 errors. ``` This commit fixes the problem by introducing a new step to `lb4 example` command where we remove `references` field from `tsconfig.json` file and set the field `compilerOptions.composite` to `false`. Signed-off-by: Miroslav Bajtoš <[email protected]>
See https://www.typescriptlang.org/docs/handbook/project-references.html
Supersedes #1636
Implements #2609
TypeScript project references seem to be working with latest VSCode now. Please help verify.
Checklist
👉 Read and sign the CLA (Contributor License Agreement) 👈
npm test
passes on your machinepackages/cli
were updatedexamples/*
were updated👉 Check out how to submit a PR 👈