Skip to content

feat: support ts import type modifiers on import names#28

Closed
haoqunjiang wants to merge 2 commits into
vuejs:mainfrom
haoqunjiang:feat-type-modifier
Closed

feat: support ts import type modifiers on import names#28
haoqunjiang wants to merge 2 commits into
vuejs:mainfrom
haoqunjiang:feat-type-modifier

Conversation

@haoqunjiang

@haoqunjiang haoqunjiang commented Apr 2, 2022

Copy link
Copy Markdown
Member

This feature is introduced in TypeScript 4.5:
https://www.typescriptlang.org/docs/handbook/release-notes/typescript-4-5.html#type-modifiers-on-import-names

And recommended in @vue/tsconfig:
https://github.com/vuejs/tsconfig/blob/26fc528db347dbbbbaa2ea15d3c2d95c197887b7/tsconfig.json#L19-L23

Sucrase does not support it yet:
alangpierce/sucrase#668

So I replaced it with @babel/standalone.
Babel supported the new syntax since v7.16.
So I also updated the project dependencies to ensure that
vue/compiler-sfc can also parse this syntax.

The bundle is a lot bigger after this change:

dist/vue-repl.js   5040.05 KiB / gzip: 840.42 KiB

Before this PR:

dist/vue-repl.js   1011.27 KiB / gzip: 232.21 KiB

But it is still much smaller than the size of a full TypeScript compiler
or esbuild-wasm, which are 9MiB+ in size.

This feature is introduced in TypeScript 4.5:
https://www.typescriptlang.org/docs/handbook/release-notes/typescript-4-5.html#type-modifiers-on-import-names

And recommended in `@vue/tsconfig`:
https://github.com/vuejs/tsconfig/blob/26fc528db347dbbbbaa2ea15d3c2d95c197887b7/tsconfig.json#L19-L23

Sucrase does not support it yet:
alangpierce/sucrase#668

So I replaced it with `@babel/standalone`.
Babel supported the new syntax since v7.16.
So I also updated the project dependencies to ensure that
`vue/compiler-sfc` can also parse this syntax.

The bundle is a lot bigger after this change:
```
dist/vue-repl.js   5040.05 KiB / gzip: 840.42 KiB
```

But it is still much smaller than the size of a full TypeScript compiler
or `esbuild-wasm`, which are 9MiB+ in size.
@yyx990803

Copy link
Copy Markdown
Member

Babel is huge and slow... maybe we should consider using esbuild-wasm instead

@haoqunjiang

Copy link
Copy Markdown
Member Author

esbuild-wasm has a 9.79MB binary… https://unpkg.com/browse/esbuild-wasm@0.14.39/

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants