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

feat(compiler-sfc): support import attributes and using syntax in TS #8786

Merged
merged 3 commits into from
Dec 8, 2023

Conversation

sxzz
Copy link
Member

@sxzz sxzz commented Jul 14, 2023

upgrade babel, add importAttributes and explicitResourceManagement for parser plugins.
TypeScript 5.2 already supports these syntaxes.

relate microsoft/TypeScript#53656

Example

import json from "./foo.json" with { type: "json" }
import json from "./foo.json" assert { type: "json" } // deprecated & legacy syntax
using foo = useFoo()

@sxzz sxzz requested a review from yyx990803 July 14, 2023 17:23
@sxzz sxzz added the ready to merge The PR is ready to be merged. label Jul 14, 2023
@sxzz sxzz changed the title feat: support import attributes syntax feat(compiler-sfc): support import attributes syntax Jul 14, 2023
@github-actions
Copy link

github-actions bot commented Aug 21, 2023

Size Report

Bundles

File Size Gzip Brotli
runtime-dom.global.prod.js 85.9 kB 32.6 kB 29.5 kB
vue.global.prod.js 132 kB 49.3 kB 44.4 kB

Usages

Name Size Gzip Brotli
createApp 47.9 kB 18.8 kB 17.2 kB
createSSRApp 50.6 kB 19.9 kB 18.2 kB
defineCustomElement 50.3 kB 19.6 kB 17.9 kB
overall 61.2 kB 23.7 kB 21.6 kB

@sxzz sxzz changed the title feat(compiler-sfc): support import attributes syntax feat(compiler-sfc): support import attributes and with syntax Aug 26, 2023
@sxzz sxzz changed the title feat(compiler-sfc): support import attributes and with syntax feat(compiler-sfc): support import attributes and using syntax in TS Aug 26, 2023
@sxzz sxzz changed the base branch from main to minor October 20, 2023 09:09
plugins.push(['typescript', { dts }])
plugins.push(['typescript', { dts }], 'explicitResourceManagement')
if (!plugins.includes('importAssertions')) {
plugins.push(['importAttributes', { deprecatedAssertSyntax: true }])
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why support the deprecated syntax here?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Currently in typescript@5.2 only support import assert syntax (deprecatedAssertSyntax). In ts@5.3 it support both.

Copy link
Member

@yyx990803 yyx990803 Oct 20, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should only support the latest version.

Also, the includes check should also check importAttributes? This way the user can override the default by specifying importAttributes with their own options, if needed.

Copy link
Member Author

@sxzz sxzz Oct 20, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The latest version of TypeScript is 5.2, and 5.3 will be released on 2023-11-14, which is less than one month (and the beta version is already released). Vue 3.4 stable could be likely later than it.

@yyx990803
Copy link
Member

yyx990803 commented Dec 8, 2023

Made a few adjustments in efddf96:

  • importAttributes should apply to plain JS as well, not just TS.
  • Use latest importAttributes by default (no deprecated syntax support) now that TS 5.3 is already out.
  • Users can override the internal importAttributes plugin with their own to enable the deprecated syntax.
  • rewriteDefault should also go through the same plugin resolution.

@yyx990803 yyx990803 merged commit 5b2bd1d into minor Dec 8, 2023
6 checks passed
@yyx990803 yyx990803 deleted the feat/ts-assert branch December 8, 2023 07:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ready to merge The PR is ready to be merged. version: minor
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

2 participants