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: speed up the TypeScript transpilation when using webpack #735

Merged
merged 1 commit into from May 26, 2020

Conversation

tinogo
Copy link
Contributor

@tinogo tinogo commented May 25, 2020

Disable the type-checking while transpiling the TS files, as the ForkTsCheckerWebpackPlugin
is already handling this within another process

PR Checklist

Please check if your PR fulfills the following requirements:

PR Type

What kind of change does this PR introduce?

[ ] Bugfix
[ ] Feature
[ ] Code style update (formatting, local variables)
[ ] Refactoring (no functional changes, no api changes)
[x] Build related changes
[ ] CI related changes
[ ] Other... Please describe:

What is the current behavior?

Run nest build for a webpack based Nest.js-CLI project (it should be considerably big).

Issue Number: N/A

What is the new behavior?

With ts-loaders transpileOnly-flag set to true, the transpilation process gets a serious speed up, as it disables the type-checking while transpiling the sources.
It is still safe to do this, as the type checking takes place in another process using the ForkTsCheckerWebpackPlugin.

Does this PR introduce a breaking change?

[ ] Yes
[x] No

Other information

Disable the type-checking while transpiling the TS files, as the ForkTsCheckerWebpackPlugin
is already handling this within another process
@tinogo
Copy link
Contributor Author

tinogo commented May 25, 2020

Just to give you some numbers:
For our project at work, this change halves the time at takes to bundle the app.
The initial compilation drops from ca. 35 sec. to 17-18 sec. :)

@tinogo tinogo changed the title build: speed up the TypeScript transpilation build: speed up the TypeScript transpilation when using webpack May 25, 2020
@kamilmysliwiec
Copy link
Member

Thank you @tinogo!

@kamilmysliwiec kamilmysliwiec merged commit 05c2e8b into nestjs:master May 26, 2020
@tblue1994
Copy link

Looks like this change breaks the nestjs swagger plugin's ability to automatically resolve circular dependencies. When we upgraded to 7.2.0, we started getting the following error:

UnhandledPromiseRejectionWarning: Error: A circular dependency has been detected (property key: "statuses"). Please, make sure that each side of a bidirectional relationships are using lazy resolvers ("type: () => ClassType").

However, this was working in 7.1.5, and if I manually turn transpileOnly off, the app will start.

@kamilmysliwiec
Copy link
Member

@tblue1994 can you please create a separate issue in @nestjs/swagger with a minimum reproduction repo?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants