-
Notifications
You must be signed in to change notification settings - Fork 56
feat: add sveltekit support #131
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
base: main
Are you sure you want to change the base?
Conversation
|
|
The latest updates on your projects. Learn more about Vercel for GitHub.
1 Skipped Deployment
|
|
Review the following changes in direct dependencies. Learn more about Socket for GitHub.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Additional Comments:
packages/cli/src/lib/config/types.ts (lines 42-46):
The isValidBuildTarget function doesn't include the new 'sveltekit' build target in its validation logic, so users trying to build with --target sveltekit will have their target silently changed to 'standalone'.
View Details
📝 Patch Details
diff --git a/packages/cli/src/commands/build.ts b/packages/cli/src/commands/build.ts
index c9ddaf5..bb23067 100644
--- a/packages/cli/src/commands/build.ts
+++ b/packages/cli/src/commands/build.ts
@@ -1,8 +1,9 @@
import { Args, Flags } from '@oclif/core';
import { BaseCommand } from '../base.js';
+import { NextBuilder } from '../lib/builders/next-build.js';
import { VercelBuildOutputAPIBuilder } from '../lib/builders/vercel-build-output-api.js';
import { StandaloneBuilder } from '../lib/builders/standalone.js';
-import { type BuildTarget, isValidBuildTarget } from '../lib/config/types.js';
+import { type BuildTarget, isValidBuildTarget, validBuildTargets } from '../lib/config/types.js';
import { getWorkflowConfig } from '../lib/config/workflow-config.js';
export default class Build extends BaseCommand {
@@ -18,7 +19,7 @@ export default class Build extends BaseCommand {
target: Flags.string({
char: 't',
description: 'build target',
- options: ['standalone', 'vercel-build-output-api'],
+ options: validBuildTargets,
default: 'standalone',
}),
'workflow-manifest': Flags.string({
@@ -61,7 +62,7 @@ export default class Build extends BaseCommand {
this.logWarn(
`Invalid target "${buildTarget}". Using default "standalone".`
);
- this.logWarn('Valid targets: standalone, vercel-build-output-api');
+ this.logWarn(`Valid targets: ${validBuildTargets.join(', ')}`);
buildTarget = 'standalone';
}
@@ -82,6 +83,14 @@ export default class Build extends BaseCommand {
this.logInfo('Building with VercelBuildOutputAPIBuilder');
const builder = new VercelBuildOutputAPIBuilder(config);
await builder.build();
+ } else if (config.buildTarget === 'next') {
+ this.logInfo('Building with NextBuilder');
+ const builder = new NextBuilder(config);
+ await builder.build();
+ } else if (config.buildTarget === 'sveltekit') {
+ this.logInfo('Building with StandaloneBuilder (SvelteKit support)');
+ const builder = new StandaloneBuilder(config);
+ await builder.build();
} else {
this.error(`Unknown build target: ${config.buildTarget}`);
}
diff --git a/packages/cli/src/lib/config/types.ts b/packages/cli/src/lib/config/types.ts
index b4d729c..a278673 100644
--- a/packages/cli/src/lib/config/types.ts
+++ b/packages/cli/src/lib/config/types.ts
@@ -42,5 +42,5 @@ export interface WorkflowConfig {
export function isValidBuildTarget(
target: string | undefined
): target is BuildTarget {
- return target === 'standalone' || target === 'vercel-build-output-api';
+ return validBuildTargets.includes(target as any);
}
Analysis
isValidBuildTarget doesn't validate 'next' and 'sveltekit' targets
What fails: The isValidBuildTarget() function in packages/cli/src/lib/config/types.ts only validates 'standalone' and 'vercel-build-output-api', missing the 'next' and 'sveltekit' targets that are defined in the validBuildTargets array.
How to reproduce:
cd packages/cli
npm run build -- --target nextResult: Returns validation error "Invalid target 'next'. Using default 'standalone'." and silently falls back to building standalone instead of next.
Expected: The validation should pass since 'next' is a valid target in the validBuildTargets array, and the build should proceed with the NextBuilder.
Root causes:
isValidBuildTarget()used hardcoded string checks instead of checking againstvalidBuildTargetsarraybuild.tsCLI flags options array was not updated to include 'next' and 'sveltekit'build.tslacked handler branches for 'next' and 'sveltekit' build targets- NextBuilder was not imported despite being needed for the 'next' target
Fixes applied:
- Updated
isValidBuildTarget()to check:return validBuildTargets.includes(target as any); - Updated
build.tsto importvalidBuildTargetsandNextBuilder - Updated CLI flags options to use
validBuildTargetsarray dynamically - Updated validation error message to dynamically list all valid targets
- Added handler branches for 'next' target (uses NextBuilder) and 'sveltekit' target (uses StandaloneBuilder which has built-in SvelteKit support via BaseBuilder)
904afa6 to
c4ec230
Compare
No description provided.