Skip to content

Commit

Permalink
Cleanup internal breaking changes (#5724)
Browse files Browse the repository at this point in the history
* Remove Astro.glob template literal trick

* Remove RenderTemplateResult toString

* Remove astro add volar warning

* Add changeset
  • Loading branch information
bluwy committed Jan 3, 2023
1 parent 4cc8c84 commit 16c7d0b
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 33 deletions.
5 changes: 5 additions & 0 deletions .changeset/serious-cats-jog.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'astro': major
---

Remove outdated Vue info log. Remove `toString` support for `RenderTemplateResult`.
22 changes: 1 addition & 21 deletions packages/astro/src/core/add/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 &&
Expand All @@ -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',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
8 changes: 1 addition & 7 deletions packages/astro/src/vite-plugin-astro-postprocess/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit 16c7d0b

Please sign in to comment.