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

Cleanup internal breaking changes #5724

Merged
merged 5 commits into from
Jan 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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);
Copy link
Member Author

Choose a reason for hiding this comment

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

The intent here was to remove support for:

Astro.glob(`./foo/*.md`) // using template literals

which transforms to import.meta.glob, but it looks like Vite 4 now supports template literal too so this is no longer a breaking change to note in the changeset.

s ??= new MagicString(code);
s.overwrite(
firstArgStart,
Expand Down