From 16c7d0bfd49d2b9bfae45385f506bcd642f9444a Mon Sep 17 00:00:00 2001 From: Bjorn Lu Date: Wed, 4 Jan 2023 04:38:51 +0800 Subject: [PATCH] Cleanup internal breaking changes (#5724) * Remove Astro.glob template literal trick * Remove RenderTemplateResult toString * Remove astro add volar warning * Add changeset --- .changeset/serious-cats-jog.md | 5 +++++ packages/astro/src/core/add/index.ts | 22 +------------------ .../server/render/astro/render-template.ts | 5 ----- .../vite-plugin-astro-postprocess/index.ts | 8 +------ 4 files changed, 7 insertions(+), 33 deletions(-) create mode 100644 .changeset/serious-cats-jog.md diff --git a/.changeset/serious-cats-jog.md b/.changeset/serious-cats-jog.md new file mode 100644 index 000000000..467424a19 --- /dev/null +++ b/.changeset/serious-cats-jog.md @@ -0,0 +1,5 @@ +--- +'astro': major +--- + +Remove outdated Vue info log. Remove `toString` support for `RenderTemplateResult`. diff --git a/packages/astro/src/core/add/index.ts b/packages/astro/src/core/add/index.ts index 536cbe2f9..fd7d66d15 100644 --- a/packages/astro/src/core/add/index.ts +++ b/packages/astro/src/core/add/index.ts @@ -801,7 +801,7 @@ async function updateTSConfig( // Every major framework, apart from Vue and Svelte requires different `jsxImportSource`, as such it's impossible to config // all of them in the same `tsconfig.json`. However, Vue only need `"jsx": "preserve"` for template intellisense which - // can be compatible with some frameworks (ex: Solid), though ultimately run into issues on the current version of Volar + // can be compatible with some frameworks (ex: Solid) const conflictingIntegrations = [...Object.keys(presets).filter((config) => config !== 'vue')]; const hasConflictingIntegrations = integrations.filter((integration) => presets.has(integration)).length > 1 && @@ -821,26 +821,6 @@ async function updateTSConfig( ); } - // TODO: Remove this when Volar 1.0 ships, as it fixes the issue. - // Info: https://github.com/johnsoncodehk/volar/discussions/592#discussioncomment-3660903 - if ( - integrations.includes('vue') && - hasConflictingIntegrations && - ((outputConfig.compilerOptions?.jsx !== 'preserve' && - outputConfig.compilerOptions?.jsxImportSource !== undefined) || - integrations.includes('react')) // https://docs.astro.build/en/guides/typescript/#vue-components-are-mistakenly-typed-by-the-typesreact-package-when-installed - ) { - info( - logging, - null, - red( - ` ${bold( - 'Caution:' - )} Using Vue together with a JSX framework can lead to type checking issues inside Vue files.\n More information: https://docs.astro.build/en/guides/typescript/#vue-components-are-mistakenly-typed-by-the-typesreact-package-when-installed\n` - ) - ); - } - if (await askToContinue({ flags })) { await fs.writeFile(inputConfig?.path ?? path.join(cwd, 'tsconfig.json'), output, { encoding: 'utf-8', diff --git a/packages/astro/src/runtime/server/render/astro/render-template.ts b/packages/astro/src/runtime/server/render/astro/render-template.ts index 66930594b..fc1442422 100644 --- a/packages/astro/src/runtime/server/render/astro/render-template.ts +++ b/packages/astro/src/runtime/server/render/astro/render-template.ts @@ -32,11 +32,6 @@ export class RenderTemplateResult { }); } - // TODO this is legacy and should be removed in 2.0 - get [Symbol.toStringTag]() { - return 'AstroComponent'; - } - async *[Symbol.asyncIterator]() { const { htmlParts, expressions } = this; diff --git a/packages/astro/src/vite-plugin-astro-postprocess/index.ts b/packages/astro/src/vite-plugin-astro-postprocess/index.ts index 435457a5d..0fa4032e3 100644 --- a/packages/astro/src/vite-plugin-astro-postprocess/index.ts +++ b/packages/astro/src/vite-plugin-astro-postprocess/index.ts @@ -46,13 +46,7 @@ export default function astro(_opts: AstroPluginOptions): Plugin { const firstArgStart = node.arguments[0].start; const firstArgEnd = node.arguments[0].end; const lastArgEnd = node.arguments[node.arguments.length - 1].end; - let firstArg = code.slice(firstArgStart, firstArgEnd); - // If argument is template literal, try convert to a normal string. - // This is needed for compat with previous recast strategy. - // TODO: Remove in Astro 2.0 - if (firstArg.startsWith('`') && firstArg.endsWith('`') && !firstArg.includes('${')) { - firstArg = JSON.stringify(firstArg.slice(1, -1)); - } + const firstArg = code.slice(firstArgStart, firstArgEnd); s ??= new MagicString(code); s.overwrite( firstArgStart,