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 SWC as compiler #9216
Closed
stevefan1999-personal
wants to merge
12
commits into
typeorm:master
from
stevefan1999-personal:patch-swc
Closed
Use SWC as compiler #9216
stevefan1999-personal
wants to merge
12
commits into
typeorm:master
from
stevefan1999-personal:patch-swc
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Signed-off-by: Steve Fan <29133953+stevefan1999-personal@users.noreply.github.com>
Signed-off-by: Steve Fan <29133953+stevefan1999-personal@users.noreply.github.com>
gulp: prepend shebang for cli transpiled file; gulp: fix parallel build; Signed-off-by: Steve Fan <29133953+stevefan1999-personal@users.noreply.github.com>
Signed-off-by: Steve Fan <29133953+stevefan1999-personal@users.noreply.github.com>
since we can directly use typescript in mocha now, and swc-node/register supports tsconfig path Signed-off-by: Steve Fan <29133953+stevefan1999-personal@users.noreply.github.com>
Signed-off-by: Steve Fan <29133953+stevefan1999-personal@users.noreply.github.com>
Signed-off-by: Steve Fan <29133953+stevefan1999-personal@users.noreply.github.com>
Signed-off-by: Steve Fan <29133953+stevefan1999-personal@users.noreply.github.com>
Test seems to be blocked by swc-project/swc#5047, but I've pinned the last version that can work with circular imports. |
Signed-off-by: Steve Fan <29133953+stevefan1999-personal@users.noreply.github.com>
Signed-off-by: Steve Fan <29133953+stevefan1999-personal@users.noreply.github.com>
blocked by swc-project/swc#5252 Signed-off-by: Steve Fan <29133953+stevefan1999-personal@users.noreply.github.com>
Signed-off-by: Steve Fan <29133953+stevefan1999-personal@users.noreply.github.com>
I don't think I want to switch out of |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description of change
This PR will replace tsc with swc, that the responsibility of tsc will be to emit declarations only. SWC is the fastest Typescript transpiler that supports decorators, and because it is written in Rust, making it virtually zero transpilation turnaround time compared to
ts-node
, and can be seamlessly integrated into Mocha as well using@swc-node/register
without needing to prebuild as well. You can now just click the test run button in either VSCode or IDEA to get direct test result. This also means we can use Typescriptpaths
to infer the location of our source code. I have also did a preliminary replacement of../../../src
and such totypeorm
instead which resulted in a huge diff in the PR.Also, by switching the build responsibility to a set of new
npm run
commands that invokes SWC, this also means you can now save at least 3x time in Gulp that now we lowered it down to around 20 seconds, which is before at least 1 minute. Keep in mind that SWC does have some slight semantic difference compared to the emission of TSC, which is now discovered in some of the tests: ironically speaking, there are unintentional bugs inside tests due to implementation difference between CommonJS and ES modules though.Bug #1: Cyclic import
Solution: Lazy initialization by amalgamated export. POC:
Pull-Request Checklist
master
branchnpm run format
to apply prettier formattingnpm run test
passes with this changeFixes #0000