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

fix: use Vite by default for Svelte and Vue #20966

Closed
wants to merge 1 commit into from
Closed
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
17 changes: 9 additions & 8 deletions code/lib/cli/src/automigrate/fixes/new-frameworks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,12 +62,15 @@ interface NewFrameworkRunOptions {
};
}

export const getBuilder = (builder: string | { name: string }) => {
if (typeof builder === 'string') {
return builder.includes('vite') ? 'vite' : 'webpack5';
const getBuilder = (builder: string | { name: string }, frameworkPackage: string) => {
const name = typeof builder === 'string' ? builder : builder?.name;
if (name?.includes('webpack')) {
return 'webpack5';
}

return builder?.name.includes('vite') ? 'vite' : 'webpack5';
if (name?.includes('vite')) {
return 'vite';
}
return frameworkPackage.includes('svelte') || frameworkPackage.includes('vue3') ? 'vite' : 'webpack5';
Copy link
Contributor Author

@benmccann benmccann Feb 7, 2023

Choose a reason for hiding this comment

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

this should probably change from vue3 to vue if #20970 is merged

};

export const getFrameworkOptions = (framework: string, main: ConfigFile) => {
Expand Down Expand Up @@ -140,13 +143,11 @@ export const newFrameworks: Fix<NewFrameworkRunOptions> = {
}

const builderInfo = {
name: getBuilder(builder),
name: getBuilder(builder, frameworkPackage),
options: main.getFieldValue(['core', 'builder', 'options']) || {},
} as const;

const newFrameworkPackage = packagesMap[frameworkPackage][builderInfo.name];

// not all frameworks support vite yet e.g. Svelte
if (!newFrameworkPackage) {
return null;
}
Expand Down