@workflow/builders 4.0.1-beta.21 → 4.0.1-beta.23

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.
@@ -1,36 +1,303 @@
1
+ import { readFile } from 'node:fs/promises';
2
+ import { normalize, relative, resolve } from 'node:path';
3
+ import { promisify } from 'node:util';
1
4
  import { ERROR_SLUGS } from '@workflow/errors';
2
5
  import builtinModules from 'builtin-modules';
6
+ import enhancedResolveOriginal from 'enhanced-resolve';
7
+ const enhancedResolve = promisify(enhancedResolveOriginal);
3
8
  // Match exact Node.js built-in module names:
4
9
  // - "fs", "path", "stream" etc. (exact match)
5
10
  // - "node:fs", "node:path" etc. (with node: prefix)
6
- // - "bun" (exact match)
7
- // - "bun:sqlite", "bun:ffi" etc. (with bun: prefix)
8
11
  // But NOT "some-package/stream" or "eventsource-parser/stream"
9
12
  const nodeModulesPattern = `(${builtinModules.join('|')})`;
10
- const nodeModulesRegex = new RegExp(`^${nodeModulesPattern}$`);
13
+ // Match Bun modules:
14
+ // - "bun" (exact match)
15
+ // - "bun:sqlite", "bun:ffi" etc. (with bun: prefix)
11
16
  const bunModulesRegex = /^bun(:|$)/;
12
- const regex = new RegExp(`^(${nodeModulesPattern}|bun(:.*)?)$`);
17
+ // Combined regex for both Node.js and Bun modules
18
+ const runtimeModulesRegex = new RegExp(`^((node:)?${nodeModulesPattern}|bun(:.*)?)$`);
19
+ /**
20
+ * Get the package name from a file path.
21
+ * @param filePath - The file path to get the package name from.
22
+ * @returns The package name.
23
+ */
24
+ export function getPackageName(filePath) {
25
+ const normalized = filePath.replace(/\\/g, '/');
26
+ const marker = '/node_modules/';
27
+ const idx = normalized.lastIndexOf(marker);
28
+ if (idx === -1)
29
+ return null;
30
+ const after = normalized.slice(idx + marker.length); // e.g. ".pnpm/node-fetch@3.3.2/node_modules/node-fetch/src/index.js"
31
+ const segments = after.split('/');
32
+ if (!segments.length)
33
+ return null;
34
+ let packageName = segments[0];
35
+ // pnpm nests: ".pnpm/<pkg>@<version>/node_modules/<pkg>/..."
36
+ if (packageName === '.pnpm' && segments.length >= 3) {
37
+ packageName = segments[2];
38
+ }
39
+ else if (packageName.startsWith('@') && segments.length >= 2) {
40
+ packageName = `${segments[0]}/${segments[1]}`;
41
+ }
42
+ return packageName;
43
+ }
44
+ /**
45
+ * Escape a regular expression string.
46
+ * @param value - The string to escape.
47
+ * @returns The escaped string.
48
+ */
49
+ export function escapeRegExp(value) {
50
+ return value.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
51
+ }
52
+ /**
53
+ * Get the imported identifier from a specifier.
54
+ * @param specifier - The specifier to get the imported identifier from.
55
+ * @returns The imported identifier.
56
+ */
57
+ export function getImportedIdentifier(specifier) {
58
+ const namespaceMatch = specifier.match(/\*\s+as\s+([A-Za-z0-9_$]+)/);
59
+ if (namespaceMatch) {
60
+ return namespaceMatch[1];
61
+ }
62
+ if (specifier.includes('{')) {
63
+ const inside = specifier.replace(/^[^{]*\{/, '').replace(/\}.*$/, '');
64
+ const firstNamed = inside
65
+ .split(',')
66
+ .map((token) => token.trim())
67
+ .find(Boolean);
68
+ if (firstNamed) {
69
+ const aliasMatch = firstNamed.match(/([A-Za-z0-9_$]+)\s+as\s+([A-Za-z0-9_$]+)/);
70
+ if (aliasMatch) {
71
+ return aliasMatch[2];
72
+ }
73
+ // Validate that firstNamed is a valid identifier (not empty braces or whitespace)
74
+ const identifierMatch = firstNamed.match(/^[A-Za-z_$][A-Za-z0-9_$]*/);
75
+ if (identifierMatch) {
76
+ return identifierMatch[0];
77
+ }
78
+ }
79
+ // Empty braces or no valid identifier found - return undefined
80
+ return undefined;
81
+ }
82
+ const defaultPart = specifier.split(',')[0]?.trim();
83
+ if (defaultPart && defaultPart !== '*') {
84
+ return defaultPart;
85
+ }
86
+ }
87
+ /**
88
+ * Find the usage of an identifier in a list of lines.
89
+ * @param lines - The list of lines to search in.
90
+ * @param startIndex - The index to start searching from.
91
+ * @param identifier - The identifier to search for.
92
+ * @returns The usage of the identifier.
93
+ */
94
+ function findIdentifierUsage(lines, startIndex, identifier) {
95
+ const usageRegex = new RegExp(`\\b${escapeRegExp(identifier)}\\b`);
96
+ for (let i = startIndex; i < lines.length; i += 1) {
97
+ const line = lines[i];
98
+ // Skip comments (both // and /* */ style)
99
+ const withoutComments = line
100
+ .replace(/\/\*[\s\S]*?\*\//g, '')
101
+ .replace(/\/\/.*$/, '');
102
+ // Remove (replace with spaces) string literals to avoid matching inside paths
103
+ // Use escaped quote handling to properly match strings with escaped quotes
104
+ const withoutStrings = withoutComments
105
+ .replace(/'(?:[^'\\]|\\.)*'/g, (segment) => ' '.repeat(segment.length))
106
+ .replace(/"(?:[^"\\]|\\.)*"/g, (segment) => ' '.repeat(segment.length))
107
+ .replace(/`(?:[^`\\]|\\.)*`/g, (segment) => ' '.repeat(segment.length));
108
+ const match = withoutStrings.match(usageRegex);
109
+ if (match && match.index !== undefined) {
110
+ return {
111
+ line: i,
112
+ column: match.index,
113
+ lineText: line,
114
+ };
115
+ }
116
+ }
117
+ }
118
+ /**
119
+ * Get the location of a violation.
120
+ * @param cwd - The current working directory.
121
+ * @param relativePath - The relative path to the file.
122
+ * @param packageName - The name of the package.
123
+ * @returns The location of the violation.
124
+ */
125
+ export async function getViolationLocation(cwd, relativePath, packageName) {
126
+ try {
127
+ const absolutePath = resolve(cwd, relativePath);
128
+ const contents = await readFile(absolutePath, 'utf8');
129
+ const lines = contents.split(/\r?\n/);
130
+ const importRegex = new RegExp(`import\\s+(.+?)\\s+from\\s+['"]${escapeRegExp(packageName)}(?:/[^'"]*)?['"]`);
131
+ for (let i = 0; i < lines.length; i += 1) {
132
+ const line = lines[i];
133
+ const importMatch = line.match(importRegex);
134
+ if (importMatch && importMatch.index !== undefined) {
135
+ const specifier = importMatch[1].trim();
136
+ const identifier = getImportedIdentifier(specifier);
137
+ if (identifier) {
138
+ const usage = findIdentifierUsage(lines, i + 1, identifier);
139
+ if (usage) {
140
+ return {
141
+ file: relativePath,
142
+ line: usage.line + 1,
143
+ column: usage.column,
144
+ lineText: usage.lineText,
145
+ length: identifier.length,
146
+ };
147
+ }
148
+ // Identifier exists but is never referenced; surface no location
149
+ return undefined;
150
+ }
151
+ // Fallback: if we can't extract identifier, point to package name
152
+ const columnIndex = line.indexOf(packageName);
153
+ if (columnIndex !== -1) {
154
+ return {
155
+ file: relativePath,
156
+ line: i + 1,
157
+ column: columnIndex,
158
+ lineText: line,
159
+ length: packageName.length,
160
+ };
161
+ }
162
+ }
163
+ }
164
+ }
165
+ catch {
166
+ // ignore file read failures, fallback to no location info
167
+ }
168
+ }
169
+ /**
170
+ * Get the module type label for error messages.
171
+ * @param modulePath - The module path to check.
172
+ * @returns The module type label.
173
+ */
174
+ function getModuleTypeLabel(modulePath) {
175
+ if (bunModulesRegex.test(modulePath)) {
176
+ return 'Bun';
177
+ }
178
+ return 'Node.js';
179
+ }
180
+ /**
181
+ * Create an esbuild plugin to detect violations of the Node.js module usage rule.
182
+ * This plugin prevents workflow functions from importing Node.js or Bun built-in
183
+ * modules, which are not available in the sandboxed workflow runtime.
184
+ */
13
185
  export function createNodeModuleErrorPlugin() {
14
186
  return {
15
187
  name: 'workflow-node-module-error',
16
188
  setup(build) {
17
- build.onResolve({ filter: regex }, (args) => {
18
- const isNodeModule = nodeModulesRegex.test(args.path);
19
- const isBunModule = bunModulesRegex.test(args.path);
20
- const moduleType = isNodeModule
21
- ? 'Node.js '
22
- : isBunModule
23
- ? 'Bun '
24
- : '';
189
+ const cwd = process.cwd();
190
+ const importParents = new Map();
191
+ const packageViolations = [];
192
+ const seenViolations = new Set();
193
+ // Track ALL import relationships to build the dependency graph.
194
+ // This is necessary to trace transitive dependencies back to user code.
195
+ // Performance impact is minimal as we only store path mappings.
196
+ build.onResolve({ filter: /.*/ }, async (args) => {
197
+ if (!args.importer)
198
+ return null;
199
+ try {
200
+ const resolvedChild = await enhancedResolve(args.resolveDir, args.path);
201
+ if (resolvedChild) {
202
+ const childKey = normalize(resolvedChild);
203
+ const parentValue = normalize(args.importer);
204
+ importParents.set(childKey, parentValue);
205
+ }
206
+ }
207
+ catch {
208
+ // For built-in modules that can't be resolved, still track using the import path
209
+ const childKey = args.path;
210
+ const parentValue = normalize(args.importer);
211
+ importParents.set(childKey, parentValue);
212
+ }
213
+ return null;
214
+ });
215
+ // Detect Node.js and Bun module imports
216
+ build.onResolve({ filter: runtimeModulesRegex }, async (args) => {
217
+ const importerPath = resolve(cwd, args.importer);
218
+ let current = importerPath;
219
+ const chain = [];
220
+ const visited = new Set();
221
+ while (current) {
222
+ if (visited.has(current)) {
223
+ break;
224
+ }
225
+ visited.add(current);
226
+ chain.push(current);
227
+ let next = importParents.get(current);
228
+ // If we can't find the parent and current is in node_modules,
229
+ // try looking up by potential package import strings
230
+ if (!next && current.includes('node_modules')) {
231
+ const packageName = getPackageName(current);
232
+ if (packageName) {
233
+ // Try the package name directly
234
+ next = importParents.get(packageName);
235
+ if (!next) {
236
+ // Try with node: prefix
237
+ next = importParents.get(`node:${packageName}`);
238
+ }
239
+ }
240
+ }
241
+ current = next ?? '';
242
+ }
243
+ const filteredChain = chain.filter((path) => !path.includes('node_modules'));
244
+ const workflowFile = filteredChain[0] ?? importerPath;
245
+ if (!workflowFile || workflowFile.includes('node_modules')) {
246
+ return {
247
+ path: args.path,
248
+ external: true,
249
+ };
250
+ }
251
+ const packageName = importerPath.includes('node_modules')
252
+ ? (getPackageName(importerPath) ?? args.path)
253
+ : args.path;
254
+ const relativeWorkflowFile = relative(cwd, workflowFile);
255
+ const violationKey = `${packageName}:${relativeWorkflowFile}`;
256
+ if (!seenViolations.has(violationKey)) {
257
+ seenViolations.add(violationKey);
258
+ const location = await getViolationLocation(cwd, relativeWorkflowFile, packageName);
259
+ // Only report violations where we can find the import location.
260
+ // If we can't find it, the package is likely a transitive dependency
261
+ // that the user didn't directly import - we'll report the top-level
262
+ // package they did import instead.
263
+ if (location) {
264
+ packageViolations.push({
265
+ path: args.path,
266
+ importer: relativeWorkflowFile,
267
+ packageName,
268
+ location,
269
+ });
270
+ }
271
+ }
25
272
  return {
26
273
  path: args.path,
27
- errors: [
28
- {
29
- text: `Cannot use ${moduleType}module "${args.path}" in workflow functions. Move this module to a step function.\n\nLearn more: https://useworkflow.dev/err/${ERROR_SLUGS.NODE_JS_MODULE_IN_WORKFLOW}`,
30
- },
31
- ],
274
+ external: true,
32
275
  };
33
276
  });
277
+ // Report all violations at the end of the build
278
+ build.onEnd(() => {
279
+ if (packageViolations.length > 0) {
280
+ return {
281
+ errors: packageViolations.map((violation) => {
282
+ const isBuiltinModule = runtimeModulesRegex.test(violation.packageName);
283
+ const moduleType = getModuleTypeLabel(violation.path);
284
+ // Different messages for built-in modules vs npm packages that use them
285
+ const text = isBuiltinModule
286
+ ? `You are attempting to use "${violation.packageName}" which is a ${moduleType} module. ${moduleType} modules are not available in workflow functions.\n\nLearn more: https://useworkflow.dev/err/${ERROR_SLUGS.NODE_JS_MODULE_IN_WORKFLOW}`
287
+ : `You are attempting to use "${violation.packageName}" which depends on ${moduleType} modules. Packages that depend on ${moduleType} modules are not available in workflow functions.\n\nLearn more: https://useworkflow.dev/err/${ERROR_SLUGS.NODE_JS_MODULE_IN_WORKFLOW}`;
288
+ return {
289
+ text,
290
+ location: violation.location
291
+ ? {
292
+ ...violation.location,
293
+ suggestion: 'Move this function into a step function.',
294
+ }
295
+ : undefined,
296
+ };
297
+ }),
298
+ };
299
+ }
300
+ });
34
301
  },
35
302
  };
36
303
  }
@@ -1 +1 @@
1
- {"version":3,"file":"node-module-esbuild-plugin.js","sourceRoot":"","sources":["../src/node-module-esbuild-plugin.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC/C,OAAO,cAAc,MAAM,iBAAiB,CAAC;AAG7C,6CAA6C;AAC7C,8CAA8C;AAC9C,oDAAoD;AACpD,wBAAwB;AACxB,oDAAoD;AACpD,+DAA+D;AAC/D,MAAM,kBAAkB,GAAG,IAAI,cA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