@workflow/builders 4.0.4 → 4.0.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/base-builder.d.ts +23 -4
- package/dist/base-builder.d.ts.map +1 -1
- package/dist/base-builder.js +121 -7
- package/dist/base-builder.js.map +1 -1
- package/dist/discover-entries-esbuild-plugin.d.ts +5 -3
- package/dist/discover-entries-esbuild-plugin.d.ts.map +1 -1
- package/dist/discover-entries-esbuild-plugin.js +30 -7
- package/dist/discover-entries-esbuild-plugin.js.map +1 -1
- package/dist/external-package-warning.test.d.ts +2 -0
- package/dist/external-package-warning.test.d.ts.map +1 -0
- package/dist/external-package-warning.test.js +219 -0
- package/dist/external-package-warning.test.js.map +1 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/request-converter.d.ts +2 -1
- package/dist/request-converter.d.ts.map +1 -1
- package/dist/request-converter.js +19 -1
- package/dist/request-converter.js.map +1 -1
- package/dist/request-converter.test.d.ts +2 -0
- package/dist/request-converter.test.d.ts.map +1 -0
- package/dist/request-converter.test.js +28 -0
- package/dist/request-converter.test.js.map +1 -0
- package/dist/swc-esbuild-plugin.d.ts +9 -0
- package/dist/swc-esbuild-plugin.d.ts.map +1 -1
- package/dist/swc-esbuild-plugin.js +24 -1
- package/dist/swc-esbuild-plugin.js.map +1 -1
- package/dist/swc-esbuild-plugin.test.js +184 -0
- package/dist/swc-esbuild-plugin.test.js.map +1 -1
- package/dist/vercel-build-output-api.d.ts.map +1 -1
- package/dist/vercel-build-output-api.js +3 -0
- package/dist/vercel-build-output-api.js.map +1 -1
- package/package.json +5 -5
package/dist/base-builder.d.ts
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import * as esbuild from 'esbuild';
|
|
2
2
|
import { type WorkflowManifest } from './apply-swc-transform.js';
|
|
3
3
|
import type { WorkflowConfig } from './types.js';
|
|
4
|
+
export type DiscoveredEntryCollection = string[] | Set<string>;
|
|
4
5
|
export interface DiscoveredEntries {
|
|
5
|
-
discoveredSteps:
|
|
6
|
-
discoveredWorkflows:
|
|
7
|
-
discoveredSerdeFiles:
|
|
6
|
+
discoveredSteps: DiscoveredEntryCollection;
|
|
7
|
+
discoveredWorkflows: DiscoveredEntryCollection;
|
|
8
|
+
discoveredSerdeFiles: DiscoveredEntryCollection;
|
|
8
9
|
}
|
|
9
10
|
/**
|
|
10
11
|
* Base class for workflow builders. Provides common build logic for transforming
|
|
@@ -14,6 +15,11 @@ export interface DiscoveredEntries {
|
|
|
14
15
|
*/
|
|
15
16
|
export declare abstract class BaseBuilder {
|
|
16
17
|
protected config: WorkflowConfig;
|
|
18
|
+
/**
|
|
19
|
+
* Tracks which external packages have already been warned about
|
|
20
|
+
* to avoid duplicate warnings across multiple discoverEntries() calls.
|
|
21
|
+
*/
|
|
22
|
+
private warnedExternalPackages;
|
|
17
23
|
constructor(config: WorkflowConfig);
|
|
18
24
|
protected get transformProjectRoot(): string;
|
|
19
25
|
/**
|
|
@@ -56,6 +62,17 @@ export declare abstract class BaseBuilder {
|
|
|
56
62
|
* (e.g., when files are added/removed during watch mode).
|
|
57
63
|
*/
|
|
58
64
|
private discoveredEntries;
|
|
65
|
+
/**
|
|
66
|
+
* Pseudo-packages that should not be checked for workflow patterns.
|
|
67
|
+
*/
|
|
68
|
+
private static readonly PSEUDO_PACKAGES;
|
|
69
|
+
/**
|
|
70
|
+
* Checks each package in externalPackages for workflow patterns and emits
|
|
71
|
+
* warnings if any contain "use step", "use workflow" directives, or
|
|
72
|
+
* serialization classes. These patterns will not be transformed by the
|
|
73
|
+
* workflow compiler when the package is externalized.
|
|
74
|
+
*/
|
|
75
|
+
private warnAboutExternalWorkflowPackages;
|
|
59
76
|
protected discoverEntries(inputs: string[], outdir: string, tsconfigPath?: string): Promise<DiscoveredEntries>;
|
|
60
77
|
/**
|
|
61
78
|
* Writes debug information to a JSON file for troubleshooting build issues.
|
|
@@ -77,14 +94,16 @@ export declare abstract class BaseBuilder {
|
|
|
77
94
|
* Steps have full Node.js runtime access and handle side effects, API calls, etc.
|
|
78
95
|
*
|
|
79
96
|
* @param externalizeNonSteps - If true, only bundles step entry points and externalizes other code
|
|
97
|
+
* @param bundleTransitiveLocalStepDependencies - If true, also bundles project-local files imported by step entries for direct runtime loading
|
|
80
98
|
* @returns Build context (for watch mode) and the collected workflow manifest
|
|
81
99
|
*/
|
|
82
|
-
protected createStepsBundle({ inputFiles, format, outfile, externalizeNonSteps, rewriteTsExtensions, tsconfigPath, discoveredEntries, }: {
|
|
100
|
+
protected createStepsBundle({ inputFiles, format, outfile, externalizeNonSteps, bundleTransitiveLocalStepDependencies, rewriteTsExtensions, tsconfigPath, discoveredEntries, }: {
|
|
83
101
|
tsconfigPath?: string;
|
|
84
102
|
inputFiles: string[];
|
|
85
103
|
outfile: string;
|
|
86
104
|
format?: 'cjs' | 'esm';
|
|
87
105
|
externalizeNonSteps?: boolean;
|
|
106
|
+
bundleTransitiveLocalStepDependencies?: boolean;
|
|
88
107
|
rewriteTsExtensions?: boolean;
|
|
89
108
|
discoveredEntries?: DiscoveredEntries;
|
|
90
109
|
}): Promise<{
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"base-builder.d.ts","sourceRoot":"","sources":["../src/base-builder.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"base-builder.d.ts","sourceRoot":"","sources":["../src/base-builder.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,OAAO,MAAM,SAAS,CAAC;AAGnC,OAAO,EAEL,KAAK,gBAAgB,EACtB,MAAM,0BAA0B,CAAC;AAQlC,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AA4BjD,MAAM,MAAM,yBAAyB,GAAG,MAAM,EAAE,GAAG,GAAG,CAAC,MAAM,CAAC,CAAC;AAE/D,MAAM,WAAW,iBAAiB;IAChC,eAAe,EAAE,yBAAyB,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EAAE;QACD,kBAAkB,EAAE,MAAM,CAAC;QAC3B,WAAW,EAAE,MAAM,CAAC;QACpB,QAAQ,EAAE,gBAAgB,CAAC;KAC5B,GAAG,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC;IAuD/B,OAAO,CAAC,oBAAoB;IAe5B,OAAO,CAAC,wBAAwB;IAyDhC,OAAO,CAAC,sBAAsB;CAc/B"}
|
package/dist/base-builder.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { randomUUID } from 'node:crypto';
|
|
2
2
|
import { mkdir, readFile, realpath, rename, writeFile } from 'node:fs/promises';
|
|
3
|
+
import { createRequire } from 'node:module';
|
|
3
4
|
import { basename, dirname, join, relative, resolve } from 'node:path';
|
|
4
5
|
import { promisify } from 'node:util';
|
|
5
6
|
import { pluralize, usesVercelWorld } from '@workflow/utils';
|
|
@@ -15,8 +16,10 @@ import { getImportPath } from './module-specifier.js';
|
|
|
15
16
|
import { createNodeModuleErrorPlugin } from './node-module-esbuild-plugin.js';
|
|
16
17
|
import { createPseudoPackagePlugin } from './pseudo-package-esbuild-plugin.js';
|
|
17
18
|
import { createSwcPlugin } from './swc-esbuild-plugin.js';
|
|
19
|
+
import { detectWorkflowPatterns } from './transform-utils.js';
|
|
18
20
|
import { extractWorkflowGraphs } from './workflows-extractor.js';
|
|
19
21
|
const enhancedResolve = promisify(enhancedResolveOriginal);
|
|
22
|
+
const require = createRequire(import.meta.url);
|
|
20
23
|
const EMIT_SOURCEMAPS_FOR_DEBUGGING = process.env.WORKFLOW_EMIT_SOURCEMAPS_FOR_DEBUGGING === '1';
|
|
21
24
|
/**
|
|
22
25
|
* Normalize an array of file paths by appending the `realpath()` of each entry
|
|
@@ -36,6 +39,11 @@ async function withRealpaths(entries) {
|
|
|
36
39
|
*/
|
|
37
40
|
export class BaseBuilder {
|
|
38
41
|
config;
|
|
42
|
+
/**
|
|
43
|
+
* Tracks which external packages have already been warned about
|
|
44
|
+
* to avoid duplicate warnings across multiple discoverEntries() calls.
|
|
45
|
+
*/
|
|
46
|
+
warnedExternalPackages = new Set();
|
|
39
47
|
constructor(config) {
|
|
40
48
|
this.config = config;
|
|
41
49
|
}
|
|
@@ -141,15 +149,114 @@ export class BaseBuilder {
|
|
|
141
149
|
* (e.g., when files are added/removed during watch mode).
|
|
142
150
|
*/
|
|
143
151
|
discoveredEntries = new WeakMap();
|
|
152
|
+
/**
|
|
153
|
+
* Pseudo-packages that should not be checked for workflow patterns.
|
|
154
|
+
*/
|
|
155
|
+
static PSEUDO_PACKAGES = new Set([
|
|
156
|
+
'server-only',
|
|
157
|
+
'client-only',
|
|
158
|
+
]);
|
|
159
|
+
/**
|
|
160
|
+
* Checks each package in externalPackages for workflow patterns and emits
|
|
161
|
+
* warnings if any contain "use step", "use workflow" directives, or
|
|
162
|
+
* serialization classes. These patterns will not be transformed by the
|
|
163
|
+
* workflow compiler when the package is externalized.
|
|
164
|
+
*/
|
|
165
|
+
async warnAboutExternalWorkflowPackages() {
|
|
166
|
+
const externalPackages = this.config.externalPackages;
|
|
167
|
+
if (!externalPackages?.length)
|
|
168
|
+
return;
|
|
169
|
+
for (const pkg of externalPackages) {
|
|
170
|
+
if (BaseBuilder.PSEUDO_PACKAGES.has(pkg))
|
|
171
|
+
continue;
|
|
172
|
+
if (this.warnedExternalPackages.has(pkg))
|
|
173
|
+
continue;
|
|
174
|
+
if (pkg.startsWith('.') ||
|
|
175
|
+
pkg.startsWith('/') ||
|
|
176
|
+
pkg.startsWith('$') ||
|
|
177
|
+
pkg.includes('*') ||
|
|
178
|
+
pkg.includes(':')) {
|
|
179
|
+
continue;
|
|
180
|
+
}
|
|
181
|
+
try {
|
|
182
|
+
// Check package.json dependencies for @workflow/serde (fast path)
|
|
183
|
+
let hasWorkflowSerdeDep = false;
|
|
184
|
+
try {
|
|
185
|
+
const pkgJsonPath = require.resolve(`${pkg}/package.json`, {
|
|
186
|
+
paths: [this.config.workingDir],
|
|
187
|
+
});
|
|
188
|
+
const pkgJsonSource = await readFile(pkgJsonPath, 'utf-8');
|
|
189
|
+
const pkgJson = JSON.parse(pkgJsonSource);
|
|
190
|
+
const dependencies = typeof pkgJson.dependencies === 'object' &&
|
|
191
|
+
pkgJson.dependencies !== null &&
|
|
192
|
+
!Array.isArray(pkgJson.dependencies)
|
|
193
|
+
? pkgJson.dependencies
|
|
194
|
+
: {};
|
|
195
|
+
const peerDependencies = typeof pkgJson.peerDependencies === 'object' &&
|
|
196
|
+
pkgJson.peerDependencies !== null &&
|
|
197
|
+
!Array.isArray(pkgJson.peerDependencies)
|
|
198
|
+
? pkgJson.peerDependencies
|
|
199
|
+
: {};
|
|
200
|
+
hasWorkflowSerdeDep =
|
|
201
|
+
Object.hasOwn(dependencies, '@workflow/serde') ||
|
|
202
|
+
Object.hasOwn(peerDependencies, '@workflow/serde');
|
|
203
|
+
}
|
|
204
|
+
catch {
|
|
205
|
+
// package.json not resolvable - continue to source check
|
|
206
|
+
}
|
|
207
|
+
// Check source patterns (thorough path).
|
|
208
|
+
// Note: require.resolve only inspects the package's main entry point.
|
|
209
|
+
// If workflow constructs live in sub-paths (e.g. `my-pkg/workflows`),
|
|
210
|
+
// they won't be detected here. The @workflow/serde dep check above
|
|
211
|
+
// partially covers serde cases. This is acceptable as a best-effort
|
|
212
|
+
// heuristic — the primary fix is auto-removal in withWorkflow().
|
|
213
|
+
let hasUseStep = false;
|
|
214
|
+
let hasUseWorkflow = false;
|
|
215
|
+
let hasSerde = hasWorkflowSerdeDep;
|
|
216
|
+
try {
|
|
217
|
+
const entryPath = require.resolve(pkg, {
|
|
218
|
+
paths: [this.config.workingDir],
|
|
219
|
+
});
|
|
220
|
+
const source = await readFile(entryPath, 'utf-8');
|
|
221
|
+
const patterns = detectWorkflowPatterns(source);
|
|
222
|
+
hasUseStep = patterns.hasUseStep;
|
|
223
|
+
hasUseWorkflow = patterns.hasUseWorkflow;
|
|
224
|
+
if (!hasSerde) {
|
|
225
|
+
hasSerde = patterns.hasSerde;
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
catch {
|
|
229
|
+
// Entry file not resolvable or not readable - use what we have
|
|
230
|
+
}
|
|
231
|
+
if (!hasUseStep && !hasUseWorkflow && !hasSerde)
|
|
232
|
+
continue;
|
|
233
|
+
// Build a specific description of what was found
|
|
234
|
+
const issues = [];
|
|
235
|
+
if (hasUseWorkflow)
|
|
236
|
+
issues.push('"use workflow" functions');
|
|
237
|
+
if (hasUseStep)
|
|
238
|
+
issues.push('"use step" functions');
|
|
239
|
+
if (hasSerde)
|
|
240
|
+
issues.push('serialization classes');
|
|
241
|
+
this.warnedExternalPackages.add(pkg);
|
|
242
|
+
console.warn(`\n${chalk.yellow('⚠')} Warning: ${chalk.bold(`"${pkg}"`)} is listed in ${chalk.bold('externalPackages')} (${chalk.bold('serverExternalPackages')} in Next.js) but contains workflow code (${issues.join(', ')}).` +
|
|
243
|
+
`\n This code will ${chalk.bold('not')} be transformed by the workflow compiler, which can cause runtime failures.` +
|
|
244
|
+
`\n Remove ${chalk.bold(`"${pkg}"`)} from ${chalk.bold('externalPackages')} (${chalk.bold('serverExternalPackages')} in Next.js) to fix this.\n`);
|
|
245
|
+
}
|
|
246
|
+
catch {
|
|
247
|
+
// Best-effort: if anything goes wrong, skip this package silently
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
}
|
|
144
251
|
async discoverEntries(inputs, outdir, tsconfigPath) {
|
|
145
252
|
const previousResult = this.discoveredEntries.get(inputs);
|
|
146
253
|
if (previousResult) {
|
|
147
254
|
return previousResult;
|
|
148
255
|
}
|
|
149
256
|
const state = {
|
|
150
|
-
discoveredSteps:
|
|
151
|
-
discoveredWorkflows:
|
|
152
|
-
discoveredSerdeFiles:
|
|
257
|
+
discoveredSteps: new Set(),
|
|
258
|
+
discoveredWorkflows: new Set(),
|
|
259
|
+
discoveredSerdeFiles: new Set(),
|
|
153
260
|
};
|
|
154
261
|
const discoverStart = Date.now();
|
|
155
262
|
const effectiveTsconfigPath = tsconfigPath ?? (await this.findTsConfigPath());
|
|
@@ -175,6 +282,8 @@ export class BaseBuilder {
|
|
|
175
282
|
}
|
|
176
283
|
catch (_) { }
|
|
177
284
|
this.logBaseBuilderInfo(`Discovering workflow directives`, `${Date.now() - discoverStart}ms`);
|
|
285
|
+
// Warn about external packages that contain workflow code
|
|
286
|
+
await this.warnAboutExternalWorkflowPackages();
|
|
178
287
|
this.discoveredEntries.set(inputs, state);
|
|
179
288
|
return state;
|
|
180
289
|
}
|
|
@@ -270,9 +379,10 @@ export class BaseBuilder {
|
|
|
270
379
|
* Steps have full Node.js runtime access and handle side effects, API calls, etc.
|
|
271
380
|
*
|
|
272
381
|
* @param externalizeNonSteps - If true, only bundles step entry points and externalizes other code
|
|
382
|
+
* @param bundleTransitiveLocalStepDependencies - If true, also bundles project-local files imported by step entries for direct runtime loading
|
|
273
383
|
* @returns Build context (for watch mode) and the collected workflow manifest
|
|
274
384
|
*/
|
|
275
|
-
async createStepsBundle({ inputFiles, format = 'cjs', outfile, externalizeNonSteps, rewriteTsExtensions, tsconfigPath, discoveredEntries, }) {
|
|
385
|
+
async createStepsBundle({ inputFiles, format = 'cjs', outfile, externalizeNonSteps, bundleTransitiveLocalStepDependencies, rewriteTsExtensions, tsconfigPath, discoveredEntries, }) {
|
|
276
386
|
// These need to handle watching for dev to scan for
|
|
277
387
|
// new entries and changes to existing ones
|
|
278
388
|
const discovered = discoveredEntries ??
|
|
@@ -339,7 +449,7 @@ export class BaseBuilder {
|
|
|
339
449
|
// Serde files for cross-context class registration
|
|
340
450
|
${serdeImports}
|
|
341
451
|
// API entrypoint
|
|
342
|
-
export { stepEntrypoint as POST } from 'workflow/runtime';`;
|
|
452
|
+
export { stepEntrypoint as HEAD, stepEntrypoint as POST } from 'workflow/runtime';`;
|
|
343
453
|
// Bundle with esbuild and our custom SWC plugin
|
|
344
454
|
const entriesToBundle = externalizeNonSteps
|
|
345
455
|
? [
|
|
@@ -410,6 +520,7 @@ export class BaseBuilder {
|
|
|
410
520
|
outdir: outfile ? dirname(outfile) : undefined,
|
|
411
521
|
projectRoot: this.transformProjectRoot,
|
|
412
522
|
workflowManifest,
|
|
523
|
+
bundleTransitiveLocalStepDependencies,
|
|
413
524
|
rewriteTsExtensions,
|
|
414
525
|
sideEffectEntries: normalizedSideEffectEntries,
|
|
415
526
|
}),
|
|
@@ -642,7 +753,10 @@ import { workflowEntrypoint } from 'workflow/runtime';
|
|
|
642
753
|
|
|
643
754
|
const workflowCode = \`${workflowBundleCode.replace(/[\\`$]/g, '\\$&')}\`;
|
|
644
755
|
|
|
645
|
-
|
|
756
|
+
const handler = workflowEntrypoint(workflowCode);
|
|
757
|
+
|
|
758
|
+
export const HEAD = handler;
|
|
759
|
+
export const POST = handler;`;
|
|
646
760
|
// we skip the final bundling step for Next.js so it can bundle itself
|
|
647
761
|
if (!bundleFinalOutput) {
|
|
648
762
|
if (!outfile) {
|
|
@@ -738,7 +852,7 @@ export const POST = workflowEntrypoint(workflowCode);`;
|
|
|
738
852
|
const { discoveredSerdeFiles } = await this.discoverEntries(inputFiles, outputDir);
|
|
739
853
|
// Identify serde files that aren't in the inputFiles (deduplicated)
|
|
740
854
|
const inputFilesNormalized = new Set(inputFiles.map((f) => f.replace(/\\/g, '/')));
|
|
741
|
-
const serdeOnlyFiles = discoveredSerdeFiles.filter((f) => !inputFilesNormalized.has(f));
|
|
855
|
+
const serdeOnlyFiles = [...discoveredSerdeFiles].filter((f) => !inputFilesNormalized.has(f));
|
|
742
856
|
// Re-exports for input files (user's workflow/step definitions).
|
|
743
857
|
// These must use valid relative specifiers because some frameworks pass
|
|
744
858
|
// generated files like ".output/server/index.mjs" as input files.
|