Skip to content
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
3 changes: 2 additions & 1 deletion .changeset/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
"@workflow/example-hono",
"@workflow/example-nitro-v3",
"@workflow/example-nitro-v2",
"@workflow/example-nuxt"
"@workflow/example-nuxt",
"@workflow/example-vite"
]
}
3 changes: 2 additions & 1 deletion .changeset/pre.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@
"nextjs-webpack": "0.0.2-alpha.5",
"@workflow/example-nitro-v3": "0.0.0",
"@workflow/example-nitro-v2": "0.0.0",
"@workflow/example-nuxt": "0.0.0"
"@workflow/example-nuxt": "0.0.0",
"@workflow/example-vite": "0.0.0"
},
"changesets": [
"angry-owls-beg",
Expand Down
10 changes: 9 additions & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ jobs:
project-id: "prj_avRPBF3eWjh6iDNQgmhH4VOg27h0"
- name: "nitro"
project-id: "prj_e7DZirYdLrQKXNrlxg7KmA6ABx8r"
- name: "vite"
project-id: "prj_uLIcNZNDmETulAvj5h0IcDHi5432"
env:
TURBO_TOKEN: ${{ secrets.TURBO_TOKEN }}
TURBO_TEAM: ${{ vars.TURBO_TEAM }}
Expand Down Expand Up @@ -170,7 +172,7 @@ jobs:
run: cd workbench/${{ matrix.app.name }} && ./resolve-symlinks.sh

- name: Run E2E Tests (Next.js)
if: matrix.app.name != 'nitro'
if: matrix.app.name != 'nitro' && matrix.app.name != 'vite'
run: cd workbench/${{ matrix.app.name }} && pnpm dev & echo "starting tests in 10 seconds" && sleep 10 && pnpm vitest run packages/core/e2e/next-dev.test.ts && pnpm run test:e2e
env:
APP_NAME: ${{ matrix.app.name }}
Expand All @@ -182,6 +184,12 @@ jobs:
env:
APP_NAME: ${{ matrix.app.name }}
DEPLOYMENT_URL: "http://localhost:3000"
- name: Run E2E Tests (Vite)
if: matrix.app.name == 'vite'
run: cd workbench/${{ matrix.app.name }} && pnpm dev & echo "starting tests in 10 seconds" && sleep 10 && pnpm vitest run packages/core/e2e/e2e.test.ts
env:
APP_NAME: ${{ matrix.app.name }}
DEPLOYMENT_URL: "http://localhost:3000"

e2e-local-prod:
name: E2E Local Prod Tests (${{ matrix.app.name }} - ${{ matrix.app.canary && 'canary' || 'stable' }})
Expand Down
2 changes: 1 addition & 1 deletion packages/core/e2e/local-build.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { getWorkbenchAppPath } from './utils';

const exec = promisify(execOriginal);

describe.each(['nextjs-webpack', 'nextjs-turbopack', 'nitro'])(
describe.each(['nextjs-webpack', 'nextjs-turbopack', 'nitro', 'vite'])(
'e2e',
(project) => {
test('builds without errors', { timeout: 180_000 }, async () => {
Expand Down
6 changes: 4 additions & 2 deletions packages/nitro/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@
},
"exports": {
".": "./dist/index.js",
"./rollup-plugin": "./dist/rollup-plugin.js"
"./rollup-plugin": "./dist/rollup-plugin.js",
"./vite": "./dist/vite.js"
},
"scripts": {
"build": "tsc",
Expand All @@ -36,6 +37,7 @@
"devDependencies": {
"@types/node": "catalog:",
"@workflow/tsconfig": "workspace:*",
"nitro": "latest"
"nitro": "catalog:",
"vite": "^7.1.12"
}
}
4 changes: 2 additions & 2 deletions packages/nitro/src/builders.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { mkdir, readFile, writeFile } from 'node:fs/promises';
import { BaseBuilder } from '@workflow/cli/dist/lib/builders/base-builder';
import { VercelBuildOutputAPIBuilder } from '@workflow/cli/dist/lib/builders/vercel-build-output-api';
import { BaseBuilder } from '@workflow/cli/dist/lib/builders/base-builder.js';
import { VercelBuildOutputAPIBuilder } from '@workflow/cli/dist/lib/builders/vercel-build-output-api.js';
import type { Nitro } from 'nitro/types';
import { join, resolve } from 'pathe';

Expand Down
8 changes: 5 additions & 3 deletions packages/nitro/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type { Nitro, NitroModule, RollupConfig } from 'nitro/types';
import { join } from 'pathe';
import { LocalBuilder, VercelBuilder } from './builders';
import { workflowRollupPlugin } from './rollup-plugin';
import { LocalBuilder, VercelBuilder } from './builders.js';
import { workflowRollupPlugin } from './rollup-plugin.js';
import type { ModuleOptions } from './types';

export type { ModuleOptions };
Expand All @@ -18,7 +18,9 @@ export default {
});

// Temporary workaround for debug unenv mock
nitro.options.alias['debug'] ??= 'debug';
if (!nitro.options.workflow?._vite) {
nitro.options.alias['debug'] ??= 'debug';
}

// Generate functions for vercel build
if (isVercelDeploy) {
Expand Down
2 changes: 1 addition & 1 deletion packages/nitro/src/rollup-plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ type RollupPlugin = Exclude<

export function workflowRollupPlugin(): RollupPlugin {
return {
name: 'workflow-rollup-plugin',
name: 'workflow:transform',
// This transform applies the "use workflow"/"use step"
// client transformation
async transform(code: string, id: string) {
Expand Down
3 changes: 3 additions & 0 deletions packages/nitro/src/types.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
export interface ModuleOptions {
/** @internal */
_vite?: boolean;

/**
* Directories to scan for workflows and steps.
*
Expand Down
22 changes: 22 additions & 0 deletions packages/nitro/src/vite.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import type { Plugin } from 'vite'
import type { ModuleOptions } from './index.js'
import type { Nitro } from 'nitro/types';
import { workflowRollupPlugin } from './rollup-plugin.js';
import nitroModule from './index.js'

export function workflow(options?: ModuleOptions): Plugin[] {
return [
workflowRollupPlugin(),
{
name: 'workflow:nitro',
// Requires https://github.com/nitrojs/nitro/discussions/3680
// @ts-ignore
nitro: {
setup: (nitro: Nitro) => {
nitro.options.workflow = { ...nitro.options.workflow, ...options, _vite: true }
return nitroModule.setup(nitro)
}
}
}
]
}
1 change: 1 addition & 0 deletions packages/workflow/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
"./next": "./dist/next.js",
"./nitro": "./dist/nitro.js",
"./rollup-plugin": "./dist/rollup-plugin.js",
Copy link
Collaborator

Choose a reason for hiding this comment

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

we can change this to just /rollup in this PR if we want. might as well make the change now before waiting too long

I am worried we're polluting the workflow package with too many framework builders but we can break it apart in a future major release. changing workflow/nitro to @workflow/nitro is a pretty simple codemod

"./vite": "./dist/vite.js",
"./runtime": "./dist/runtime.js"
},
"scripts": {
Expand Down
1 change: 1 addition & 0 deletions packages/workflow/src/vite.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { workflow } from '@workflow/nitro/vite';
Loading