@workflow/builders 4.0.8 → 4.0.10

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.
Files changed (63) hide show
  1. package/dist/apply-swc-transform.js +1 -1
  2. package/dist/base-builder.js +1 -1
  3. package/dist/build-queue.js +1 -1
  4. package/dist/config-helpers.js +1 -1
  5. package/dist/constants.js +1 -1
  6. package/dist/discover-entries-esbuild-plugin.js +1 -1
  7. package/dist/discover-entries-esbuild-plugin.test.js +1 -1
  8. package/dist/esbuild-tsconfig.js +1 -1
  9. package/dist/esbuild-tsconfig.test.js +1 -1
  10. package/dist/external-package-warning.test.js +1 -1
  11. package/dist/get-input-files.test.js +1 -1
  12. package/dist/index.js +1 -1
  13. package/dist/module-specifier.js +1 -1
  14. package/dist/module-specifier.test.js +1 -1
  15. package/dist/node-module-esbuild-plugin.js +1 -1
  16. package/dist/node-module-esbuild-plugin.test.js +1 -1
  17. package/dist/pseudo-package-esbuild-plugin.js +1 -1
  18. package/dist/pseudo-package-esbuild-plugin.test.js +1 -1
  19. package/dist/request-converter.js +1 -1
  20. package/dist/request-converter.test.js +1 -1
  21. package/dist/serde-checker.js +1 -1
  22. package/dist/standalone.js +1 -1
  23. package/dist/swc-esbuild-plugin.js +1 -1
  24. package/dist/swc-esbuild-plugin.test.js +1 -1
  25. package/dist/transform-utils.js +1 -1
  26. package/dist/transform-utils.test.js +1 -1
  27. package/dist/types.js +1 -1
  28. package/dist/vercel-build-output-api.js +1 -1
  29. package/dist/workflow-alias.js +1 -1
  30. package/dist/workflow-alias.test.js +1 -1
  31. package/dist/workflows-extractor.js +1 -1
  32. package/package.json +5 -5
  33. package/dist/apply-swc-transform.js.map +0 -1
  34. package/dist/base-builder.js.map +0 -1
  35. package/dist/build-queue.js.map +0 -1
  36. package/dist/config-helpers.js.map +0 -1
  37. package/dist/constants.js.map +0 -1
  38. package/dist/discover-entries-esbuild-plugin.js.map +0 -1
  39. package/dist/discover-entries-esbuild-plugin.test.js.map +0 -1
  40. package/dist/esbuild-tsconfig.js.map +0 -1
  41. package/dist/esbuild-tsconfig.test.js.map +0 -1
  42. package/dist/external-package-warning.test.js.map +0 -1
  43. package/dist/get-input-files.test.js.map +0 -1
  44. package/dist/index.js.map +0 -1
  45. package/dist/module-specifier.js.map +0 -1
  46. package/dist/module-specifier.test.js.map +0 -1
  47. package/dist/node-module-esbuild-plugin.js.map +0 -1
  48. package/dist/node-module-esbuild-plugin.test.js.map +0 -1
  49. package/dist/pseudo-package-esbuild-plugin.js.map +0 -1
  50. package/dist/pseudo-package-esbuild-plugin.test.js.map +0 -1
  51. package/dist/request-converter.js.map +0 -1
  52. package/dist/request-converter.test.js.map +0 -1
  53. package/dist/serde-checker.js.map +0 -1
  54. package/dist/standalone.js.map +0 -1
  55. package/dist/swc-esbuild-plugin.js.map +0 -1
  56. package/dist/swc-esbuild-plugin.test.js.map +0 -1
  57. package/dist/transform-utils.js.map +0 -1
  58. package/dist/transform-utils.test.js.map +0 -1
  59. package/dist/types.js.map +0 -1
  60. package/dist/vercel-build-output-api.js.map +0 -1
  61. package/dist/workflow-alias.js.map +0 -1
  62. package/dist/workflow-alias.test.js.map +0 -1
  63. package/dist/workflows-extractor.js.map +0 -1
@@ -1 +0,0 @@
1
- {"version":3,"file":"node-module-esbuild-plugin.js","sourceRoot":"","sources":["../src/node-module-esbuild-plugin.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACzD,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AACtC,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC/C,OAAO,cAAc,MAAM,iBAAiB,CAAC;AAC7C,OAAO,uBAAuB,MAAM,kBAAkB,CAAC;AAGvD,MAAM,eAAe,GAAG,SAAS,CAAC,uBAAuB,CAAC,CA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wE;4BACxE,MAAM,IAAI,GAAG,eAAe;gCAC1B,CAAC,CAAC,8BAA8B,SAAS,CAAC,WAAW,gBAAgB,UAAU,YAAY,UAAU,gGAAgG,WAAW,CAAC,0BAA0B,EAAE;gCAC7O,CAAC,CAAC,8BAA8B,SAAS,CAAC,WAAW,sBAAsB,UAAU,qCAAqC,UAAU,gGAAgG,WAAW,CAAC,0BAA0B,EAAE,CAAC;4BAE/Q,OAAO;gCACL,IAAI;gCACJ,QAAQ,EAAE,SAAS,CAAC,QAAQ;oCAC1B,CAAC,CAAC;wCACE,GAAG,SAAS,CAAC,QAAQ;wCACrB,UAAU,EAAE,0CAA0C;qCACvD;oCACH,CAAC,CAAC,SAAS;6BACd,CAAC;wBACJ,CAAC,CAAC;qBACH,CAAC;gBACJ,CAAC;YACH,CAAC,CAAC,CAAC;QACL,CAAC;KACF,CAAC;AACJ,CAAC","sourcesContent":["import { readFile } from 'node:fs/promises';\nimport { normalize, relative, resolve } from 'node:path';\nimport { promisify } from 'node:util';\nimport { ERROR_SLUGS } from '@workflow/errors';\nimport builtinModules from 'builtin-modules';\nimport enhancedResolveOriginal from 'enhanced-resolve';\nimport type * as esbuild from 'esbuild';\n\nconst enhancedResolve = promisify(enhancedResolveOriginal);\n\n// Match exact Node.js built-in module names:\n// - \"fs\", \"path\", \"stream\" etc. (exact match)\n// - \"node:fs\", \"node:path\" etc. (with node: prefix)\n// But NOT \"some-package/stream\" or \"eventsource-parser/stream\"\nconst nodeModulesPattern = `(${builtinModules.join('|')})`;\n\n// Match Bun modules:\n// - \"bun\" (exact match)\n// - \"bun:sqlite\", \"bun:ffi\" etc. (with bun: prefix)\nconst bunModulesRegex = /^bun(:|$)/;\n\n// Combined regex for both Node.js and Bun modules\nconst runtimeModulesRegex = new RegExp(\n `^((node:)?${nodeModulesPattern}|bun(:.*)?)$`\n);\n\ntype PackageViolation = {\n packageName: string;\n importer: string;\n path: string;\n location: Partial<esbuild.Location>;\n};\n\n/**\n * Get the package name from a file path.\n * @param filePath - The file path to get the package name from.\n * @returns The package name.\n */\nexport function getPackageName(filePath: string) {\n const normalized = filePath.replace(/\\\\/g, '/');\n const marker = '/node_modules/';\n const idx = normalized.lastIndexOf(marker);\n if (idx === -1) return null;\n\n const after = normalized.slice(idx + marker.length); // e.g. \".pnpm/node-fetch@3.3.2/node_modules/node-fetch/src/index.js\"\n const segments = after.split('/');\n if (!segments.length) return null;\n\n let packageName = segments[0];\n\n // pnpm nests: \".pnpm/<pkg>@<version>/node_modules/<pkg>/...\"\n if (packageName === '.pnpm' && segments.length >= 3) {\n packageName = segments[2];\n } else if (packageName.startsWith('@') && segments.length >= 2) {\n packageName = `${segments[0]}/${segments[1]}`;\n }\n\n return packageName;\n}\n\n/**\n * Get the package name from an import specifier.\n * @param specifier - The import specifier to parse.\n * @returns The package name (for bare package imports), otherwise null.\n */\nfunction getPackageNameFromSpecifier(specifier: string) {\n // Not a bare package specifier (relative, absolute, or URL-like)\n if (\n !specifier ||\n specifier.startsWith('.') ||\n specifier.startsWith('/') ||\n /^[A-Za-z]:[\\\\/]/.test(specifier)\n ) {\n return null;\n }\n\n // Ignore runtime built-ins and URL-like specifiers\n if (\n runtimeModulesRegex.test(specifier) ||\n specifier.includes('://') ||\n specifier.startsWith('#')\n ) {\n return null;\n }\n\n const normalized = specifier.replace(/\\\\/g, '/');\n if (normalized.startsWith('@')) {\n const [scope, name] = normalized.split('/');\n if (!scope || !name) {\n return null;\n }\n return `${scope}/${name}`;\n }\n\n const [name] = normalized.split('/');\n return name ?? null;\n}\n\n/**\n * Escape a regular expression string.\n * @param value - The string to escape.\n * @returns The escaped string.\n */\nexport function escapeRegExp(value: string) {\n return value.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\$&');\n}\n\n/**\n * Get the imported identifier from a specifier.\n * @param specifier - The specifier to get the imported identifier from.\n * @returns The imported identifier.\n */\nexport function getImportedIdentifier(specifier: string) {\n const namespaceMatch = specifier.match(/\\*\\s+as\\s+([A-Za-z0-9_$]+)/);\n if (namespaceMatch) {\n return namespaceMatch[1];\n }\n\n if (specifier.includes('{')) {\n const inside = specifier.replace(/^[^{]*\\{/, '').replace(/\\}.*$/, '');\n const firstNamed = inside\n .split(',')\n .map((token) => token.trim())\n .find(Boolean);\n\n if (firstNamed) {\n const aliasMatch = firstNamed.match(\n /([A-Za-z0-9_$]+)\\s+as\\s+([A-Za-z0-9_$]+)/\n );\n if (aliasMatch) {\n return aliasMatch[2];\n }\n // Validate that firstNamed is a valid identifier (not empty braces or whitespace)\n const identifierMatch = firstNamed.match(/^[A-Za-z_$][A-Za-z0-9_$]*/);\n if (identifierMatch) {\n return identifierMatch[0];\n }\n }\n // Empty braces or no valid identifier found - return undefined\n return undefined;\n }\n\n const defaultPart = specifier.split(',')[0]?.trim();\n if (defaultPart && defaultPart !== '*') {\n return defaultPart;\n }\n}\n\n/**\n * Find the usage of an identifier in a list of lines.\n * @param lines - The list of lines to search in.\n * @param startIndex - The index to start searching from.\n * @param identifier - The identifier to search for.\n * @returns The usage of the identifier.\n */\nfunction findIdentifierUsage(\n lines: string[],\n startIndex: number,\n identifier: string\n) {\n const usageRegex = new RegExp(`\\\\b${escapeRegExp(identifier)}\\\\b`);\n let inBlockComment = false;\n\n for (let i = startIndex; i < lines.length; i += 1) {\n // Strip string literals first so that comment delimiters inside strings\n // (e.g. `const s = \"/*\";`) don't confuse the comment scanner.\n const stringsStripped = lines[i]\n .replace(/'(?:[^'\\\\]|\\\\.)*'/g, (s) => ' '.repeat(s.length))\n .replace(/\"(?:[^\"\\\\]|\\\\.)*\"/g, (s) => ' '.repeat(s.length))\n .replace(/`(?:[^`\\\\]|\\\\.)*`/g, (s) => ' '.repeat(s.length));\n\n let line = stringsStripped;\n\n // Handle multi-line block comments (including JSDoc)\n if (inBlockComment) {\n const endIdx = line.indexOf('*/');\n if (endIdx === -1) {\n continue;\n }\n line = ' '.repeat(endIdx + 2) + line.slice(endIdx + 2);\n inBlockComment = false;\n }\n\n // Scan for comments, replacing them with spaces\n let processed = '';\n let j = 0;\n while (j < line.length) {\n if (line[j] === '/' && line[j + 1] === '/') {\n processed += ' '.repeat(line.length - j);\n break;\n }\n if (line[j] === '/' && line[j + 1] === '*') {\n const endIdx = line.indexOf('*/', j + 2);\n if (endIdx !== -1) {\n const len = endIdx + 2 - j;\n processed += ' '.repeat(len);\n j = endIdx + 2;\n } else {\n processed += ' '.repeat(line.length - j);\n inBlockComment = true;\n break;\n }\n } else {\n processed += line[j];\n j += 1;\n }\n }\n\n const match = processed.match(usageRegex);\n if (match && match.index !== undefined) {\n return {\n line: i,\n column: match.index,\n lineText: lines[i],\n };\n }\n }\n}\n\n/**\n * Get the location of a violation.\n * @param cwd - The current working directory.\n * @param relativePath - The relative path to the file.\n * @param packageName - The name of the package.\n * @returns The location of the violation.\n */\nexport async function getViolationLocation(\n cwd: string,\n relativePath: string,\n packageName: string\n) {\n try {\n const absolutePath = resolve(cwd, relativePath);\n const contents = await readFile(absolutePath, 'utf8');\n const lines = contents.split(/\\r?\\n/);\n\n const importRegex = new RegExp(\n `import\\\\s+(.+?)\\\\s+from\\\\s+['\"]${escapeRegExp(packageName)}(?:/[^'\"]*)?['\"]`\n );\n\n for (let i = 0; i < lines.length; i += 1) {\n const line = lines[i];\n const importMatch = line.match(importRegex);\n\n if (importMatch && importMatch.index !== undefined) {\n const specifier = importMatch[1].trim();\n const identifier = getImportedIdentifier(specifier);\n if (identifier) {\n const usage = findIdentifierUsage(lines, i + 1, identifier);\n if (usage) {\n return {\n file: relativePath,\n line: usage.line + 1,\n column: usage.column,\n lineText: usage.lineText,\n length: identifier.length,\n };\n }\n\n // Identifier exists but is never referenced; surface no location\n return undefined;\n }\n\n // Fallback: if we can't extract identifier, point to package name\n const columnIndex = line.indexOf(packageName);\n if (columnIndex !== -1) {\n return {\n file: relativePath,\n line: i + 1,\n column: columnIndex,\n lineText: line,\n length: packageName.length,\n };\n }\n }\n }\n } catch {\n // ignore file read failures, fallback to no location info\n }\n}\n\n/**\n * Get the module type label for error messages.\n * @param modulePath - The module path to check.\n * @returns The module type label.\n */\nfunction getModuleTypeLabel(modulePath: string): string {\n if (bunModulesRegex.test(modulePath)) {\n return 'Bun';\n }\n return 'Node.js';\n}\n\n/**\n * Create an esbuild plugin to detect violations of the Node.js module usage rule.\n * This plugin prevents workflow functions from importing Node.js or Bun built-in\n * modules, which are not available in the sandboxed workflow runtime.\n */\nexport function createNodeModuleErrorPlugin(): esbuild.Plugin {\n return {\n name: 'workflow-node-module-error',\n setup(build) {\n const cwd = process.cwd();\n const importParents = new Map<string, string>();\n const packageViolations: PackageViolation[] = [];\n const seenViolations = new Set<string>();\n\n // Track ALL import relationships to build the dependency graph.\n // This is necessary to trace transitive dependencies back to user code.\n // Performance impact is minimal as we only store path mappings.\n build.onResolve({ filter: /.*/ }, async (args) => {\n if (!args.importer) return null;\n\n const parentValue = normalize(args.importer);\n const specifierPackageName = getPackageNameFromSpecifier(args.path);\n\n try {\n const resolvedChild = await enhancedResolve(\n args.resolveDir,\n args.path\n );\n\n if (resolvedChild) {\n const childKey = normalize(resolvedChild);\n importParents.set(childKey, parentValue);\n\n // Record the resolved package edge so transitive builtin usage can\n // still trace back even when esbuild and enhanced-resolve pick\n // different entry files (e.g. `module` vs `main`).\n const resolvedPackageName = getPackageName(childKey);\n if (resolvedPackageName) {\n importParents.set(resolvedPackageName, parentValue);\n }\n }\n\n // Also preserve the bare package-specifier edge (e.g. \"postgres\"),\n // which is the fallback key used when tracing from files in\n // node_modules back to user code.\n if (specifierPackageName) {\n importParents.set(specifierPackageName, parentValue);\n }\n } catch {\n // For built-in modules that can't be resolved, still track using the import path\n const childKey = args.path;\n importParents.set(childKey, parentValue);\n\n if (specifierPackageName) {\n importParents.set(specifierPackageName, parentValue);\n }\n }\n return null;\n });\n\n // Detect Node.js and Bun module imports\n build.onResolve({ filter: runtimeModulesRegex }, async (args) => {\n const importerPath = resolve(cwd, args.importer);\n let current = importerPath;\n const chain: string[] = [];\n const visited = new Set<string>();\n while (current) {\n if (visited.has(current)) {\n break;\n }\n visited.add(current);\n chain.push(current);\n let next = importParents.get(current);\n\n // If we can't find the parent and current is in node_modules,\n // try looking up by potential package import strings\n if (!next && current.includes('node_modules')) {\n const packageName = getPackageName(current);\n if (packageName) {\n // Try the package name directly\n next = importParents.get(packageName);\n if (!next) {\n // Try with node: prefix\n next = importParents.get(`node:${packageName}`);\n }\n }\n }\n\n current = next ?? '';\n }\n const filteredChain = chain.filter(\n (path) => !path.includes('node_modules')\n );\n\n const workflowFile = filteredChain[0] ?? importerPath;\n\n if (!workflowFile || workflowFile.includes('node_modules')) {\n return {\n path: args.path,\n external: true,\n };\n }\n\n const packageName = importerPath.includes('node_modules')\n ? (getPackageName(importerPath) ?? args.path)\n : args.path;\n\n const relativeWorkflowFile = relative(cwd, workflowFile);\n const violationKey = `${packageName}:${relativeWorkflowFile}`;\n\n if (!seenViolations.has(violationKey)) {\n seenViolations.add(violationKey);\n const location = await getViolationLocation(\n cwd,\n relativeWorkflowFile,\n packageName\n );\n // Only report violations where we can find the import location.\n // If we can't find it, the package is likely a transitive dependency\n // that the user didn't directly import - we'll report the top-level\n // package they did import instead.\n if (location) {\n packageViolations.push({\n path: args.path,\n importer: relativeWorkflowFile,\n packageName,\n location,\n });\n }\n }\n\n return {\n path: args.path,\n external: true,\n };\n });\n\n // Report all violations at the end of the build\n build.onEnd(() => {\n if (packageViolations.length > 0) {\n return {\n errors: packageViolations.map((violation) => {\n const isBuiltinModule = runtimeModulesRegex.test(\n violation.packageName\n );\n const moduleType = getModuleTypeLabel(violation.path);\n\n // Different messages for built-in modules vs npm packages that use them\n const text = isBuiltinModule\n ? `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}`\n : `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}`;\n\n return {\n text,\n location: violation.location\n ? {\n ...violation.location,\n suggestion: 'Move this function into a step function.',\n }\n : undefined,\n };\n }),\n };\n }\n });\n },\n };\n}\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"node-module-esbuild-plugin.test.js","sourceRoot":"","sources":["../src/node-module-esbuild-plugin.test.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,WAAW,EACX,YAAY,EACZ,YAAY,EACZ,MAAM,EACN,aAAa,GACd,MAAM,SAAS,CAAC;AAIjB,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AACjC,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEpD,wEAAwE;AACxE,MAAM,UAAU,GAAG,YAAY,CAAC,MAAM,EAAE,CAAC,CAAC;AAE1C,OAAO,KAAK,OAAO,MAAM,SAAS,CAAC;AACnC,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,QAAQ,CAAC;AAC9C,OAAO,EACL,2BAA2B,EAC3B,YAAY,EACZ,qBAAqB,EACrB,cAAc,EACd,oBAAoB,GACrB,MAAM,iCAAiC,CAAC;AAEzC,KAAK,UAAU,0BAA0B,CACvC,MAAc,EACd,YAA2C,EAAE;IAE7C,MAAM,OAAO,GAAG,WAAW,CAAC,IAAI,CAAC,UAAU,EAAE,0BAA0B,CAAC,CAAC,CAAC;IAC1E,MAAM,SAAS,GAAG,IAAI,CAAC,OAAO,EAAE,aAAa,CAAC,CAAC;IAC/C,aAAa,CAAC,SAAS,EAAE,MAAM,CAAC,CAAC;IACjC,MAAM,aAAa,GAAG,QAAQ,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,SAAS,CAAC,CAAC;IAEzD,IAAI,CAAC;QACH,MAAM,OAAO,CAAC,KAAK,CAAC;YAClB,WAAW,EAAE,CAAC,SAAS,CAAC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AgD,EAAE,KAAK,IAAI,EAAE;YAC9D,MAAM,GAAG,GAAG,OAAO,CAAC,GAAG,EAAE,CAAC;YAC1B,MAAM,QAAQ,GAAG,MAAM,oBAAoB,CACzC,GAAG,EACH,sBAAsB,EACtB,cAAc,CACf,CAAC;YAEF,MAAM,CAAC,QAAQ,CAAC,CAAC,aAAa,EAAE,CAAC;QACnC,CAAC,CAAC,CAAC;QAEH,EAAE,CAAC,8DAA8D,EAAE,KAAK,IAAI,EAAE;YAC5E,MAAM,GAAG,GAAG,OAAO,CAAC,GAAG,EAAE,CAAC;YAC1B,MAAM,QAAQ,GAAG,wCAAwC,CAAC;YAE1D,gDAAgD;YAChD,MAAM,QAAQ,GAAG,MAAM,oBAAoB,CACzC,GAAG,EACH,QAAQ,EACR,sBAAsB,CACvB,CAAC;YAEF,MAAM,CAAC,QAAQ,CAAC,CAAC,aAAa,EAAE,CAAC;QACnC,CAAC,CAAC,CAAC;QAEH,EAAE,CAAC,wEAAwE,EAAE,KAAK,IAAI,EAAE;YACtF,MAAM,GAAG,GAAG,OAAO,CAAC,GAAG,EAAE,CAAC;YAC1B,MAAM,QAAQ,GAAG,wCAAwC,CAAC;YAE1D,sEAAsE;YACtE,MAAM,QAAQ,GAAG,MAAM,oBAAoB,CAAC,GAAG,EAAE,QAAQ,EAAE,WAAW,CAAC,CAAC;YAExE,sEAAsE;YACtE,kCAAkC;YAClC,MAAM,CAAC,QAAQ,CAAC,CAAC,aAAa,EAAE,CAAC;QACnC,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","sourcesContent":["import {\n mkdtempSync,\n readFileSync,\n realpathSync,\n rmSync,\n writeFileSync,\n} from 'node:fs';\n// @ts-expect-error - Intentionally unused import for testing getViolationLocation\n// with an import that exists but is never referenced in code\nimport http from 'node:http';\nimport { tmpdir } from 'node:os';\nimport { join, relative, resolve } from 'node:path';\n\n// Resolve symlinks in tmpdir to avoid macOS /var -> /private/var issues\nconst realTmpdir = realpathSync(tmpdir());\n\nimport * as esbuild from 'esbuild';\nimport { describe, expect, it } from 'vitest';\nimport {\n createNodeModuleErrorPlugin,\n escapeRegExp,\n getImportedIdentifier,\n getPackageName,\n getViolationLocation,\n} from './node-module-esbuild-plugin.js';\n\nasync function buildWorkflowWithViolation(\n source: string,\n overrides: Partial<esbuild.BuildOptions> = {}\n) {\n const tempDir = mkdtempSync(join(realTmpdir, 'node-module-plugin-test-'));\n const entryFile = join(tempDir, 'workflow.ts');\n writeFileSync(entryFile, source);\n const relativeEntry = relative(process.cwd(), entryFile);\n\n try {\n await esbuild.build({\n entryPoints: [entryFile],\n bundle: true,\n write: false,\n platform: 'neutral',\n logLevel: 'silent',\n plugins: [createNodeModuleErrorPlugin(), ...(overrides.plugins ?? [])],\n ...overrides,\n });\n throw new Error('Expected build to fail');\n } catch (error: any) {\n if (error && typeof error === 'object' && 'errors' in error) {\n return {\n failure: error as esbuild.BuildFailure,\n relativeEntry,\n };\n }\n throw error;\n } finally {\n rmSync(tempDir, { recursive: true, force: true });\n }\n}\n\ndescribe('workflow-node-module-error plugin', () => {\n it('should error on fs import', async () => {\n const testCode = `\n import { readFile } from \"fs\";\n export function workflow() {\n return readFile(\"test.txt\");\n }\n `;\n\n const { failure, relativeEntry } =\n await buildWorkflowWithViolation(testCode);\n\n expect(failure.errors).toHaveLength(1);\n const violation = failure.errors[0];\n expect(violation.text).toContain(\n 'You are attempting to use \"fs\" which is a Node.js module'\n );\n expect(violation.location).toMatchObject({\n file: relativeEntry,\n suggestion: 'Move this function into a step function.',\n });\n expect(violation.location?.line).toBeGreaterThan(0);\n expect(violation.location?.column).toBeGreaterThanOrEqual(0);\n expect(violation.location?.lineText).toContain('readFile');\n });\n\n it('should error on node: prefixed imports', async () => {\n const testCode = `\n import { readFile } from \"node:fs\";\n export function workflow() {\n return readFile;\n }\n `;\n\n const { failure, relativeEntry } = await buildWorkflowWithViolation(\n testCode,\n { format: 'cjs' }\n );\n\n expect(failure.errors).toHaveLength(1);\n const violation = failure.errors[0];\n expect(violation.text).toContain(\n 'You are attempting to use \"node:fs\" which is a Node.js module'\n );\n expect(violation.location).toMatchObject({\n file: relativeEntry,\n suggestion: 'Move this function into a step function.',\n });\n expect(violation.location?.lineText).toContain('readFile');\n });\n\n it('should error on multiple Node.js imports', async () => {\n const testCode = `\n import { readFile } from \"fs\";\n import { join } from \"path\";\n export function workflow() {\n return readFile(join(\"a\", \"b\"));\n }\n `;\n\n const { failure, relativeEntry } = await buildWorkflowWithViolation(\n testCode,\n { format: 'cjs' }\n );\n\n expect(failure.errors).toHaveLength(2);\n\n const packages = failure.errors.map((error) => ({\n text: error.text,\n location: error.location,\n }));\n\n const fsViolation = packages.find((pkg) => pkg.text.includes('\"fs\"'));\n const pathViolation = packages.find((pkg) => pkg.text.includes('\"path\"'));\n\n expect(fsViolation?.text).toContain('which is a Node.js module');\n expect(pathViolation?.text).toContain('which is a Node.js module');\n\n expect(fsViolation?.location).toMatchObject({\n file: relativeEntry,\n suggestion: 'Move this function into a step function.',\n });\n expect(fsViolation?.location?.lineText).toContain('readFile');\n expect(pathViolation?.location).toMatchObject({\n file: relativeEntry,\n suggestion: 'Move this function into a step function.',\n });\n expect(pathViolation?.location?.lineText).toContain('join');\n });\n\n it('should show top-level package name for nested Node.js imports', async () => {\n // This test validates that when a package in node_modules internally uses\n // Node.js built-in modules, the error message shows the top-level package name\n // (e.g., \"fake-package\") instead of the internal built-in (e.g., \"stream\").\n //\n // We create a real node_modules directory structure to simulate this scenario.\n const tempDir = mkdtempSync(join(realTmpdir, 'node-module-plugin-test-'));\n const nodeModulesDir = join(tempDir, 'node_modules', 'fake-package');\n const { mkdirSync } = await import('node:fs');\n mkdirSync(nodeModulesDir, { recursive: true });\n\n const fakePackageCode = `\n import { Stream } from \"stream\";\n export function fakePackage() {\n return new Stream();\n }\n `;\n writeFileSync(join(nodeModulesDir, 'index.js'), fakePackageCode);\n writeFileSync(\n join(nodeModulesDir, 'package.json'),\n JSON.stringify({ name: 'fake-package', main: 'index.js' })\n );\n\n const testCode = `\n import { fakePackage } from \"fake-package\";\n export function workflow() {\n return fakePackage();\n }\n `;\n const entryFile = join(tempDir, 'workflow.ts');\n writeFileSync(entryFile, testCode);\n const relativeEntry = relative(process.cwd(), entryFile);\n\n try {\n await esbuild.build({\n entryPoints: [entryFile],\n bundle: true,\n write: false,\n platform: 'neutral',\n logLevel: 'silent',\n plugins: [createNodeModuleErrorPlugin()],\n });\n throw new Error('Expected build to fail');\n } catch (error: any) {\n if (error && typeof error === 'object' && 'errors' in error) {\n const failure = error as esbuild.BuildFailure;\n expect(failure.errors).toHaveLength(1);\n const violation = failure.errors[0];\n // Should mention the top-level package \"fake-package\", not the internal \"stream\" module\n expect(violation.text).toContain('\"fake-package\"');\n expect(violation.text).toContain('which depends on Node.js modules');\n expect(violation.text).not.toContain('\"stream\"');\n expect(violation.location).toMatchObject({\n file: relativeEntry,\n });\n } else {\n throw error;\n }\n } finally {\n rmSync(tempDir, { recursive: true, force: true });\n }\n });\n\n it('should detect packages when esbuild and resolver choose different entry fields', async () => {\n const tempDir = mkdtempSync(join(realTmpdir, 'node-module-plugin-test-'));\n const nodeModulesDir = join(tempDir, 'node_modules', 'dual-entry-package');\n const esmDir = join(nodeModulesDir, 'esm');\n const cjsDir = join(nodeModulesDir, 'cjs');\n const { mkdirSync } = await import('node:fs');\n mkdirSync(esmDir, { recursive: true });\n mkdirSync(cjsDir, { recursive: true });\n\n writeFileSync(\n join(esmDir, 'index.js'),\n `\n import os from \"os\";\n export function getPlatform() {\n return os.platform();\n }\n `\n );\n writeFileSync(\n join(cjsDir, 'index.cjs'),\n `\n module.exports = {\n getPlatform() {\n return \"cjs\";\n }\n };\n `\n );\n writeFileSync(\n join(nodeModulesDir, 'package.json'),\n JSON.stringify({\n name: 'dual-entry-package',\n main: 'cjs/index.cjs',\n module: 'esm/index.js',\n })\n );\n\n const testCode = `\n import { getPlatform } from \"dual-entry-package\";\n export function workflow() {\n return getPlatform();\n }\n `;\n const entryFile = join(tempDir, 'workflow.ts');\n writeFileSync(entryFile, testCode);\n const relativeEntry = relative(process.cwd(), entryFile);\n\n try {\n await esbuild.build({\n entryPoints: [entryFile],\n bundle: true,\n write: false,\n platform: 'neutral',\n format: 'cjs',\n mainFields: ['module', 'main'],\n logLevel: 'silent',\n plugins: [createNodeModuleErrorPlugin()],\n });\n throw new Error('Expected build to fail');\n } catch (error: any) {\n if (error && typeof error === 'object' && 'errors' in error) {\n const failure = error as esbuild.BuildFailure;\n expect(failure.errors).toHaveLength(1);\n const violation = failure.errors[0];\n expect(violation.text).toContain('\"dual-entry-package\"');\n expect(violation.text).toContain('depends on Node.js modules');\n expect(violation.location).toMatchObject({\n file: relativeEntry,\n });\n } else {\n throw error;\n }\n } finally {\n rmSync(tempDir, { recursive: true, force: true });\n }\n });\n\n it('should find usage of namespace imports', async () => {\n const testCode = `\n import * as fs from \"fs\";\n export function workflow() {\n return fs.readFile(\"test.txt\");\n }\n `;\n\n const { failure, relativeEntry } =\n await buildWorkflowWithViolation(testCode);\n\n expect(failure.errors).toHaveLength(1);\n const violation = failure.errors[0];\n expect(violation.text).toContain('\"fs\" which is a Node.js module');\n expect(violation.location).toMatchObject({\n file: relativeEntry,\n });\n expect(violation.location?.lineText).toContain('fs.readFile');\n });\n\n it('should find usage of default imports', async () => {\n const testCode = `\n import fs from \"fs\";\n export function workflow() {\n return fs.readFile(\"test.txt\");\n }\n `;\n\n const { failure, relativeEntry } =\n await buildWorkflowWithViolation(testCode);\n\n expect(failure.errors).toHaveLength(1);\n const violation = failure.errors[0];\n expect(violation.text).toContain('\"fs\" which is a Node.js module');\n expect(violation.location).toMatchObject({\n file: relativeEntry,\n });\n expect(violation.location?.lineText).toContain('fs.readFile');\n });\n\n it('should find usage of aliased imports', async () => {\n const testCode = `\n import { readFile as read } from \"fs\";\n export function workflow() {\n return read(\"test.txt\");\n }\n `;\n\n const { failure, relativeEntry } =\n await buildWorkflowWithViolation(testCode);\n\n expect(failure.errors).toHaveLength(1);\n const violation = failure.errors[0];\n expect(violation.text).toContain('\"fs\" which is a Node.js module');\n expect(violation.location).toMatchObject({\n file: relativeEntry,\n });\n // Should point to the aliased identifier \"read\", not \"readFile\"\n expect(violation.location?.lineText).toContain('read(');\n });\n\n it('should not error when import is unused (tree-shaken)', async () => {\n // Note: esbuild tree-shakes unused imports, so they never trigger resolution.\n // This is expected behavior - if the import isn't used, the module won't be bundled.\n const testCode = `\n import { readFile } from \"fs\";\n export function workflow() {\n return \"no fs usage\";\n }\n `;\n\n const tempDir = mkdtempSync(join(realTmpdir, 'node-module-plugin-test-'));\n const entryFile = join(tempDir, 'workflow.ts');\n writeFileSync(entryFile, testCode);\n\n try {\n // Build should succeed because unused imports are tree-shaken\n const result = await esbuild.build({\n entryPoints: [entryFile],\n bundle: true,\n write: false,\n platform: 'neutral',\n logLevel: 'silent',\n plugins: [createNodeModuleErrorPlugin()],\n });\n expect(result.errors).toHaveLength(0);\n } finally {\n rmSync(tempDir, { recursive: true, force: true });\n }\n });\n\n it('should not point to JSDoc comments when finding usage', async () => {\n const testCode = `\n import { Writable } from \"stream\";\n /**\n * Convert a Web WritableStream<string> into a Node.js Writable stream\n */\n export function workflow() {\n return new Writable();\n }\n `;\n\n const { failure } = await buildWorkflowWithViolation(testCode);\n\n expect(failure.errors).toHaveLength(1);\n const violation = failure.errors[0];\n expect(violation.text).toContain('\"stream\" which is a Node.js module');\n // Should point to the actual code usage, not the JSDoc comment\n expect(violation.location?.lineText).toContain('new Writable()');\n expect(violation.location?.lineText).not.toContain('*');\n });\n\n it('should not point to single-line block comments when finding usage', async () => {\n const testCode = `\n import { Writable } from \"stream\";\n /* Writable is used below */\n export function workflow() {\n return new Writable();\n }\n `;\n\n const { failure } = await buildWorkflowWithViolation(testCode);\n\n expect(failure.errors).toHaveLength(1);\n const violation = failure.errors[0];\n // Should point to the actual code usage, not the comment\n expect(violation.location?.lineText).toContain('new Writable()');\n });\n\n it('should not treat comment delimiters inside strings as comments', async () => {\n const testCode = `\n import { Writable } from \"stream\";\n const pattern = \"/* Writable */\";\n export function workflow() {\n return new Writable();\n }\n `;\n\n const { failure } = await buildWorkflowWithViolation(testCode);\n\n expect(failure.errors).toHaveLength(1);\n const violation = failure.errors[0];\n expect(violation.text).toContain('\"stream\" which is a Node.js module');\n // Should point to actual code, not the string containing \"Writable\"\n expect(violation.location?.lineText).toContain('new Writable()');\n });\n\n it('should error on Bun module imports', async () => {\n const testCode = `\n import { serve } from \"bun\";\n export function workflow() {\n return serve({ port: 3000 });\n }\n `;\n\n const { failure, relativeEntry } =\n await buildWorkflowWithViolation(testCode);\n\n expect(failure.errors).toHaveLength(1);\n const violation = failure.errors[0];\n expect(violation.text).toContain('\"bun\" which is a Bun module');\n expect(violation.text).toContain('Bun modules are not available');\n expect(violation.location).toMatchObject({\n file: relativeEntry,\n });\n });\n\n it('should error on Bun subpath imports', async () => {\n const testCode = `\n import { Database } from \"bun:sqlite\";\n export function workflow() {\n return new Database(\"test.db\");\n }\n `;\n\n const { failure, relativeEntry } =\n await buildWorkflowWithViolation(testCode);\n\n expect(failure.errors).toHaveLength(1);\n const violation = failure.errors[0];\n expect(violation.text).toContain('\"bun:sqlite\" which is a Bun module');\n expect(violation.text).toContain('Bun modules are not available');\n expect(violation.location).toMatchObject({\n file: relativeEntry,\n });\n });\n});\n\ndescribe('workflow-node-module-error helper functions', () => {\n describe('getPackageName', () => {\n it('should get the package name from simple node_modules path', () => {\n const packageName = getPackageName(\n '/Users/adrianlam/GitHub/workflow/node_modules/node-fetch/src/index.js'\n );\n expect(packageName).toBe('node-fetch');\n });\n\n it('should get the package name from pnpm nested path', () => {\n const packageName = getPackageName(\n '/Users/adrianlam/GitHub/workflow/node_modules/.pnpm/node-fetch@3.3.2/node_modules/node-fetch/src/index.js'\n );\n expect(packageName).toBe('node-fetch');\n });\n\n it('should get scoped package name', () => {\n const packageName = getPackageName(\n '/project/node_modules/@supabase/supabase-js/dist/index.js'\n );\n expect(packageName).toBe('@supabase/supabase-js');\n });\n\n it('should return null for paths without node_modules', () => {\n const packageName = getPackageName(\n '/Users/adrianlam/GitHub/workflow/src/index.js'\n );\n expect(packageName).toBeNull();\n });\n });\n\n describe('escapeRegExp', () => {\n it('should escape regex special characters', () => {\n expect(escapeRegExp('test.file')).toBe('test\\\\.file');\n expect(escapeRegExp('test*file')).toBe('test\\\\*file');\n expect(escapeRegExp('test+file')).toBe('test\\\\+file');\n expect(escapeRegExp('test?file')).toBe('test\\\\?file');\n expect(escapeRegExp('test^file')).toBe('test\\\\^file');\n expect(escapeRegExp('test$file')).toBe('test\\\\$file');\n });\n\n it('should escape brackets and braces', () => {\n expect(escapeRegExp('test{file}')).toBe('test\\\\{file\\\\}');\n expect(escapeRegExp('test[file]')).toBe('test\\\\[file\\\\]');\n expect(escapeRegExp('test(file)')).toBe('test\\\\(file\\\\)');\n });\n\n it('should escape pipes and backslashes', () => {\n expect(escapeRegExp('test|file')).toBe('test\\\\|file');\n expect(escapeRegExp('test\\\\file')).toBe('test\\\\\\\\file');\n });\n\n it('should handle strings without special characters', () => {\n expect(escapeRegExp('testfile')).toBe('testfile');\n expect(escapeRegExp('test-file')).toBe('test-file');\n });\n\n it('should handle package names with special characters', () => {\n expect(escapeRegExp('@supabase/supabase-js')).toBe(\n '@supabase/supabase-js'\n );\n expect(escapeRegExp('package.name')).toBe('package\\\\.name');\n });\n });\n\n describe('getImportedIdentifier', () => {\n it('should extract namespace import identifier', () => {\n expect(getImportedIdentifier('* as fs')).toBe('fs');\n expect(getImportedIdentifier('* as path')).toBe('path');\n });\n\n it('should extract first named import', () => {\n expect(getImportedIdentifier('{ readFile }')).toBe('readFile');\n expect(getImportedIdentifier('{ readFile, writeFile }')).toBe('readFile');\n });\n\n it('should extract aliased named import', () => {\n expect(getImportedIdentifier('{ readFile as read }')).toBe('read');\n expect(getImportedIdentifier('{ readFile as read, writeFile }')).toBe(\n 'read'\n );\n });\n\n it('should extract default import', () => {\n expect(getImportedIdentifier('fs')).toBe('fs');\n expect(getImportedIdentifier('myDefault')).toBe('myDefault');\n });\n\n it('should extract first identifier from mixed imports', () => {\n // The function checks for braces first, so it extracts from named imports\n expect(getImportedIdentifier('fs, { readFile }')).toBe('readFile');\n expect(getImportedIdentifier('defaultExport, { named }')).toBe('named');\n });\n\n it('should handle whitespace variations', () => {\n expect(getImportedIdentifier(' { readFile } ')).toBe('readFile');\n expect(getImportedIdentifier('{readFile}')).toBe('readFile');\n expect(getImportedIdentifier('{ readFile , writeFile }')).toBe(\n 'readFile'\n );\n });\n\n it('should handle complex named imports', () => {\n expect(getImportedIdentifier('type { ReadStream }')).toBe('ReadStream');\n expect(getImportedIdentifier('{ default as fs }')).toBe('fs');\n });\n\n it('should return undefined for edge cases', () => {\n expect(getImportedIdentifier('*')).toBeUndefined();\n expect(getImportedIdentifier('')).toBeUndefined();\n // Empty braces should return undefined since there's no valid identifier\n expect(getImportedIdentifier('{}')).toBeUndefined();\n });\n });\n\n describe('getViolationLocation', () => {\n it('should find violation location for package name that appears in file', async () => {\n // Use the actual monorepo root as cwd\n const cwd = process.cwd();\n const testFile = 'src/node-module-esbuild-plugin.test.ts';\n\n // Test with 'vitest' which is actually imported in this file\n const location = await getViolationLocation(cwd, testFile, 'vitest');\n\n // The function should find 'vitest' in the import statement\n expect(location).toBeDefined();\n expect(location?.file).toBe(testFile);\n\n const contents = readFileSync(resolve(cwd, testFile), 'utf8');\n const lines = contents.split(/\\r?\\n/);\n const expectedLine =\n lines.findIndex((line) => line.includes(`describe(`)) + 1;\n\n expect(location?.line).toBe(expectedLine);\n expect(location?.column).toBe(0);\n expect(location?.lineText).toContain(`describe(`);\n expect(location?.length).toBe(8);\n });\n\n it('should return undefined for non-existent files', async () => {\n const cwd = process.cwd();\n const location = await getViolationLocation(\n cwd,\n 'non-existent-file.ts',\n 'some-package'\n );\n\n expect(location).toBeUndefined();\n });\n\n it('should return undefined for files without the package import', async () => {\n const cwd = process.cwd();\n const testFile = 'src/node-module-esbuild-plugin.test.ts';\n\n // This package is not imported in the test file\n const location = await getViolationLocation(\n cwd,\n testFile,\n 'non-existent-package'\n );\n\n expect(location).toBeUndefined();\n });\n\n it('should return undefined when import is unused even if it can be parsed', async () => {\n const cwd = process.cwd();\n const testFile = 'src/node-module-esbuild-plugin.test.ts';\n\n // Test with 'node:http' which is imported in this file but never used\n const location = await getViolationLocation(cwd, testFile, 'node:http');\n\n // Since the identifier is never referenced (only imported), we should\n // not produce a location preview.\n expect(location).toBeUndefined();\n });\n });\n});\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"pseudo-package-esbuild-plugin.js","sourceRoot":"","sources":["../src/pseudo-package-esbuild-plugin.ts"],"names":[],"mappings":"AAEA;;;;GAIG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG,IAAI,GAAG,CAAC;IACrC,aAAa;IACb,aAAa;IACb,gCAAgC;IAChC,gCAAgC;CACjC,CAAC,CAAC;AAEH;;;;;;;;;;GAUG;AACH,MAAM,UAAU,yBAAyB;IACvC,OAAO;QACL,IAAI,EAAE,0BAA0B;QAChC,KAAK,CAAC,KAA0B;YAC9B,qEAAqE;YACrE,KAAK,CAAC,SAAS,CAAC,EAAE,MAAM,EAAE,IAAI,EAAE,EAAE,CAAC,IAA2B,EAAE,EAAE;gBAChE,IAAI,eAAe,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC;oBACnC,OAAO;wBACL,IAAI,EAAE,IAAI,CAAC,IAAI;wBACf,SAAS,EAAE,gBAAgB;qBAC5B,CAAC;gBACJ,CAAC;gBACD,OAAO,IAAI,CAAC;YACd,CAAC,CAAC,CAAC;YAEH,mDAAmD;YACnD,KAAK,CAAC,MAAM,CACV,EAAE,MAAM,EAAE,IAAI,EAAE,SAAS,EAAE,gBAAgB,EAAE,EAC7C,CAAC,IAAwB,EAAE,EAAE;gBAC3B,OAAO;oBACL,QAAQ,EAAE,sBAAsB,IAAI,CAAC,IAAI,iCAAiC;oBAC1E,MAAM,EAAE,IAAI;iBACb,CAAC;YACJ,CAAC,CACF,CAAC;QACJ,CAAC;KACF,CAAC;AACJ,CAAC","sourcesContent":["import type * as esbuild from 'esbuild';\n\n/**\n * Pseudo-packages are marker packages with no actual functionality - they only\n * throw errors when imported in the wrong context (e.g., client-side vs server-side).\n * In the workflow VM context, we don't need their behavior, so we provide empty modules.\n */\nexport const PSEUDO_PACKAGES = new Set([\n 'server-only',\n 'client-only',\n 'next/dist/compiled/server-only',\n 'next/dist/compiled/client-only',\n]);\n\n/**\n * Creates an esbuild plugin that handles pseudo-packages like 'server-only' and 'client-only'.\n *\n * These packages need special handling because:\n * 1. They have exports defined in package.json that esbuild needs to resolve\n * 2. Without this plugin, esbuild may fail to resolve them during bundling\n * 3. Marking them as external would generate require() calls that don't work in the workflow VM\n *\n * This plugin intercepts imports of these packages and provides empty modules,\n * which is safe because they are marker packages with no actual functionality.\n */\nexport function createPseudoPackagePlugin(): esbuild.Plugin {\n return {\n name: 'workflow-pseudo-packages',\n setup(build: esbuild.PluginBuild) {\n // Intercept imports of pseudo packages and redirect to our namespace\n build.onResolve({ filter: /.*/ }, (args: esbuild.OnResolveArgs) => {\n if (PSEUDO_PACKAGES.has(args.path)) {\n return {\n path: args.path,\n namespace: 'pseudo-package',\n };\n }\n return null;\n });\n\n // Provide empty module content for pseudo packages\n build.onLoad(\n { filter: /.*/, namespace: 'pseudo-package' },\n (args: esbuild.OnLoadArgs) => {\n return {\n contents: `/* Pseudo-package: ${args.path} - no-op in workflow context */`,\n loader: 'js',\n };\n }\n );\n },\n };\n}\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"pseudo-package-esbuild-plugin.test.js","sourceRoot":"","sources":["../src/pseudo-package-esbuild-plugin.test.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,SAAS,EACT,WAAW,EACX,YAAY,EACZ,MAAM,EACN,aAAa,GACd,MAAM,SAAS,CAAC;AACjB,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AACjC,OAAO,EAAE,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AC,KAAK,CAAC,CAAC;QAClC,CAAC;gBAAS,CAAC;YACT,MAAM,CAAC,OAAO,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;QACpD,CAAC;IACH,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","sourcesContent":["import {\n mkdirSync,\n mkdtempSync,\n realpathSync,\n rmSync,\n writeFileSync,\n} from 'node:fs';\nimport { tmpdir } from 'node:os';\nimport { join } from 'node:path';\n\nimport * as esbuild from 'esbuild';\nimport { describe, expect, it } from 'vitest';\nimport {\n createPseudoPackagePlugin,\n PSEUDO_PACKAGES,\n} from './pseudo-package-esbuild-plugin.js';\n\n// Resolve symlinks in tmpdir to avoid macOS /var -> /private/var issues\nconst realTmpdir = realpathSync(tmpdir());\n\nasync function buildWithPlugin(\n source: string,\n plugins: esbuild.Plugin[] = [createPseudoPackagePlugin()]\n): Promise<{ result: esbuild.BuildResult; tempDir: string }> {\n const tempDir = mkdtempSync(join(realTmpdir, 'pseudo-package-plugin-test-'));\n const entryFile = join(tempDir, 'workflow.ts');\n writeFileSync(entryFile, source);\n\n const result = await esbuild.build({\n entryPoints: [entryFile],\n bundle: true,\n write: false,\n platform: 'neutral',\n format: 'cjs',\n logLevel: 'silent',\n plugins,\n });\n\n return { result, tempDir };\n}\n\ndescribe('createPseudoPackagePlugin', () => {\n describe('server-only package', () => {\n it('should replace server-only import with empty module', async () => {\n const testCode = `\n import 'server-only';\n export function workflow() {\n return \"hello\";\n }\n `;\n\n const { result, tempDir } = await buildWithPlugin(testCode);\n\n try {\n expect(result.errors).toHaveLength(0);\n const output = result.outputFiles?.[0].text;\n expect(output).toBeDefined();\n // Should not contain require('server-only') since it's replaced with empty module\n // (esbuild tree-shakes unused imports, so the module content may not appear,\n // but importantly no require() call is generated)\n expect(output).not.toContain(\"require('server-only')\");\n expect(output).not.toContain('require(\"server-only\")');\n } finally {\n rmSync(tempDir, { recursive: true, force: true });\n }\n });\n\n it('should handle server-only alongside other imports', async () => {\n const testCode = `\n import 'server-only';\n const x = 42;\n export function workflow() {\n return x;\n }\n `;\n\n const { result, tempDir } = await buildWithPlugin(testCode);\n\n try {\n expect(result.errors).toHaveLength(0);\n const output = result.outputFiles?.[0].text;\n expect(output).toBeDefined();\n // No require() call should be generated\n expect(output).not.toContain(\"require('server-only')\");\n expect(output).not.toContain('require(\"server-only\")');\n // The actual code should still work\n expect(output).toContain('42');\n } finally {\n rmSync(tempDir, { recursive: true, force: true });\n }\n });\n });\n\n describe('client-only package', () => {\n it('should replace client-only import with empty module', async () => {\n const testCode = `\n import 'client-only';\n export const x = 1;\n `;\n\n const { result, tempDir } = await buildWithPlugin(testCode);\n\n try {\n expect(result.errors).toHaveLength(0);\n const output = result.outputFiles?.[0].text;\n expect(output).toBeDefined();\n // No require() call should be generated\n expect(output).not.toContain(\"require('client-only')\");\n expect(output).not.toContain('require(\"client-only\")');\n } finally {\n rmSync(tempDir, { recursive: true, force: true });\n }\n });\n });\n\n describe('compiled pseudo-packages', () => {\n it('should replace next/dist/compiled/server-only import', async () => {\n const testCode = `\n import 'next/dist/compiled/server-only';\n export const x = 1;\n `;\n\n const { result, tempDir } = await buildWithPlugin(testCode);\n\n try {\n expect(result.errors).toHaveLength(0);\n const output = result.outputFiles?.[0].text;\n expect(output).toBeDefined();\n expect(output).not.toContain(\n \"require('next/dist/compiled/server-only')\"\n );\n expect(output).not.toContain(\n 'require(\"next/dist/compiled/server-only\")'\n );\n } finally {\n rmSync(tempDir, { recursive: true, force: true });\n }\n });\n\n it('should replace next/dist/compiled/client-only import', async () => {\n const testCode = `\n import 'next/dist/compiled/client-only';\n export const x = 1;\n `;\n\n const { result, tempDir } = await buildWithPlugin(testCode);\n\n try {\n expect(result.errors).toHaveLength(0);\n const output = result.outputFiles?.[0].text;\n expect(output).toBeDefined();\n expect(output).not.toContain(\n \"require('next/dist/compiled/client-only')\"\n );\n expect(output).not.toContain(\n 'require(\"next/dist/compiled/client-only\")'\n );\n } finally {\n rmSync(tempDir, { recursive: true, force: true });\n }\n });\n });\n\n describe('both pseudo-packages', () => {\n it('should handle both server-only and client-only in same file', async () => {\n const testCode = `\n import 'server-only';\n import 'client-only';\n export function workflow() {\n return \"mixed\";\n }\n `;\n\n const { result, tempDir } = await buildWithPlugin(testCode);\n\n try {\n expect(result.errors).toHaveLength(0);\n const output = result.outputFiles?.[0].text;\n expect(output).toBeDefined();\n // No require() calls should be generated for either package\n expect(output).not.toContain(\"require('server-only')\");\n expect(output).not.toContain('require(\"server-only\")');\n expect(output).not.toContain(\"require('client-only')\");\n expect(output).not.toContain('require(\"client-only\")');\n } finally {\n rmSync(tempDir, { recursive: true, force: true });\n }\n });\n });\n\n describe('without plugin', () => {\n it('should fail to resolve server-only without the plugin', async () => {\n const testCode = `\n import 'server-only';\n export const x = 1;\n `;\n\n const tempDir = mkdtempSync(\n join(realTmpdir, 'pseudo-package-plugin-test-')\n );\n const entryFile = join(tempDir, 'workflow.ts');\n writeFileSync(entryFile, testCode);\n\n try {\n await esbuild.build({\n entryPoints: [entryFile],\n bundle: true,\n write: false,\n platform: 'neutral',\n format: 'cjs',\n logLevel: 'silent',\n // No plugins - should fail to resolve\n });\n // If we get here, the build succeeded (server-only might be installed)\n // This is okay - we just want to verify the plugin works when the package isn't there\n } catch (error: any) {\n // Expected: esbuild can't resolve server-only\n expect(error.errors?.[0]?.text).toMatch(\n /Could not resolve \"server-only\"/\n );\n } finally {\n rmSync(tempDir, { recursive: true, force: true });\n }\n });\n });\n\n describe('PSEUDO_PACKAGES constant', () => {\n it('should contain next marker packages', () => {\n expect(PSEUDO_PACKAGES.has('server-only')).toBe(true);\n expect(PSEUDO_PACKAGES.has('client-only')).toBe(true);\n expect(PSEUDO_PACKAGES.has('next/dist/compiled/server-only')).toBe(true);\n expect(PSEUDO_PACKAGES.has('next/dist/compiled/client-only')).toBe(true);\n expect(PSEUDO_PACKAGES.size).toBe(4);\n });\n });\n});\n\ndescribe('workflow bundle dynamic imports', () => {\n it('should inline dynamic imports when bundling without external', async () => {\n const tempDir = mkdtempSync(join(realTmpdir, 'dynamic-import-test-'));\n const nodeModulesDir = join(tempDir, 'node_modules', 'my-test-package');\n mkdirSync(nodeModulesDir, { recursive: true });\n\n // Create a simple package to dynamically import\n writeFileSync(\n join(nodeModulesDir, 'index.js'),\n 'export const testValue = 42;'\n );\n writeFileSync(\n join(nodeModulesDir, 'package.json'),\n JSON.stringify({ name: 'my-test-package', main: 'index.js' })\n );\n\n const testCode = `\n export async function workflow() {\n const pkg = await import('my-test-package');\n return pkg.testValue;\n }\n `;\n const entryFile = join(tempDir, 'workflow.ts');\n writeFileSync(entryFile, testCode);\n\n try {\n const result = await esbuild.build({\n entryPoints: [entryFile],\n bundle: true,\n write: false,\n platform: 'neutral',\n format: 'cjs',\n logLevel: 'silent',\n // No external option - should inline the dynamic import\n });\n\n expect(result.errors).toHaveLength(0);\n const output = result.outputFiles?.[0].text;\n expect(output).toBeDefined();\n\n // The dynamic import should be resolved and the value inlined\n // esbuild converts dynamic imports to either Promise.resolve(require(...))\n // or inlines the code directly\n expect(output).toContain('42');\n } finally {\n rmSync(tempDir, { recursive: true, force: true });\n }\n });\n\n it('should leave dynamic import as import() when marked external', async () => {\n const tempDir = mkdtempSync(join(realTmpdir, 'dynamic-import-test-'));\n const nodeModulesDir = join(tempDir, 'node_modules', 'external-package');\n mkdirSync(nodeModulesDir, { recursive: true });\n\n writeFileSync(\n join(nodeModulesDir, 'index.js'),\n 'export const value = 100;'\n );\n writeFileSync(\n join(nodeModulesDir, 'package.json'),\n JSON.stringify({ name: 'external-package', main: 'index.js' })\n );\n\n const testCode = `\n export async function workflow() {\n const pkg = await import('external-package');\n return pkg.value;\n }\n `;\n const entryFile = join(tempDir, 'workflow.ts');\n writeFileSync(entryFile, testCode);\n\n try {\n const result = await esbuild.build({\n entryPoints: [entryFile],\n bundle: true,\n write: false,\n platform: 'neutral',\n format: 'cjs',\n logLevel: 'silent',\n external: ['external-package'], // Mark as external\n });\n\n expect(result.errors).toHaveLength(0);\n const output = result.outputFiles?.[0].text;\n expect(output).toBeDefined();\n\n // When external, esbuild leaves a dynamic import() call that would fail in the VM\n // (the VM doesn't have import() available)\n // This demonstrates why we DON'T use external for workflow bundles\n expect(output).toMatch(/import\\([\"']external-package[\"']\\)/);\n // The actual value should NOT be inlined\n expect(output).not.toContain('100');\n } finally {\n rmSync(tempDir, { recursive: true, force: true });\n }\n });\n\n it('should inline nested dynamic imports from dependencies', async () => {\n const tempDir = mkdtempSync(join(realTmpdir, 'dynamic-import-test-'));\n\n // Create a package that itself uses dynamic import\n const outerPackageDir = join(tempDir, 'node_modules', 'outer-package');\n const innerPackageDir = join(tempDir, 'node_modules', 'inner-package');\n mkdirSync(outerPackageDir, { recursive: true });\n mkdirSync(innerPackageDir, { recursive: true });\n\n writeFileSync(\n join(innerPackageDir, 'index.js'),\n 'export const innerValue = 999;'\n );\n writeFileSync(\n join(innerPackageDir, 'package.json'),\n JSON.stringify({ name: 'inner-package', main: 'index.js' })\n );\n\n writeFileSync(\n join(outerPackageDir, 'index.js'),\n `\n export async function loadInner() {\n const inner = await import('inner-package');\n return inner.innerValue;\n }\n `\n );\n writeFileSync(\n join(outerPackageDir, 'package.json'),\n JSON.stringify({ name: 'outer-package', main: 'index.js' })\n );\n\n const testCode = `\n import { loadInner } from 'outer-package';\n export async function workflow() {\n return loadInner();\n }\n `;\n const entryFile = join(tempDir, 'workflow.ts');\n writeFileSync(entryFile, testCode);\n\n try {\n const result = await esbuild.build({\n entryPoints: [entryFile],\n bundle: true,\n write: false,\n platform: 'neutral',\n format: 'cjs',\n logLevel: 'silent',\n // No external - everything should be inlined\n });\n\n expect(result.errors).toHaveLength(0);\n const output = result.outputFiles?.[0].text;\n expect(output).toBeDefined();\n\n // Both the outer and inner package code should be inlined\n expect(output).toContain('999');\n } finally {\n rmSync(tempDir, { recursive: true, force: true });\n }\n });\n});\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"request-converter.js","sourceRoot":"","sources":["../src/request-converter.ts"],"names":[],"mappings":"AAAA,MAAM,sBAAsB,GAAG;;;;;;;;;;;CAW9B,CAAC;AAEF,SAAS,2BAA2B,CAClC,OAAe,EACf,OAAe,EACf,WAAmB,EACnB,YAAoB;IAEpB,MAAM,eAAe,GAAG,OAAO,CAAC,OAAO,CAAC,OAAO,EAAE,WAAW,CAAC,CAAC;IAC9D,IAAI,eAAe,KAAK,OAAO,EAAE,CAAC;QAChC,OAAO,eAAe,CAAC;IACzB,CAAC;IAED,MAAM,eAAe,GAAG,yBAAyB,CAAC;IAClD,MAAM,cAAc,GAAG,OAAO,CAAC,WAAW,CAAC,eAAe,CAAC,CAAC;IAC5D,IAAI,cAAc,KAAK,CAAC,CAAC,EAAE,CAAC;QAC1B,MAAM,IAAI,KAAK,CAAC,YAAY,CAAC,CAAC;IAChC,CAAC;IAED,MAAM,SAAS,GAAG,OAAO,CAAC,KAAK,CAAC,CAAC,EAAE,cAAc,CAAC,CAAC;IACnD,MAAM,SAAS,GAAG,OAAO,CAAC,KAAK,CAAC,cAAc,CAAC,CAAC;IAChD,MAAM,gBAAgB,GAAG,SAAS,CAAC,OAAO,CAAC,OAAO,EAAE,WAAW,CAAC,CAAC;IACjE,IAAI,gBAAgB,KAAK,SAAS,EAAE,CAAC;QACnC,MAAM,IAAI,KAAK,CAAC,YAAY,CAAC,CAAC;IAChC,CAAC;IACD,OAAO,gBAAgB,GAAG,SAAS,CAAC;AACtC,CAAC;AAED,OAAO,EAAE,sBAAsB,EAAE,2BAA2B,EAAE,CAAC","sourcesContent":["const NORMALIZE_REQUEST_CODE = `\nasync function normalizeRequest(request) {\n const options = {\n method: request.method,\n headers: new Headers(request.headers)\n };\n if (!['GET', 'HEAD', 'OPTIONS', 'TRACE', 'CONNECT'].includes(request.method)) {\n options.body = await request.arrayBuffer();\n }\n return new Request(request.url, options);\n}\n`;\n\nfunction replaceGeneratedRouteExport(\n content: string,\n pattern: RegExp,\n replacement: string,\n errorMessage: string\n) {\n const replacedContent = content.replace(pattern, replacement);\n if (replacedContent !== content) {\n return replacedContent;\n }\n\n const sourceMapMarker = '\\n//# sourceMappingURL=';\n const sourceMapIndex = content.lastIndexOf(sourceMapMarker);\n if (sourceMapIndex === -1) {\n throw new Error(errorMessage);\n }\n\n const routeCode = content.slice(0, sourceMapIndex);\n const sourceMap = content.slice(sourceMapIndex);\n const wrappedRouteCode = routeCode.replace(pattern, replacement);\n if (wrappedRouteCode === routeCode) {\n throw new Error(errorMessage);\n }\n return wrappedRouteCode + sourceMap;\n}\n\nexport { NORMALIZE_REQUEST_CODE, replaceGeneratedRouteExport };\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"request-converter.test.js","sourceRoot":"","sources":["../src/request-converter.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,QAAQ,CAAC;AAC9C,OAAO,EAAE,2BAA2B,EAAE,MAAM,wBAAwB,CAAC;AAErE,QAAQ,CAAC,6BAA6B,EAAE,GAAG,EAAE;IAC3C,EAAE,CAAC,iDAAiD,EAAE,GAAG,EAAE;QACzD,MAAM,MAAM,GAAG,2BAA2B,CACxC,qFAAqF,EACrF,+BAA+B,EAC/B,qCAAqC,EACrC,WAAW,CACZ,CAAC;QAEF,MAAM,CAAC,MAAM,CAAC,CAAC,IAAI,CACjB,4FAA4F,CAC7F,CAAC;IACJ,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,2DAA2D,EAAE,GAAG,EAAE;QACnE,MAAM,MAAM,GAAG,2BAA2B,CACxC;YACE,wBAAwB;YACxB,yDAAyD;YACzD,IAAI;YACJ,mDAAmD;YACnD,8BAA8B;YAC9B,8BAA8B;SAC/B,CAAC,IAAI,CAAC,IAAI,CAAC,EACZ,yHAAyH,EACzH,qCAAqC,EACrC,WAAW,CACZ,CAAC;QAEF,MAAM,CAAC,MAAM,CAAC,CAAC,IAAI,CACjB;YACE,wBAAwB;YACxB,yDAAyD;YACzD,IAAI;YACJ,qCAAqC;SACtC,CAAC,IAAI,CAAC,IAAI,CAAC,CACb,CAAC;IACJ,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,mDAAmD,EAAE,GAAG,EAAE;QAC3D,MAAM,CAAC,GAAG,EAAE,CACV,2BAA2B,CACzB,6BAA6B,EAC7B,+BAA+B,EAC/B,qCAAqC,EACrC,sBAAsB,CACvB,CACF,CAAC,OAAO,CAAC,sBAAsB,CAAC,CAAC;IACpC,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","sourcesContent":["import { describe, expect, it } from 'vitest';\nimport { replaceGeneratedRouteExport } from './request-converter.js';\n\ndescribe('replaceGeneratedRouteExport', () => {\n it('replaces route code before an inline source map', () => {\n const result = replaceGeneratedRouteExport(\n 'export const POST = handler;\\n//# sourceMappingURL=data:application/json;base64,abc',\n /export const POST = handler;$/,\n 'export const POST = wrappedHandler;',\n 'not found'\n );\n\n expect(result).toBe(\n 'export const POST = wrappedHandler;\\n//# sourceMappingURL=data:application/json;base64,abc'\n );\n });\n\n it('ignores source map comments embedded before route exports', () => {\n const result = replaceGeneratedRouteExport(\n [\n 'const workflowCode = `',\n '//# sourceMappingURL=data:application/json;base64,inner',\n '`;',\n 'const handler = workflowEntrypoint(workflowCode);',\n 'export const HEAD = handler;',\n 'export const POST = handler;',\n ].join('\\n'),\n /const handler = workflowEntrypoint\\(workflowCode\\);\\s*export const HEAD = handler;\\s*export const POST = handler;?\\s*$/m,\n 'export const POST = wrappedHandler;',\n 'not found'\n );\n\n expect(result).toBe(\n [\n 'const workflowCode = `',\n '//# sourceMappingURL=data:application/json;base64,inner',\n '`;',\n 'export const POST = wrappedHandler;',\n ].join('\\n')\n );\n });\n\n it('throws when the route export pattern is not found', () => {\n expect(() =>\n replaceGeneratedRouteExport(\n 'export const GET = handler;',\n /export const POST = handler;$/,\n 'export const POST = wrappedHandler;',\n 'missing route export'\n )\n ).toThrow('missing route export');\n });\n});\n"]}
@@ -1 +0,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I,CAAC,EACzC,CAAC;QACD,qEAAqE;QACrE,MAAM,UAAU,GAAG,KAAK,CAAC,CAAC,CAAC,IAAI,KAAK,CAAC,CAAC,CAAC,CAAC;QACxC,IAAI,UAAU,EAAE,CAAC;YACf,8DAA8D;YAC9D,OAAO,CAAC,GAAG,CAAC,UAAU,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;QACxC,CAAC;IACH,CAAC;IACD,OAAO,CAAC,GAAG,OAAO,CAAC,CAAC,IAAI,EAAE,CAAC;AAC7B,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,mBAAmB,CACjC,QAA0B;IAE1B,MAAM,OAAO,GAIR,EAAE,CAAC;IACR,IAAI,CAAC,QAAQ,CAAC,OAAO;QAAE,OAAO,OAAO,CAAC;IAEtC,KAAK,MAAM,CAAC,QAAQ,EAAE,OAAO,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAC,EAAE,CAAC;QACnE,KAAK,MAAM,CAAC,SAAS,EAAE,EAAE,OAAO,EAAE,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC;YAC/D,OAAO,CAAC,IAAI,CAAC,EAAE,SAAS,EAAE,OAAO,EAAE,QAAQ,EAAE,CAAC,CAAC;QACjD,CAAC;IACH,CAAC;IACD,OAAO,OAAO,CAAC;AACjB,CAAC","sourcesContent":["/**\n * Serde compliance checker for workflow custom class serialization.\n *\n * Analyzes source code to determine if classes with WORKFLOW_SERIALIZE /\n * WORKFLOW_DESERIALIZE are correctly set up for the workflow sandbox.\n *\n * Used by:\n * - CLI `validate` command\n * - CLI `transform` command (--check-serde)\n * - SWC playground serde analysis panel\n * - Build-time warnings in BaseBuilder\n */\n\nimport builtinModules from 'builtin-modules';\nimport type { WorkflowManifest } from './apply-swc-transform.js';\n\n// Build a regex that matches Node.js built-in module imports in transformed code.\n// Handles both ESM (`from 'fs'`, `from 'node:fs'`) and CJS (`require('fs')`)\nconst nodeBuiltins = builtinModules.join('|');\n\n// Regex to extract specific module names from import/require statements\nconst nodeImportExtractRegex = new RegExp(\n `(?:from\\\\s+['\"](?:node:)?((?:${nodeBuiltins})(?:/[^'\"]*)?)['\"]` +\n `|require\\\\s*\\\\(\\\\s*['\"](?:node:)?((?:${nodeBuiltins})(?:/[^'\"]*)?)['\"]\\\\s*\\\\))`,\n 'g'\n);\n\n// Regex to detect class registration IIFEs generated by the SWC plugin\nconst registrationIifeRegex =\n /Symbol\\.for\\s*\\(\\s*[\"']workflow-class-registry[\"']\\s*\\)/;\n\n/**\n * Result of checking a single class for serde compliance.\n */\nexport interface SerdeClassCheckResult {\n /** The class name as detected in the source */\n className: string;\n /** The classId assigned by the SWC plugin (from the manifest) */\n classId: string;\n /** Whether the SWC plugin detected serde symbols on this class */\n detected: boolean;\n /** Whether a registration IIFE was generated in the output */\n registered: boolean;\n /**\n * Node.js built-in module imports remaining in the workflow-mode output.\n * If non-empty, the class is NOT workflow-sandbox compliant.\n */\n nodeImports: string[];\n /** Whether the class passes all compliance checks */\n compliant: boolean;\n /** Human-readable descriptions of any issues found */\n issues: string[];\n}\n\n/**\n * Full result of serde compliance analysis for a source file.\n */\nexport interface SerdeCheckResult {\n /** Per-class analysis results */\n classes: SerdeClassCheckResult[];\n /** All Node.js built-in imports found in the workflow-mode output */\n globalNodeImports: string[];\n /** Whether the workflow-mode output contains any serde-related classes */\n hasSerdeClasses: boolean;\n /** The raw workflow manifest extracted from the SWC transform */\n manifest: WorkflowManifest;\n}\n\n/**\n * Lightweight serde compliance checker that works with pre-computed\n * SWC transform results. This avoids re-running the SWC transform\n * when the caller already has the outputs (e.g., the playground or builder).\n */\nexport function analyzeSerdeCompliance(options: {\n /** Source code (used for pattern detection) */\n sourceCode: string;\n /** Workflow-mode transformed output */\n workflowCode: string;\n /** Manifest extracted from the SWC transform */\n manifest: WorkflowManifest;\n}): SerdeCheckResult {\n const { sourceCode, workflowCode, manifest } = options;\n\n // 1. Extract all Node.js built-in imports from the workflow output\n const globalNodeImports = extractNodeImports(workflowCode);\n\n // 2. Check if the manifest contains any serde-registered classes\n const classEntries = extractClassEntries(manifest);\n const hasSerdeClasses = classEntries.length > 0;\n\n // 3. Check if the workflow output contains registration IIFEs\n const hasRegistration = registrationIifeRegex.test(workflowCode);\n\n // 4. Analyze each class\n const classes: SerdeClassCheckResult[] = classEntries.map((entry) => {\n const issues: string[] = [];\n\n // Check for Node.js imports (these will fail in the workflow sandbox)\n if (globalNodeImports.length > 0) {\n issues.push(\n `Workflow bundle contains Node.js built-in imports: ${globalNodeImports.join(', ')}. ` +\n `These will fail at runtime in the workflow sandbox. ` +\n `Add \"use step\" to methods that depend on Node.js APIs so they are stripped from the workflow bundle.`\n );\n }\n\n // Check for registration\n if (!hasRegistration) {\n issues.push(\n `No class registration IIFE was generated. ` +\n `Ensure WORKFLOW_SERIALIZE and WORKFLOW_DESERIALIZE are defined as static methods ` +\n `inside the class body using computed property syntax: static [WORKFLOW_SERIALIZE](...) { ... }`\n );\n }\n\n return {\n className: entry.className,\n classId: entry.classId,\n detected: true,\n registered: hasRegistration,\n nodeImports: globalNodeImports,\n compliant: globalNodeImports.length === 0 && hasRegistration,\n issues,\n };\n });\n\n // 5. Check for classes that have serde patterns in source but weren't detected by SWC\n const sourceHasSerdePatterns =\n /\\[\\s*WORKFLOW_(?:SERIALIZE|DESERIALIZE)\\s*\\]/.test(sourceCode) ||\n /Symbol\\.for\\s*\\(\\s*['\"]workflow-(?:serialize|deserialize)['\"]\\s*\\)/.test(\n sourceCode\n );\n\n if (sourceHasSerdePatterns && classEntries.length === 0) {\n classes.push({\n className: '<unknown>',\n classId: '',\n detected: false,\n registered: false,\n nodeImports: globalNodeImports,\n compliant: false,\n issues: [\n `Source code contains WORKFLOW_SERIALIZE/WORKFLOW_DESERIALIZE patterns but ` +\n `the SWC plugin did not detect any serde-enabled classes. ` +\n `Ensure the symbols are defined as static methods INSIDE the class body, ` +\n `not assigned externally (e.g., (MyClass as any)[WORKFLOW_SERIALIZE] = ...).`,\n ],\n });\n }\n\n return {\n classes,\n globalNodeImports,\n hasSerdeClasses,\n manifest,\n };\n}\n\n/**\n * Extract Node.js built-in module names from transformed code.\n */\nfunction extractNodeImports(code: string): string[] {\n const imports = new Set<string>();\n // Reset regex state\n nodeImportExtractRegex.lastIndex = 0;\n for (\n let match = nodeImportExtractRegex.exec(code);\n match !== null;\n match = nodeImportExtractRegex.exec(code)\n ) {\n // match[1] is from the ESM pattern, match[2] is from the CJS pattern\n const moduleName = match[1] || match[2];\n if (moduleName) {\n // Normalize to base module name (e.g., 'fs/promises' -> 'fs')\n imports.add(moduleName.split('/')[0]);\n }\n }\n return [...imports].sort();\n}\n\n/**\n * Extract class entries from a WorkflowManifest.\n */\nexport function extractClassEntries(\n manifest: WorkflowManifest\n): Array<{ className: string; classId: string; fileName: string }> {\n const entries: Array<{\n className: string;\n classId: string;\n fileName: string;\n }> = [];\n if (!manifest.classes) return entries;\n\n for (const [fileName, classes] of Object.entries(manifest.classes)) {\n for (const [className, { classId }] of Object.entries(classes)) {\n entries.push({ className, classId, fileName });\n }\n }\n return entries;\n}\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"standalone.js","sourceRoot":"","sources":["../src/standalone.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAGhD,MAAM,OAAO,iBAAkB,SAAQ,WAAW;IAChD,YAAY,MAAsB;QAChC,KAAK,CAAC;YACJ,GAAG,MAAM;YACT,IAAI,EAAE,CAAC,GAAG,CAAC;SACZ,CAAC,CAAC;IACL,CAAC;IAED,KAAK,CAAC,KAAK;QACT,MAAM,UAAU,GAAG,MAAM,IAAI,CAAC,aAAa,EAAE,CAAC;QAC9C,MAAM,YAAY,GAAG,MAAM,IAAI,CAAC,gBAAgB,EAAE,CAAC;QAEnD,MAAM,OAAO,GAAG;YACd,UAAU;YACV,YAAY;SACb,CAAC;QACF,MAAM,aAA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e,CAAC,eAAe,CAAC,CAAC;QAE5C,MAAM,EAAE,QAAQ,EAAE,GAAG,MAAM,IAAI,CAAC,iBAAiB,CAAC;YAChD,OAAO,EAAE,eAAe;YACxB,UAAU;YACV,YAAY;SACb,CAAC,CAAC;QAEH,OAAO,QAAQ,CAAC;IAClB,CAAC;IAEO,KAAK,CAAC,oBAAoB,CAAC,EACjC,UAAU,EACV,YAAY,GAIb;QACC,OAAO,CAAC,GAAG,CACT,8BAA8B,EAC9B,IAAI,CAAC,MAAM,CAAC,mBAAmB,CAChC,CAAC;QAEF,MAAM,kBAAkB,GAAG,IAAI,CAAC,WAAW,CACzC,IAAI,CAAC,MAAM,CAAC,mBAAmB,CAChC,CAAC;QACF,MAAM,IAAI,CAAC,eAAe,CAAC,kBAAkB,CAAC,CAAC;QAE/C,MAAM,EAAE,QAAQ,EAAE,GAAG,MAAM,IAAI,CAAC,qBAAqB,CAAC;YACpD,OAAO,EAAE,kBAAkB;YAC3B,UAAU;YACV,YAAY;SACb,CAAC,CAAC;QAEH,OAAO,QAAQ,CAAC;IAClB,CAAC;IAEO,KAAK,CAAC,oBAAoB;QAChC,OAAO,CAAC,GAAG,CAAC,4BAA4B,EAAE,IAAI,CAAC,MAAM,CAAC,iBAAiB,CAAC,CAAC;QAEzE,MAAM,iBAAiB,GAAG,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,MAAM,CAAC,iBAAiB,CAAC,CAAC;QAC1E,MAAM,IAAI,CAAC,eAAe,CAAC,iBAAiB,CAAC,CAAC;QAE9C,MAAM,IAAI,CAAC,mBAAmB,CAAC;YAC7B,OAAO,EAAE,iBAAiB;SAC3B,CAAC,CAAC;IACL,CAAC;CACF","sourcesContent":["import { BaseBuilder } from './base-builder.js';\nimport type { WorkflowConfig } from './types.js';\n\nexport class StandaloneBuilder extends BaseBuilder {\n constructor(config: WorkflowConfig) {\n super({\n ...config,\n dirs: ['.'],\n });\n }\n\n async build(): Promise<void> {\n const inputFiles = await this.getInputFiles();\n const tsconfigPath = await this.findTsConfigPath();\n\n const options = {\n inputFiles,\n tsconfigPath,\n };\n const stepsManifest = await this.buildStepsBundle(options);\n const workflowsManifest = await this.buildWorkflowsBundle(options);\n await this.buildWebhookFunction();\n\n // Merge manifests from both bundles\n // Steps bundle discovers classes from default export conditions\n // Workflow bundle discovers classes from 'workflow' export conditions\n const manifest = this.mergeManifests(stepsManifest, workflowsManifest);\n\n // Build unified manifest from workflow bundle\n const workflowBundlePath = this.resolvePath(\n this.config.workflowsBundlePath\n );\n const manifestDir = this.resolvePath('.well-known/workflow/v1');\n await this.createManifest({\n workflowBundlePath,\n manifestDir,\n manifest,\n });\n\n await this.createClientLibrary();\n }\n\n private mergeManifests(\n stepsManifest: {\n steps?: Record<string, any>;\n workflows?: Record<string, any>;\n classes?: Record<string, any>;\n },\n workflowsManifest: {\n steps?: Record<string, any>;\n workflows?: Record<string, any>;\n classes?: Record<string, any>;\n }\n ): {\n steps?: Record<string, any>;\n workflows?: Record<string, any>;\n classes?: Record<string, any>;\n } {\n return {\n steps: { ...stepsManifest.steps, ...workflowsManifest.steps },\n workflows: { ...stepsManifest.workflows, ...workflowsManifest.workflows },\n classes: { ...stepsManifest.classes, ...workflowsManifest.classes },\n };\n }\n\n private async buildStepsBundle({\n inputFiles,\n tsconfigPath,\n }: {\n inputFiles: string[];\n tsconfigPath?: string;\n }) {\n console.log('Creating steps bundle at', this.config.stepsBundlePath);\n\n const stepsBundlePath = this.resolvePath(this.config.stepsBundlePath);\n await this.ensureDirectory(stepsBundlePath);\n\n const { manifest } = await this.createStepsBundle({\n outfile: stepsBundlePath,\n inputFiles,\n tsconfigPath,\n });\n\n return manifest;\n }\n\n private async buildWorkflowsBundle({\n inputFiles,\n tsconfigPath,\n }: {\n inputFiles: string[];\n tsconfigPath?: string;\n }) {\n console.log(\n 'Creating workflows bundle at',\n this.config.workflowsBundlePath\n );\n\n const workflowBundlePath = this.resolvePath(\n this.config.workflowsBundlePath\n );\n await this.ensureDirectory(workflowBundlePath);\n\n const { manifest } = await this.createWorkflowsBundle({\n outfile: workflowBundlePath,\n inputFiles,\n tsconfigPath,\n });\n\n return manifest;\n }\n\n private async buildWebhookFunction(): Promise<void> {\n console.log('Creating webhook bundle at', this.config.webhookBundlePath);\n\n const webhookBundlePath = this.resolvePath(this.config.webhookBundlePath);\n await this.ensureDirectory(webhookBundlePath);\n\n await this.createWebhookBundle({\n outfile: webhookBundlePath,\n });\n }\n}\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"swc-esbuild-plugin.js","sourceRoot":"","sources":["../src/swc-esbuild-plugin.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AACrC,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AACtC,OAAO,mBAAmB,MAAM,kBAAkB,CAAC;AAEnD,OAAO,EACL,iBAAiB,GAElB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EACL,SAAS,EACT,cAAc,GACf,MAAM,sCAAsC,CAAC;AAC9C,OAAO,EAAE,sBAAsB,EAAE,MAAM,uBAAuB,CAAC;AAC/D,OAAO,EAAE,gCAAgC,EAAE,MAAM,qBAAqB,CAAC;AAyCvE,MAAM,oBAAoB,GAAG;IAC3B,cAAc,EAAE,UAAU;IAC1B,OAAO,EAAE,CAAC,cAAc,CAAC;IACzB,aAAa,EAAE,CAAC,SAAS,CAAC;IAC1B,aAAa,EAAE,CAAC,SAAS,CAAC;IAC1B,cAAc,EAAE,CAAC,MAAM,EAAE,SAAS,CAAC;IACnC,gBAAgB,EAAE,CAAC,cAAc,CAAC;IAClC,UAAU,EAAE;QACV,KAAK;QACL,MAAM;QACN,MAAM;QACN,MAAM;QACN,MAAM;QACN,MAAM;QACN,KAAK;QACL,MAAM;QACN,OAAO;QACP,OAAO;KACR;IACD,iBAAiB,EAAE,KAAK;IACxB,QAAQ,EAAE,IAAI;IAC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AM,CAC9C,OAAO,CAAC,gBAAgB,CAAC,OAAO,IAAI,EAAE,EACtC,gBAAgB,CAAC,OAAO,CACzB,CAAC;oBAEF,OAAO;wBACL,QAAQ,EAAE,eAAe;wBACzB,MAAM;qBACP,CAAC;gBACJ,CAAC;gBAAC,OAAO,KAAK,EAAE,CAAC;oBACf,MAAM,YAAY,GAChB,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;oBACzD,OAAO,CAAC,KAAK,CACX,4BAA4B,IAAI,CAAC,IAAI,GAAG,EACxC,YAAY,CACb,CAAC;oBACF,OAAO;wBACL,MAAM,EAAE;4BACN;gCACE,IAAI,EAAE,yBAAyB,YAAY,EAAE;gCAC7C,QAAQ,EAAE,EAAE,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,IAAI,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE;6BAClD;yBACF;qBACF,CAAC;gBACJ,CAAC;YACH,CAAC,CAAC,CAAC;QACL,CAAC;KACF,CAAC;AACJ,CAAC;AAED,SAAS,kBAAkB,CAAC,QAAgB,EAAE,WAAmB;IAC/D,IAAI,aAAa,CAAC,QAAQ,CAAC,CAAC,QAAQ,CAAC,gBAAgB,CAAC,EAAE,CAAC;QACvD,OAAO,KAAK,CAAC;IACf,CAAC;IAED,OAAO,CACL,sBAAsB,CAAC,QAAQ,EAAE,WAAW,CAAC,CAAC,eAAe,KAAK,SAAS,CAC5E,CAAC;AACJ,CAAC","sourcesContent":["import { readFile } from 'node:fs/promises';\nimport { relative } from 'node:path';\nimport { promisify } from 'node:util';\nimport enhancedResolveOrig from 'enhanced-resolve';\nimport type { Plugin } from 'esbuild';\nimport {\n applySwcTransform,\n type WorkflowManifest,\n} from './apply-swc-transform.js';\nimport {\n jsTsRegex,\n parentHasChild,\n} from './discover-entries-esbuild-plugin.js';\nimport { resolveModuleSpecifier } from './module-specifier.js';\nimport { resolveWorkflowAliasRelativePath } from './workflow-alias.js';\n\nexport interface SwcPluginOptions {\n mode: 'step' | 'workflow' | 'client';\n entriesToBundle?: string[];\n outdir?: string;\n projectRoot?: string;\n workflowManifest?: WorkflowManifest;\n /**\n * Rewrite TypeScript extensions (.ts, .tsx, .mts, .cts) to their JS\n * equivalents (.js, .mjs, .cjs) in externalized import paths.\n *\n * Enable this when the output bundle is consumed directly by Node's native\n * ESM loader (e.g. vitest), which cannot resolve .ts extensions.\n *\n * Leave disabled (default) when a downstream bundler (webpack, Vite, etc.)\n * handles resolution — those tools resolve .ts natively and rewriting\n * breaks them because the .js file doesn't exist on disk.\n */\n rewriteTsExtensions?: boolean;\n /**\n * Bundle project-local files that are transitively imported by step entries.\n *\n * Keep this disabled when a downstream bundler consumes the generated step\n * bundle because that bundler can resolve the externalized local imports.\n * Enable it for direct runtime loading, where Node imports the generated step\n * bundle from disk without a later bundling pass.\n */\n bundleTransitiveLocalStepDependencies?: boolean;\n /**\n * Absolute file paths of discovered workflow/step/serde entries whose\n * imports must be treated as side-effectful.\n *\n * The SWC compiler transform injects registration calls (workflow IDs,\n * step IDs, class serialization, etc.) into these files. Without this\n * override, esbuild honours `\"sideEffects\": false` from the package's\n * `package.json` and silently drops bare imports of these modules.\n */\n sideEffectEntries?: string[];\n}\n\nconst NODE_RESOLVE_OPTIONS = {\n dependencyType: 'commonjs',\n modules: ['node_modules'],\n exportsFields: ['exports'],\n importsFields: ['imports'],\n conditionNames: ['node', 'require'],\n descriptionFiles: ['package.json'],\n extensions: [\n '.ts',\n '.tsx',\n '.mts',\n '.cts',\n '.cjs',\n '.mjs',\n '.js',\n '.jsx',\n '.json',\n '.node',\n ],\n enforceExtensions: false,\n symlinks: true,\n mainFields: ['main'],\n mainFiles: ['index'],\n roots: [],\n fullySpecified: false,\n preferRelative: false,\n preferAbsolute: false,\n restrictions: [],\n};\n\nconst NODE_ESM_RESOLVE_OPTIONS = {\n ...NODE_RESOLVE_OPTIONS,\n dependencyType: 'esm',\n conditionNames: ['node', 'import'],\n};\n\nfunction normalizePath(path: string): string {\n return path.replace(/\\\\/g, '/');\n}\n\nexport function createSwcPlugin(options: SwcPluginOptions): Plugin {\n return {\n name: 'swc-workflow-plugin',\n setup(build) {\n // everything is external unless explicitly configured\n // to be bundled\n const cjsResolver = promisify(\n enhancedResolveOrig.create(NODE_RESOLVE_OPTIONS)\n );\n const esmResolver = promisify(\n enhancedResolveOrig.create(NODE_ESM_RESOLVE_OPTIONS)\n );\n\n const enhancedResolve = async (context: string, path: string) => {\n try {\n return await esmResolver(context, path);\n } catch (_) {\n return cjsResolver(context, path);\n }\n };\n\n // Pre-compute the normalized side-effect entries set for O(1) lookups.\n const normalizedSideEffectEntries = new Set(\n options.sideEffectEntries?.map((e) => e.replace(/\\\\/g, '/'))\n );\n\n build.onResolve({ filter: /.*/ }, async (args) => {\n if (args.pluginData?.skipSwcPlugin) return null;\n\n if (\n !options.entriesToBundle &&\n normalizedSideEffectEntries.size === 0\n ) {\n return null;\n }\n\n // When only sideEffectEntries is set (no entriesToBundle), we only\n // need to override sideEffects for top-level bare imports — typically\n // from the virtual entry. Skip resolution for transitive imports\n // (dynamic imports, requires, etc.) to avoid unnecessary overhead.\n if (!options.entriesToBundle && args.kind !== 'import-statement') {\n return null;\n }\n\n try {\n const specifier = args.path;\n const specifierIsPath =\n specifier.startsWith('.') || specifier.startsWith('/');\n\n let resolvedPath: string | false | undefined;\n // Determines whether the external path should be relativized\n // (project-local file) or kept as a bare specifier (npm package).\n let shouldMakeRelative = specifierIsPath;\n\n if (specifierIsPath) {\n resolvedPath = await enhancedResolve(args.resolveDir, specifier);\n } else {\n // Resolve from project root so nested deps aren't externalized\n resolvedPath = await enhancedResolve(\n build.initialOptions.absWorkingDir || process.cwd(),\n specifier\n ).catch(() => undefined); // swallow so esbuild fallback below can try\n\n // Fall back to esbuild for aliases/tsconfig paths,\n // but only accept project-local results\n if (!resolvedPath) {\n const esbuildResult = await build.resolve(specifier, {\n resolveDir: args.resolveDir,\n kind: args.kind,\n pluginData: { skipSwcPlugin: true },\n });\n const didResolve =\n !!esbuildResult.path && !esbuildResult.errors.length;\n const isProjectLocalFile =\n didResolve &&\n !esbuildResult.external &&\n !esbuildResult.path\n .replace(/\\\\/g, '/')\n .includes('/node_modules/');\n if (isProjectLocalFile) {\n resolvedPath = esbuildResult.path;\n shouldMakeRelative = true;\n }\n }\n }\n\n if (!resolvedPath) return null;\n\n // Normalize to forward slashes for cross-platform comparison\n const normalizedResolvedPath = normalizePath(resolvedPath);\n const workingDir =\n build.initialOptions.absWorkingDir || process.cwd();\n const projectRoot = options.projectRoot || workingDir;\n\n // Check if this module is a discovered entry whose SWC-transformed\n // code contains side effects (workflow/step/class registration).\n // Override the package.json \"sideEffects\": false so esbuild does not\n // drop bare imports of these modules.\n const hasSideEffects = normalizedSideEffectEntries.has(\n normalizedResolvedPath\n );\n\n if (options.entriesToBundle) {\n let shouldBundle = false;\n for (const entryToBundle of options.entriesToBundle) {\n const normalizedEntry = entryToBundle.replace(/\\\\/g, '/');\n\n if (normalizedResolvedPath === normalizedEntry) {\n shouldBundle = true;\n break;\n }\n\n // if the current entry imports a child that needs\n // to be bundled then it needs to also be bundled so\n // that the child can have our transform applied\n if (parentHasChild(normalizedResolvedPath, normalizedEntry)) {\n shouldBundle = true;\n break;\n }\n\n // Bundle project-local source files that are imported by a\n // step/serde entry so direct runtime loaders do not see raw TS\n // extensionless imports. Keep package dependencies external\n // unless they are themselves in entriesToBundle or are parents\n // of a discovered workflow/step/serde file via the check above.\n if (\n options.bundleTransitiveLocalStepDependencies &&\n isProjectLocalFile(normalizedResolvedPath, projectRoot) &&\n parentHasChild(normalizedEntry, normalizedResolvedPath)\n ) {\n shouldBundle = true;\n break;\n }\n }\n\n if (shouldBundle) {\n // Let esbuild bundle this entry, but override sideEffects if needed.\n // We must return the resolved `path` alongside `sideEffects` because\n // returning only `{ sideEffects: true }` without a path causes esbuild\n // to fall through to its own resolver, which re-reads the package.json\n // and applies `\"sideEffects\": false` from there.\n return hasSideEffects\n ? { path: resolvedPath, sideEffects: true }\n : null;\n }\n\n let externalPath: string;\n if (shouldMakeRelative) {\n externalPath = relative(\n options.outdir || process.cwd(),\n resolvedPath\n ).replace(/\\\\/g, '/');\n\n if (options.rewriteTsExtensions) {\n // Rewrite TypeScript extensions to their JS equivalents so the\n // externalized import is loadable by Node's native ESM loader.\n externalPath = externalPath\n .replace(/\\.tsx?$/, '.js')\n .replace(/\\.mts$/, '.mjs')\n .replace(/\\.cts$/, '.cjs');\n }\n } else {\n externalPath = specifier;\n }\n\n return {\n external: true,\n path: externalPath,\n sideEffects: hasSideEffects || undefined,\n };\n }\n\n // No entriesToBundle — only override sideEffects when needed.\n // We must return the resolved `path` alongside `sideEffects` because\n // returning only `{ sideEffects: true }` without a path causes esbuild\n // to fall through to its own resolver, which re-reads the package.json\n // and applies `\"sideEffects\": false` from there.\n return hasSideEffects\n ? { path: resolvedPath, sideEffects: true }\n : null;\n } catch (_) {}\n return null;\n });\n\n // Handle TypeScript and JavaScript files\n build.onLoad({ filter: jsTsRegex }, async (args) => {\n // Determine if this is a TypeScript file\n try {\n // Determine the loader based on the output\n let loader: 'js' | 'jsx' | 'tsx' = 'js';\n if (args.path.endsWith('.jsx')) {\n loader = 'jsx';\n } else if (args.path.endsWith('.tsx')) {\n loader = 'tsx';\n }\n const source = await readFile(args.path, 'utf8');\n const normalizedSource = source\n .replace(/require\\(\\s*(['\"])server-only\\1\\s*\\)/g, 'void 0')\n .replace(/require\\(\\s*(['\"])client-only\\1\\s*\\)/g, 'void 0');\n\n // Calculate relative path for SWC plugin\n // The filename parameter is used to generate workflowId/stepId, so it must be relative\n const workingDir =\n build.initialOptions.absWorkingDir || process.cwd();\n const projectRoot = options.projectRoot || workingDir;\n // Normalize paths: convert backslashes to forward slashes and remove trailing slashes\n const normalizedWorkingDir = workingDir\n .replace(/\\\\/g, '/')\n .replace(/\\/$/, '');\n const normalizedPath = args.path.replace(/\\\\/g, '/');\n\n // Windows fix: Always do case-insensitive path comparison as the PRIMARY logic\n // to work around node:path.relative() not recognizing paths with different drive\n // letter casing (e.g., D: vs d:) as being in the same tree\n const lowerWd = normalizedWorkingDir.toLowerCase();\n const lowerPath = normalizedPath.toLowerCase();\n\n let relativeFilepath: string;\n if (lowerPath.startsWith(lowerWd + '/')) {\n // File is under working directory - manually calculate relative path\n // This ensures we get a relative path even with drive letter casing issues\n relativeFilepath = normalizedPath.substring(\n normalizedWorkingDir.length + 1\n );\n } else if (lowerPath === lowerWd) {\n // File IS the working directory\n relativeFilepath = '.';\n } else {\n // File is outside working directory - use relative() and strip ../ prefixes if needed\n relativeFilepath = relative(\n normalizedWorkingDir,\n normalizedPath\n ).replace(/\\\\/g, '/');\n\n // Handle files discovered outside the working directory\n // These come back as ../path/to/file, but we want just path/to/file\n if (relativeFilepath.startsWith('../')) {\n const aliasedRelativePath =\n await resolveWorkflowAliasRelativePath(args.path, workingDir);\n if (aliasedRelativePath) {\n relativeFilepath = aliasedRelativePath;\n } else {\n relativeFilepath = relativeFilepath\n .split('/')\n .filter((part) => part !== '..')\n .join('/');\n }\n }\n }\n\n // Final safety check - ensure we never pass an absolute path to SWC\n if (\n relativeFilepath.includes(':') ||\n relativeFilepath.startsWith('/')\n ) {\n // This should never happen, but if it does, use just the filename as last resort\n console.error(\n `[ERROR] relativeFilepath is still absolute: ${relativeFilepath}`\n );\n relativeFilepath = normalizedPath.split('/').pop() || 'unknown.ts';\n }\n\n const { code: transformedCode, workflowManifest } =\n await applySwcTransform(\n relativeFilepath,\n normalizedSource,\n options.mode,\n args.path, // Pass absolute path for module specifier resolution\n projectRoot\n );\n\n if (!options.workflowManifest) {\n options.workflowManifest = {};\n }\n\n options.workflowManifest.workflows = Object.assign(\n options.workflowManifest.workflows || {},\n workflowManifest.workflows\n );\n options.workflowManifest.steps = Object.assign(\n options.workflowManifest.steps || {},\n workflowManifest.steps\n );\n options.workflowManifest.classes = Object.assign(\n options.workflowManifest.classes || {},\n workflowManifest.classes\n );\n\n return {\n contents: transformedCode,\n loader,\n };\n } catch (error) {\n const errorMessage =\n error instanceof Error ? error.message : String(error);\n console.error(\n `❌ SWC transform error in ${args.path}:`,\n errorMessage\n );\n return {\n errors: [\n {\n text: `SWC transform failed: ${errorMessage}`,\n location: { file: args.path, line: 0, column: 0 },\n },\n ],\n };\n }\n });\n },\n };\n}\n\nfunction isProjectLocalFile(filePath: string, projectRoot: string): boolean {\n if (normalizePath(filePath).includes('/node_modules/')) {\n return false;\n }\n\n return (\n resolveModuleSpecifier(filePath, projectRoot).moduleSpecifier === undefined\n );\n}\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"swc-esbuild-plugin.test.js","sourceRoot":"","sources":["../src/swc-esbuild-plugin.test.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,SAAS,EACT,WAAW,EACX,YAAY,EACZ,MAAM,EACN,aAAa,GACd,MAAM,SAAS,CAAC;AACjB,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AACjC,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,KAAK,OAAO,MAAM,SAAS,CAAC;AACnC,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,EAAE,EAAE,MAAM,QAAQ,CAAC;AAEzE,MAAM,EAAE,qBAAqB,EAAE,GAAG,EAAE,CAAC,OAAO,CAAC,GAAG,EAAE,CAAC,CAAC;IAClD,qBAAqB,EAAE,EAAE,CAAC,EAAE,EAAE;CAC/B,CAAC,CAAC,CAAC;AAEJ,EAAE,CAAC,IAAI,CAAC,0BAA0B,EAAE,GAAG,EAAE,CAAC,CAAC;IACzC,iBAAiB,EAAE,qBAAqB;CACzC,CAAC,CAAC,CAAC;AAEJ,OAAO,EACL,2BAA2B,EAC3B,aAAa,GACd,MAAM,sCAAsC,CAAC;AAC9C,OAAO,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC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O,CAAC,KAAK,CAAC;YACjC,WAAW,EAAE,CAAC,OAAO,CAAC,YAAY,CAAC;YACnC,aAAa,EAAE,OAAO,CAAC,WAAW;YAClC,MAAM,EAAE,IAAI;YACZ,MAAM,EAAE,KAAK;YACb,QAAQ,EAAE,MAAM;YAChB,KAAK,EAAE,KAAK;YACZ,OAAO,EAAE;gBACP,eAAe,CAAC;oBACd,IAAI,EAAE,UAAU;oBAChB,gBAAgB,EAAE,EAAE;iBACrB,CAAC;aACH;SACF,CAAC,CAAC;QAEH,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC;QACtC,MAAM,CAAC,qBAAqB,CAAC,CAAC,oBAAoB,CAChD,iDAAiD,EACjD,MAAM,CAAC,gBAAgB,CAAC,gBAAgB,CAAC,EACzC,UAAU,EACV,OAAO,CAAC,YAAY,EACpB,OAAO,CAAC,WAAW,CACpB,CAAC;IACJ,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","sourcesContent":["import {\n mkdirSync,\n mkdtempSync,\n realpathSync,\n rmSync,\n writeFileSync,\n} from 'node:fs';\nimport { tmpdir } from 'node:os';\nimport { dirname, join } from 'node:path';\nimport * as esbuild from 'esbuild';\nimport { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';\n\nconst { applySwcTransformMock } = vi.hoisted(() => ({\n applySwcTransformMock: vi.fn(),\n}));\n\nvi.mock('./apply-swc-transform.js', () => ({\n applySwcTransform: applySwcTransformMock,\n}));\n\nimport {\n createDiscoverEntriesPlugin,\n importParents,\n} from './discover-entries-esbuild-plugin.js';\nimport { createSwcPlugin } from './swc-esbuild-plugin.js';\n\nconst realTmpdir = realpathSync(tmpdir());\n\nfunction writeFile(path: string, contents = ''): void {\n mkdirSync(dirname(path), { recursive: true });\n writeFileSync(path, contents, 'utf-8');\n}\n\ndescribe('createSwcPlugin externalizeNonSteps', () => {\n let testRoot: string;\n\n beforeEach(() => {\n testRoot = mkdtempSync(join(realTmpdir, 'workflow-swc-plugin-'));\n importParents.clear();\n applySwcTransformMock.mockReset();\n applySwcTransformMock.mockImplementation(\n async (_filename: string, source: string) => ({\n code: source,\n workflowManifest: {},\n })\n );\n });\n\n afterEach(() => {\n importParents.clear();\n rmSync(testRoot, { recursive: true, force: true });\n });\n\n it.each([\n { inputExt: '.ts', outputExt: '.js' },\n { inputExt: '.tsx', outputExt: '.js' },\n { inputExt: '.mts', outputExt: '.mjs' },\n { inputExt: '.cts', outputExt: '.cjs' },\n ])('rewrites externalized $inputExt imports to $outputExt when rewriteTsExtensions is enabled', async ({\n inputExt,\n outputExt,\n }) => {\n const outdir = join(testRoot, 'out');\n const srcDir = join(testRoot, 'src');\n const stepFile = join(srcDir, 'step.ts');\n\n writeFile(join(srcDir, `dep${inputExt}`), 'export const dep = {};');\n writeFile(stepFile, `import { dep } from './dep';\\nconsole.log(dep);`);\n\n const result = await esbuild.build({\n entryPoints: [stepFile],\n absWorkingDir: testRoot,\n outdir,\n bundle: true,\n format: 'esm',\n platform: 'node',\n write: false,\n plugins: [\n createSwcPlugin({\n mode: 'step',\n entriesToBundle: [stepFile],\n outdir,\n rewriteTsExtensions: true,\n }),\n ],\n });\n\n expect(result.errors).toHaveLength(0);\n const output = result.outputFiles[0].text;\n expect(output).toContain(`/dep${outputExt}`);\n expect(output).not.toContain(`/dep${inputExt}`);\n });\n\n it('rewrites path-aliased imports to relative paths', async () => {\n const outdir = join(testRoot, 'out');\n const srcDir = join(testRoot, 'src');\n const libDir = join(srcDir, 'lib');\n const stepFile = join(srcDir, 'step.ts');\n\n writeFile(join(libDir, 'config.ts'), 'export const config = {};');\n writeFile(\n stepFile,\n `import { config } from '@/lib/config';\\nconsole.log(config);`\n );\n\n const result = await esbuild.build({\n entryPoints: [stepFile],\n absWorkingDir: testRoot,\n outdir,\n bundle: true,\n format: 'esm',\n platform: 'node',\n write: false,\n alias: { '@': srcDir },\n plugins: [\n createSwcPlugin({\n mode: 'step',\n entriesToBundle: [stepFile],\n outdir,\n rewriteTsExtensions: true,\n }),\n ],\n });\n\n expect(result.errors).toHaveLength(0);\n const output = result.outputFiles[0].text;\n expect(output).toContain('/lib/config.js');\n expect(output).not.toContain('@/lib/config');\n });\n\n it('does not relativize Node.js builtin imports', async () => {\n const outdir = join(testRoot, 'out');\n const srcDir = join(testRoot, 'src');\n const stepFile = join(srcDir, 'step.ts');\n\n writeFile(\n stepFile,\n `import { createHash } from 'crypto';\\nimport { join } from 'node:path';\\nconsole.log(createHash, join);`\n );\n\n const result = await esbuild.build({\n entryPoints: [stepFile],\n absWorkingDir: testRoot,\n outdir,\n bundle: true,\n format: 'esm',\n platform: 'node',\n write: false,\n plugins: [\n createSwcPlugin({\n mode: 'step',\n entriesToBundle: [stepFile],\n outdir,\n }),\n ],\n });\n\n expect(result.errors).toHaveLength(0);\n const output = result.outputFiles[0].text;\n // Builtins should remain as bare specifiers, not relativized paths\n expect(output).toMatch(/from\\s+[\"']crypto[\"']/);\n expect(output).toMatch(/from\\s+[\"']node:path[\"']/);\n expect(output).not.toMatch(/from\\s+[\"']\\..*crypto[\"']/);\n expect(output).not.toMatch(/from\\s+[\"']\\..*node:path[\"']/);\n });\n\n it('does not externalize aliased imports that resolve into node_modules', async () => {\n const outdir = join(testRoot, 'out');\n const srcDir = join(testRoot, 'src');\n const stepFile = join(srcDir, 'step.ts');\n const nodeModulesDir = join(testRoot, 'node_modules', 'some-pkg');\n\n writeFile(join(nodeModulesDir, 'index.js'), 'export const pkg = \"hello\";');\n writeFile(stepFile, `import { pkg } from '@pkg';\\nconsole.log(pkg);`);\n\n const result = await esbuild.build({\n entryPoints: [stepFile],\n absWorkingDir: testRoot,\n outdir,\n bundle: true,\n format: 'esm',\n platform: 'node',\n write: false,\n alias: { '@pkg': join(nodeModulesDir, 'index.js') },\n plugins: [\n createSwcPlugin({\n mode: 'step',\n entriesToBundle: [stepFile],\n outdir,\n }),\n ],\n });\n\n expect(result.errors).toHaveLength(0);\n const output = result.outputFiles[0].text;\n // Should be bundled (inlined), not externalized as a relative node_modules path\n expect(output).toContain('hello');\n expect(output).not.toMatch(/from\\s+[\"'].*node_modules/);\n });\n\n it.each([\n '.ts',\n '.tsx',\n '.mts',\n '.cts',\n ])('preserves externalized %s extensions by default', async (inputExt) => {\n const outdir = join(testRoot, 'out');\n const srcDir = join(testRoot, 'src');\n const stepFile = join(srcDir, 'step.ts');\n\n writeFile(join(srcDir, `dep${inputExt}`), 'export const dep = {};');\n writeFile(stepFile, `import { dep } from './dep';\\nconsole.log(dep);`);\n\n const result = await esbuild.build({\n entryPoints: [stepFile],\n absWorkingDir: testRoot,\n outdir,\n bundle: true,\n format: 'esm',\n platform: 'node',\n write: false,\n plugins: [\n createSwcPlugin({\n mode: 'step',\n entriesToBundle: [stepFile],\n outdir,\n }),\n ],\n });\n\n expect(result.errors).toHaveLength(0);\n const output = result.outputFiles[0].text;\n expect(output).toContain(`/dep${inputExt}`);\n });\n\n it('bundles transitive local TypeScript dependencies with extensionless imports', async () => {\n const outdir = join(testRoot, 'out');\n const stepFile = join(testRoot, 'server', 'workflows', 'my-workflow.ts');\n const constantsFile = join(testRoot, 'shared', 'constants.ts');\n const helpersFile = join(testRoot, 'shared', 'helpers.ts');\n\n writeFile(helpersFile, `export const HELPER_VALUE = \"from-helper\";`);\n writeFile(\n constantsFile,\n `import { HELPER_VALUE } from './helpers';\\nexport const CATEGORIES = [HELPER_VALUE];`\n );\n writeFile(\n stepFile,\n `import { CATEGORIES } from '../../shared/constants';\\nexport async function myStep() {\\n 'use step';\\n return CATEGORIES[0];\\n}`\n );\n\n const state = {\n discoveredSteps: new Set<string>(),\n discoveredWorkflows: new Set<string>(),\n discoveredSerdeFiles: new Set<string>(),\n };\n await esbuild.build({\n entryPoints: [stepFile],\n absWorkingDir: testRoot,\n bundle: true,\n format: 'esm',\n platform: 'node',\n write: false,\n resolveExtensions: ['.ts', '.tsx', '.js', '.jsx', '.mjs', '.cjs'],\n plugins: [createDiscoverEntriesPlugin(state, testRoot)],\n });\n\n const result = await esbuild.build({\n entryPoints: [stepFile],\n absWorkingDir: testRoot,\n outdir,\n bundle: true,\n format: 'esm',\n platform: 'node',\n write: false,\n resolveExtensions: ['.ts', '.tsx', '.js', '.jsx', '.mjs', '.cjs'],\n plugins: [\n createSwcPlugin({\n mode: 'step',\n entriesToBundle: [stepFile],\n outdir,\n bundleTransitiveLocalStepDependencies: true,\n }),\n ],\n });\n\n expect(result.errors).toHaveLength(0);\n const output = result.outputFiles[0].text;\n expect(output).toContain('from-helper');\n expect(output).not.toMatch(/from\\s+[\"'][^\"']*shared\\/constants/);\n expect(output).not.toMatch(/from\\s+[\"'][^\"']*shared\\/helpers/);\n });\n\n it('externalizes transitive local TypeScript dependencies by default', async () => {\n const outdir = join(testRoot, 'out');\n const stepFile = join(testRoot, 'server', 'workflows', 'my-workflow.ts');\n const constantsFile = join(testRoot, 'shared', 'constants.ts');\n const helpersFile = join(testRoot, 'shared', 'helpers.ts');\n\n writeFile(helpersFile, `export const HELPER_VALUE = \"from-helper\";`);\n writeFile(\n constantsFile,\n `import { HELPER_VALUE } from './helpers';\\nexport const CATEGORIES = [HELPER_VALUE];`\n );\n writeFile(\n stepFile,\n `import { CATEGORIES } from '../../shared/constants';\\nexport async function myStep() {\\n 'use step';\\n return CATEGORIES[0];\\n}`\n );\n\n const state = {\n discoveredSteps: new Set<string>(),\n discoveredWorkflows: new Set<string>(),\n discoveredSerdeFiles: new Set<string>(),\n };\n await esbuild.build({\n entryPoints: [stepFile],\n absWorkingDir: testRoot,\n bundle: true,\n format: 'esm',\n platform: 'node',\n write: false,\n resolveExtensions: ['.ts', '.tsx', '.js', '.jsx', '.mjs', '.cjs'],\n plugins: [createDiscoverEntriesPlugin(state, testRoot)],\n });\n\n const result = await esbuild.build({\n entryPoints: [stepFile],\n absWorkingDir: testRoot,\n outdir,\n bundle: true,\n format: 'esm',\n platform: 'node',\n write: false,\n resolveExtensions: ['.ts', '.tsx', '.js', '.jsx', '.mjs', '.cjs'],\n plugins: [\n createSwcPlugin({\n mode: 'step',\n entriesToBundle: [stepFile],\n outdir,\n }),\n ],\n });\n\n expect(result.errors).toHaveLength(0);\n const output = result.outputFiles[0].text;\n expect(output).not.toContain('from-helper');\n expect(output).toMatch(/from\\s+[\"'][^\"']*shared\\/constants\\.ts[\"']/);\n });\n\n it('keeps ordinary package dependencies external when reachable from a bundled step', async () => {\n const outdir = join(testRoot, 'out');\n const stepFile = join(testRoot, 'server', 'workflows', 'my-workflow.ts');\n const pkgDir = join(testRoot, 'node_modules', 'plain-pkg');\n const pkgIndex = join(pkgDir, 'index.js');\n\n writeFile(\n join(pkgDir, 'package.json'),\n JSON.stringify({ name: 'plain-pkg', main: 'index.js' })\n );\n writeFile(pkgIndex, `export const value = \"from-package\";`);\n writeFile(\n stepFile,\n `import { value } from 'plain-pkg';\\nexport async function myStep() {\\n 'use step';\\n return value;\\n}`\n );\n\n const state = {\n discoveredSteps: new Set<string>(),\n discoveredWorkflows: new Set<string>(),\n discoveredSerdeFiles: new Set<string>(),\n };\n await esbuild.build({\n entryPoints: [stepFile],\n absWorkingDir: testRoot,\n bundle: true,\n format: 'esm',\n platform: 'node',\n write: false,\n plugins: [createDiscoverEntriesPlugin(state, testRoot)],\n });\n\n const result = await esbuild.build({\n entryPoints: [stepFile],\n absWorkingDir: testRoot,\n outdir,\n bundle: true,\n format: 'esm',\n platform: 'node',\n write: false,\n plugins: [\n createSwcPlugin({\n mode: 'step',\n entriesToBundle: [stepFile],\n outdir,\n bundleTransitiveLocalStepDependencies: true,\n }),\n ],\n });\n\n expect(result.errors).toHaveLength(0);\n const output = result.outputFiles[0].text;\n expect(output).toMatch(/from\\s+[\"']plain-pkg[\"']/);\n expect(output).not.toContain('from-package');\n });\n\n it('bundles package parents when they lead to discovered workflow-related entries', async () => {\n const outdir = join(testRoot, 'out');\n const stepFile = join(testRoot, 'server', 'workflows', 'my-workflow.ts');\n const pkgDir = join(testRoot, 'node_modules', 'workflow-pkg');\n const pkgIndex = join(pkgDir, 'index.js');\n const pkgSerde = join(pkgDir, 'serde.js');\n\n writeFile(\n join(pkgDir, 'package.json'),\n JSON.stringify({ name: 'workflow-pkg', main: 'index.js' })\n );\n writeFile(pkgSerde, `export const value = \"from-serde\";`);\n writeFile(pkgIndex, `export { value } from './serde.js';`);\n writeFile(\n stepFile,\n `import { value } from 'workflow-pkg';\\nexport async function myStep() {\\n 'use step';\\n return value;\\n}`\n );\n\n const state = {\n discoveredSteps: new Set<string>(),\n discoveredWorkflows: new Set<string>(),\n discoveredSerdeFiles: new Set<string>(),\n };\n await esbuild.build({\n entryPoints: [stepFile],\n absWorkingDir: testRoot,\n bundle: true,\n format: 'esm',\n platform: 'node',\n write: false,\n plugins: [createDiscoverEntriesPlugin(state, testRoot)],\n });\n\n const result = await esbuild.build({\n entryPoints: [stepFile],\n absWorkingDir: testRoot,\n outdir,\n bundle: true,\n format: 'esm',\n platform: 'node',\n write: false,\n plugins: [\n createSwcPlugin({\n mode: 'step',\n entriesToBundle: [stepFile, pkgSerde],\n outdir,\n }),\n ],\n });\n\n expect(result.errors).toHaveLength(0);\n const output = result.outputFiles[0].text;\n expect(output).toContain('from-serde');\n expect(output).not.toMatch(/from\\s+[\"']workflow-pkg[\"']/);\n });\n});\n\ndescribe('createSwcPlugin sideEffectEntries', () => {\n let testRoot: string;\n\n beforeEach(() => {\n testRoot = mkdtempSync(join(realTmpdir, 'workflow-swc-plugin-'));\n applySwcTransformMock.mockReset();\n });\n\n afterEach(() => {\n rmSync(testRoot, { recursive: true, force: true });\n });\n\n /**\n * Helper: creates a fake node_modules package with `\"sideEffects\": false`\n * in its package.json and a single entry file that exports a side-effectful\n * registration call (simulating what the SWC transform produces).\n */\n function createSideEffectsFalsePackage(\n packageName: string,\n entryCode: string\n ): string {\n const pkgDir = join(testRoot, 'node_modules', packageName);\n writeFile(\n join(pkgDir, 'package.json'),\n JSON.stringify({\n name: packageName,\n version: '1.0.0',\n sideEffects: false,\n main: 'index.js',\n })\n );\n const entryPath = join(pkgDir, 'index.js');\n writeFile(entryPath, entryCode);\n return entryPath;\n }\n\n it('preserves bare imports of sideEffectEntries packages when bundling without entriesToBundle', async () => {\n const sideEffectCode =\n 'globalThis.__registered = globalThis.__registered || [];\\nglobalThis.__registered.push(\"my-pkg\");';\n const entryPath = createSideEffectsFalsePackage(\n 'my-side-effect-pkg',\n sideEffectCode\n );\n\n // SWC mock: return the code unchanged (the side effects are already there)\n applySwcTransformMock.mockImplementation(\n async (_filename: string, source: string) => ({\n code: source,\n workflowManifest: {},\n })\n );\n\n const result = await esbuild.build({\n stdin: {\n contents: `import 'my-side-effect-pkg';`,\n resolveDir: testRoot,\n sourcefile: 'virtual-entry.js',\n loader: 'js',\n },\n absWorkingDir: testRoot,\n bundle: true,\n format: 'cjs',\n platform: 'node',\n write: false,\n treeShaking: true,\n logLevel: 'silent',\n plugins: [\n createSwcPlugin({\n mode: 'workflow',\n sideEffectEntries: [entryPath],\n }),\n ],\n });\n\n expect(result.errors).toHaveLength(0);\n const output = result.outputFiles[0].text;\n // The registration code should be present in the bundle\n expect(output).toContain('__registered');\n });\n\n it('drops bare imports when sideEffectEntries is NOT provided for sideEffects:false packages', async () => {\n const sideEffectCode =\n 'globalThis.__registered = globalThis.__registered || [];\\nglobalThis.__registered.push(\"my-pkg\");';\n createSideEffectsFalsePackage('my-dropped-pkg', sideEffectCode);\n\n applySwcTransformMock.mockImplementation(\n async (_filename: string, source: string) => ({\n code: source,\n workflowManifest: {},\n })\n );\n\n const result = await esbuild.build({\n stdin: {\n contents: `import 'my-dropped-pkg';`,\n resolveDir: testRoot,\n sourcefile: 'virtual-entry.js',\n loader: 'js',\n },\n absWorkingDir: testRoot,\n bundle: true,\n format: 'cjs',\n platform: 'node',\n write: false,\n treeShaking: true,\n logLevel: 'silent',\n plugins: [\n createSwcPlugin({\n mode: 'workflow',\n }),\n ],\n });\n\n expect(result.errors).toHaveLength(0);\n const output = result.outputFiles[0].text;\n // Without sideEffectEntries, esbuild drops the bare import\n expect(output).not.toContain('__registered');\n });\n\n it('produces no warnings for sideEffectEntries packages', async () => {\n const sideEffectCode =\n 'globalThis.__registered = globalThis.__registered || [];\\nglobalThis.__registered.push(\"warned-pkg\");';\n const entryPath = createSideEffectsFalsePackage(\n 'my-warned-pkg',\n sideEffectCode\n );\n\n applySwcTransformMock.mockImplementation(\n async (_filename: string, source: string) => ({\n code: source,\n workflowManifest: {},\n })\n );\n\n const result = await esbuild.build({\n stdin: {\n contents: `import 'my-warned-pkg';`,\n resolveDir: testRoot,\n sourcefile: 'virtual-entry.js',\n loader: 'js',\n },\n absWorkingDir: testRoot,\n bundle: true,\n format: 'cjs',\n platform: 'node',\n write: false,\n treeShaking: true,\n plugins: [\n createSwcPlugin({\n mode: 'workflow',\n sideEffectEntries: [entryPath],\n }),\n ],\n });\n\n expect(result.errors).toHaveLength(0);\n // No \"ignored-bare-import\" warnings should be produced\n const sideEffectWarnings = result.warnings.filter(\n (w) => w.id === 'ignored-bare-import'\n );\n expect(sideEffectWarnings).toHaveLength(0);\n });\n\n it('preserves bare imports with entriesToBundle and sideEffectEntries together', async () => {\n const sideEffectCode =\n 'globalThis.__registered = globalThis.__registered || [];\\nglobalThis.__registered.push(\"bundled-pkg\");';\n const entryPath = createSideEffectsFalsePackage(\n 'my-bundled-pkg',\n sideEffectCode\n );\n\n applySwcTransformMock.mockImplementation(\n async (_filename: string, source: string) => ({\n code: source,\n workflowManifest: {},\n })\n );\n\n const outdir = join(testRoot, 'out');\n const stepFile = join(testRoot, 'src', 'step.ts');\n writeFile(\n stepFile,\n `import 'my-bundled-pkg';\\nexport const POST = () => {};`\n );\n\n const result = await esbuild.build({\n entryPoints: [stepFile],\n absWorkingDir: testRoot,\n outdir,\n bundle: true,\n format: 'esm',\n platform: 'node',\n write: false,\n treeShaking: true,\n logLevel: 'silent',\n plugins: [\n createSwcPlugin({\n mode: 'step',\n entriesToBundle: [stepFile, entryPath],\n outdir,\n sideEffectEntries: [entryPath],\n }),\n ],\n });\n\n expect(result.errors).toHaveLength(0);\n const output = result.outputFiles[0].text;\n // The registration code should be bundled in\n expect(output).toContain('__registered');\n });\n\n it('preserves bare imports for local files with sideEffects:false in their parent package.json', async () => {\n // Simulate a workspace package with sideEffects: false\n const pkgDir = join(testRoot, 'packages', 'shared');\n writeFile(\n join(pkgDir, 'package.json'),\n JSON.stringify({\n name: '@myorg/shared',\n version: '1.0.0',\n sideEffects: false,\n main: 'index.js',\n })\n );\n const sharedEntry = join(pkgDir, 'index.js');\n writeFile(sharedEntry, 'globalThis.__sharedRegistered = true;');\n\n applySwcTransformMock.mockImplementation(\n async (_filename: string, source: string) => ({\n code: source,\n workflowManifest: {},\n })\n );\n\n // Use a relative import to the local file (like the virtual entry does for local files)\n const result = await esbuild.build({\n stdin: {\n contents: `import './packages/shared/index.js';`,\n resolveDir: testRoot,\n sourcefile: 'virtual-entry.js',\n loader: 'js',\n },\n absWorkingDir: testRoot,\n bundle: true,\n format: 'cjs',\n platform: 'node',\n write: false,\n treeShaking: true,\n logLevel: 'silent',\n plugins: [\n createSwcPlugin({\n mode: 'workflow',\n sideEffectEntries: [sharedEntry],\n }),\n ],\n });\n\n expect(result.errors).toHaveLength(0);\n const output = result.outputFiles[0].text;\n expect(output).toContain('__sharedRegistered');\n });\n\n it('does not override sideEffects for non-entry modules', async () => {\n // Create two packages - one is a side-effect entry, one is not\n const sideEffectCode = 'globalThis.__entryRegistered = true;';\n const entryPath = createSideEffectsFalsePackage(\n 'entry-pkg',\n sideEffectCode\n );\n\n const nonEntryCode = 'globalThis.__nonEntryRegistered = true;';\n createSideEffectsFalsePackage('non-entry-pkg', nonEntryCode);\n\n applySwcTransformMock.mockImplementation(\n async (_filename: string, source: string) => ({\n code: source,\n workflowManifest: {},\n })\n );\n\n const result = await esbuild.build({\n stdin: {\n contents: `import 'entry-pkg';\\nimport 'non-entry-pkg';`,\n resolveDir: testRoot,\n sourcefile: 'virtual-entry.js',\n loader: 'js',\n },\n absWorkingDir: testRoot,\n bundle: true,\n format: 'cjs',\n platform: 'node',\n write: false,\n treeShaking: true,\n logLevel: 'silent',\n plugins: [\n createSwcPlugin({\n mode: 'workflow',\n // Only entry-pkg is listed, non-entry-pkg is not\n sideEffectEntries: [entryPath],\n }),\n ],\n });\n\n expect(result.errors).toHaveLength(0);\n const output = result.outputFiles[0].text;\n // entry-pkg should be preserved\n expect(output).toContain('__entryRegistered');\n // non-entry-pkg should be dropped (sideEffects: false is respected)\n expect(output).not.toContain('__nonEntryRegistered');\n });\n});\n\ndescribe('createSwcPlugin projectRoot', () => {\n let testRoot: string;\n\n beforeEach(() => {\n testRoot = mkdtempSync(join(realTmpdir, 'workflow-swc-plugin-'));\n applySwcTransformMock.mockReset();\n applySwcTransformMock.mockImplementation(\n async (_filename: string, source: string) => ({\n code: source,\n workflowManifest: {},\n })\n );\n });\n\n afterEach(() => {\n rmSync(testRoot, { recursive: true, force: true });\n });\n\n function setupFixture() {\n const appRoot = join(testRoot, 'apps', 'chat');\n const packageRoot = join(testRoot, 'packages', 'vade');\n const workflowFile = join(\n packageRoot,\n 'src',\n 'internal',\n 'message',\n 'workflow',\n 'handle-message.ts'\n );\n\n writeFile(\n workflowFile,\n `export async function handleMessageWorkflow(message) {\n \"use workflow\";\n\n return message;\n}\n`\n );\n\n return {\n appRoot,\n packageRoot,\n workflowFile,\n };\n }\n\n it('passes the explicit projectRoot through to applySwcTransform', async () => {\n const fixture = setupFixture();\n\n const result = await esbuild.build({\n entryPoints: [fixture.workflowFile],\n absWorkingDir: fixture.packageRoot,\n bundle: true,\n format: 'esm',\n platform: 'node',\n write: false,\n plugins: [\n createSwcPlugin({\n mode: 'workflow',\n projectRoot: fixture.appRoot,\n workflowManifest: {},\n }),\n ],\n });\n\n expect(result.errors).toHaveLength(0);\n expect(applySwcTransformMock).toHaveBeenCalledWith(\n 'src/internal/message/workflow/handle-message.ts',\n expect.stringContaining('\"use workflow\"'),\n 'workflow',\n fixture.workflowFile,\n fixture.appRoot\n );\n });\n\n it('defaults the transform projectRoot to absWorkingDir', async () => {\n const fixture = setupFixture();\n\n const result = await esbuild.build({\n entryPoints: [fixture.workflowFile],\n absWorkingDir: fixture.packageRoot,\n bundle: true,\n format: 'esm',\n platform: 'node',\n write: false,\n plugins: [\n createSwcPlugin({\n mode: 'workflow',\n workflowManifest: {},\n }),\n ],\n });\n\n expect(result.errors).toHaveLength(0);\n expect(applySwcTransformMock).toHaveBeenCalledWith(\n 'src/internal/message/workflow/handle-message.ts',\n expect.stringContaining('\"use workflow\"'),\n 'workflow',\n fixture.workflowFile,\n fixture.packageRoot\n );\n });\n});\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"transform-utils.js","sourceRoot":"","sources":["../src/transform-utils.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,0GAA0G;AAC1G,MAAM,CAAC,MAAM,kBAAkB,GAAG,iCAAiC,CAAC;AACpE,MAAM,CAAC,MAAM,cAAc,GAAG,6BAA6B,CAAC;AAE5D,0EAA0E;AAC1E,8DAA8D;AAC9D,MAAM,CAAC,MAAM,0BAA0B,GAAG,iCAAiC,CAAC;AAE5E,iGAAiG;AACjG,oEAAoE;AACpE,MAAM,CAAC,MAAM,0BAA0B,GACrC,oEAAoE,CAAC;AAEvE,yFAAyF;AACzF,sDAAsD;AACtD,2FAA2F;AAC3F,MAAM,CAAC,MAAM,oCAAoC,GAC/C,8CAA8C,CAAC;AAEjD,2EAA2E;AAC3E,gFAAgF;AAChF,MAAM,CAAC,MAAM,4BAA4B,GACvC,qCAAqC,CAAC;AAExC,uFAAuF;AACvF,mFAAmF;AACnF,WAAW;AACX,6BAA6B;AAC7B,4BAA4B;AAC5B,yEAAyE;AACzE,wEAAwE;AACxE,mCAAmC;AACnC,2EAA2E;AAC3E,MAAM,CAAC,MAAM,sBAAsB,GACjC,mOAAmO,CAAC;AAoBtO;;;;GAIG;AACH,MAAM,UAAU,sBAAsB,CAAC,MAAc;IACnD,MAAM,cAAc,GAAG,kBAAkB,CAAC,IAAI,CAAC,MAAM,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workflow transformation.\n * Used by builders, rollup plugin, Next.js loader, and vite plugin.\n */\n\n// Matches: 'use workflow'; \"use workflow\"; 'use step'; \"use step\"; at line start with optional whitespace\nexport const useWorkflowPattern = /^\\s*(['\"])use workflow\\1;?\\s*$/m;\nexport const useStepPattern = /^\\s*(['\"])use step\\1;?\\s*$/m;\n\n// Matches imports from '@workflow/serde' (for custom class serialization)\n// e.g.: import { WORKFLOW_SERIALIZE } from '@workflow/serde';\nexport const workflowSerdeImportPattern = /from\\s+(['\"])@workflow\\/serde\\1/;\n\n// Matches direct usage of Symbol.for('workflow-serialize') or Symbol.for('workflow-deserialize')\n// e.g.: static [Symbol.for('workflow-serialize')](instance) { ... }\nexport const workflowSerdeSymbolPattern =\n /Symbol\\.for\\s*\\(\\s*(['\"])workflow-(?:serialize|deserialize)\\1\\s*\\)/;\n\n// Matches usage of WORKFLOW_SERIALIZE or WORKFLOW_DESERIALIZE as computed property names\n// e.g.: static [WORKFLOW_SERIALIZE](instance) { ... }\n// This catches cases where the symbols are imported and used (even if bundled/re-exported)\nexport const workflowSerdeComputedPropertyPattern =\n /\\[\\s*WORKFLOW_(?:SERIALIZE|DESERIALIZE)\\s*\\]/;\n\n// Pattern to detect generated workflow route files that should be excluded\n// These files are generated by the build process and should not be re-processed\nexport const generatedWorkflowPathPattern =\n /[/\\\\]\\.well-known[/\\\\]workflow[/\\\\]/;\n\n// Pattern to detect @workflow SDK packages that should be excluded from transformation\n// These are internal SDK packages that should not be treated as user entry points.\n// Matches:\n// - node_modules/@workflow/*\n// - node_modules/workflow/*\n// - node_modules/.pnpm/.../node_modules/@workflow/* (pnpm virtual store)\n// - node_modules/.pnpm/.../node_modules/workflow/* (pnpm virtual store)\n// - monorepo packages/*/dist paths\n// User npm packages with workflows/steps/serde SHOULD still be discovered.\nexport const workflowSdkPathPattern =\n /[/\\\\](?:node_modules[/\\\\](?:@workflow[/\\\\]|workflow[/\\\\]|\\.pnpm[/\\\\][^/\\\\]+[/\\\\]node_modules[/\\\\](?:@workflow[/\\\\]|workflow[/\\\\]))|packages[/\\\\](?:builders|core|rollup|vite|next|nitro|serde|workflow|swc-plugin-workflow)[/\\\\])/;\n\n/**\n * Detects workflow-related patterns in source code.\n */\nexport interface WorkflowPatternMatch {\n /** File contains 'use workflow' directive */\n hasUseWorkflow: boolean;\n /** File contains 'use step' directive */\n hasUseStep: boolean;\n /** File contains @workflow/serde import */\n hasSerdeImport: boolean;\n /** File contains Symbol.for('workflow-serialize') or Symbol.for('workflow-deserialize') */\n hasSerdeSymbol: boolean;\n /** File contains any directive ('use workflow' or 'use step') */\n hasDirective: boolean;\n /** File contains any serde pattern (import or Symbol.for) */\n hasSerde: boolean;\n}\n\n/**\n * Detects workflow-related patterns in source code.\n * @param source - The source code to analyze\n * @returns Object with flags for each detected pattern\n */\nexport function detectWorkflowPatterns(source: string): WorkflowPatternMatch {\n const hasUseWorkflow = useWorkflowPattern.test(source);\n const hasUseStep = useStepPattern.test(source);\n const hasSerdeImport = workflowSerdeImportPattern.test(source);\n const hasSerdeSymbol = workflowSerdeSymbolPattern.test(source);\n const hasSerdeComputedProperty =\n workflowSerdeComputedPropertyPattern.test(source);\n\n return {\n hasUseWorkflow,\n hasUseStep,\n hasSerdeImport,\n hasSerdeSymbol,\n hasDirective: hasUseWorkflow || hasUseStep,\n hasSerde: hasSerdeImport || hasSerdeSymbol || hasSerdeComputedProperty,\n };\n}\n\n/**\n * Determines if a file path is a generated workflow route file.\n * @param filePath - The file path to check\n * @returns true if the file is a generated workflow route\n */\nexport function isGeneratedWorkflowFile(filePath: string): boolean {\n return generatedWorkflowPathPattern.test(filePath);\n}\n\n/**\n * Determines if a file path is part of the @workflow SDK.\n * @param filePath - The file path to check\n * @returns true if the file is part of the @workflow SDK\n */\nexport function isWorkflowSdkFile(filePath: string): boolean {\n return workflowSdkPathPattern.test(filePath);\n}\n\n/**\n * Determines if a file should be transformed based on its path and content patterns.\n *\n * Logic:\n * - Generated workflow route files are never transformed\n * - Files with directives ('use workflow' or 'use step') are always transformed\n * - Files with serde patterns are transformed, unless they're @workflow SDK files\n * (SDK files with serde patterns are internal implementation, not user code)\n *\n * @param filePath - The file path to check\n * @param patterns - The detected patterns from detectWorkflowPatterns()\n * @returns true if the file should be transformed\n */\nexport function shouldTransformFile(\n filePath: string,\n patterns: WorkflowPatternMatch\n): boolean {\n // Never transform generated workflow route files\n if (isGeneratedWorkflowFile(filePath)) {\n return false;\n }\n\n // Always transform files with directives\n if (patterns.hasDirective) {\n return true;\n }\n\n // Transform files with serde patterns, unless they're @workflow SDK files\n if (patterns.hasSerde) {\n return !isWorkflowSdkFile(filePath);\n }\n\n return false;\n}\n\n/**\n * Combined regex pattern for turbopack content matching.\n * Uses backreferences to ensure matching quote types.\n * Matches: 'use workflow', 'use step', @workflow/serde imports, Symbol.for serialization symbols,\n * and WORKFLOW_SERIALIZE/WORKFLOW_DESERIALIZE computed property usage\n */\nexport const turbopackContentPattern =\n /(use workflow|use step|from\\s+(['\"])@workflow\\/serde\\2|Symbol\\.for\\s*\\(\\s*(['\"])workflow-(?:serialize|deserialize)\\3\\s*\\)|\\[\\s*WORKFLOW_(?:SERIALIZE|DESERIALIZE)\\s*\\])/;\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"transform-utils.test.js","sourceRoot":"","sources":["../src/transform-utils.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,QAAQ,CAAC;AAC9C,OAAO,EACL,sBAAsB,EACtB,iBAAiB,EACjB,cAAc,EACd,kBAAkB,EAClB,oCAAoC,EACpC,0BAA0B,EAC1B,0BAA0B,GAC3B,MAAM,sBAAsB,CAAC;AAE9B,QAAQ,CAAC,0BAA0B,EAAE,GAAG,EAAE;IACxC,QAAQ,CAAC,oBAAoB,EAAE,GAAG,EAAE;QAClC,EAAE,CAAC,gDAAgD,EAAE,GAAG,EAAE;YACxD,MAAM,CAAC,kBAAkB,CAAC,IAAI,CAAC,iBA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AAC,CAAC","sourcesContent":["import { describe, expect, it } from 'vitest';\nimport {\n detectWorkflowPatterns,\n isWorkflowSdkFile,\n useStepPattern,\n useWorkflowPattern,\n workflowSerdeComputedPropertyPattern,\n workflowSerdeImportPattern,\n workflowSerdeSymbolPattern,\n} from './transform-utils.js';\n\ndescribe('transform-utils patterns', () => {\n describe('useWorkflowPattern', () => {\n it('should match \"use workflow\" with single quotes', () => {\n expect(useWorkflowPattern.test(`'use workflow';`)).toBe(true);\n expect(useWorkflowPattern.test(`'use workflow'`)).toBe(true);\n });\n\n it('should match \"use workflow\" with double quotes', () => {\n expect(useWorkflowPattern.test(`\"use workflow\";`)).toBe(true);\n expect(useWorkflowPattern.test(`\"use workflow\"`)).toBe(true);\n });\n\n it('should match with leading whitespace', () => {\n expect(useWorkflowPattern.test(` 'use workflow';`)).toBe(true);\n expect(useWorkflowPattern.test(`\\t\"use workflow\";`)).toBe(true);\n });\n\n it('should not match inline usage', () => {\n expect(useWorkflowPattern.test(`const x = 'use workflow';`)).toBe(false);\n });\n });\n\n describe('useStepPattern', () => {\n it('should match \"use step\" with single quotes', () => {\n expect(useStepPattern.test(`'use step';`)).toBe(true);\n expect(useStepPattern.test(`'use step'`)).toBe(true);\n });\n\n it('should match \"use step\" with double quotes', () => {\n expect(useStepPattern.test(`\"use step\";`)).toBe(true);\n expect(useStepPattern.test(`\"use step\"`)).toBe(true);\n });\n });\n\n describe('workflowSerdeImportPattern', () => {\n it('should match import from @workflow/serde with single quotes', () => {\n const source = `import { WORKFLOW_SERIALIZE } from '@workflow/serde';`;\n expect(workflowSerdeImportPattern.test(source)).toBe(true);\n });\n\n it('should match import from @workflow/serde with double quotes', () => {\n const source = `import { WORKFLOW_SERIALIZE } from \"@workflow/serde\";`;\n expect(workflowSerdeImportPattern.test(source)).toBe(true);\n });\n\n it('should match import with multiple specifiers', () => {\n const source = `import { WORKFLOW_SERIALIZE, WORKFLOW_DESERIALIZE } from '@workflow/serde';`;\n expect(workflowSerdeImportPattern.test(source)).toBe(true);\n });\n\n it('should match import with type', () => {\n const source = `import type { SerializationSymbol } from '@workflow/serde';`;\n expect(workflowSerdeImportPattern.test(source)).toBe(true);\n });\n\n it('should not match similar but different packages', () => {\n expect(\n workflowSerdeImportPattern.test(`import { x } from '@other/serde';`)\n ).toBe(false);\n expect(\n workflowSerdeImportPattern.test(\n `import { x } from '@workflow/serde-utils';`\n )\n ).toBe(false);\n });\n });\n\n describe('workflowSerdeSymbolPattern', () => {\n it('should match Symbol.for with workflow-serialize', () => {\n const source = `static [Symbol.for('workflow-serialize')](instance) {}`;\n expect(workflowSerdeSymbolPattern.test(source)).toBe(true);\n });\n\n it('should match Symbol.for with workflow-deserialize', () => {\n const source = `static [Symbol.for('workflow-deserialize')](data) {}`;\n expect(workflowSerdeSymbolPattern.test(source)).toBe(true);\n });\n\n it('should match with double quotes', () => {\n const source = `static [Symbol.for(\"workflow-serialize\")](instance) {}`;\n expect(workflowSerdeSymbolPattern.test(source)).toBe(true);\n });\n\n it('should match with whitespace variations', () => {\n expect(\n workflowSerdeSymbolPattern.test(`Symbol.for( 'workflow-serialize' )`)\n ).toBe(true);\n expect(\n workflowSerdeSymbolPattern.test(`Symbol.for('workflow-deserialize')`)\n ).toBe(true);\n });\n\n it('should match in a full class definition', () => {\n const source = `\n export class Point {\n constructor(x, y) {\n this.x = x;\n this.y = y;\n }\n\n static [Symbol.for('workflow-serialize')](instance) {\n return { x: instance.x, y: instance.y };\n }\n\n static [Symbol.for('workflow-deserialize')](data) {\n return new Point(data.x, data.y);\n }\n }\n `;\n expect(workflowSerdeSymbolPattern.test(source)).toBe(true);\n });\n\n it('should not match other Symbol.for usage', () => {\n expect(\n workflowSerdeSymbolPattern.test(`Symbol.for('other-symbol')`)\n ).toBe(false);\n expect(\n workflowSerdeSymbolPattern.test(`Symbol.for('workflow-something-else')`)\n ).toBe(false);\n });\n\n it('should not match non-Symbol.for patterns', () => {\n expect(workflowSerdeSymbolPattern.test(`'workflow-serialize'`)).toBe(\n false\n );\n expect(workflowSerdeSymbolPattern.test(`workflow-deserialize`)).toBe(\n false\n );\n });\n });\n\n describe('combined detection', () => {\n it('should detect file using imported symbols', () => {\n const source = `\n import { WORKFLOW_SERIALIZE, WORKFLOW_DESERIALIZE } from '@workflow/serde';\n\n export class MyClass {\n static [WORKFLOW_SERIALIZE](instance) {\n return { value: instance.value };\n }\n\n static [WORKFLOW_DESERIALIZE](data) {\n return new MyClass(data.value);\n }\n }\n `;\n expect(workflowSerdeImportPattern.test(source)).toBe(true);\n // Note: workflowSerdeSymbolPattern won't match here because the symbols\n // are referenced by identifier, not directly as Symbol.for()\n expect(workflowSerdeSymbolPattern.test(source)).toBe(false);\n });\n\n it('should detect file using direct Symbol.for', () => {\n const source = `\n export class Point {\n static [Symbol.for('workflow-serialize')](instance) {\n return { x: instance.x };\n }\n\n static [Symbol.for('workflow-deserialize')](data) {\n return new Point(data.x);\n }\n }\n `;\n expect(workflowSerdeImportPattern.test(source)).toBe(false);\n expect(workflowSerdeSymbolPattern.test(source)).toBe(true);\n });\n\n it('should detect file with both patterns', () => {\n // This would be unusual but valid\n const source = `\n import { WORKFLOW_SERIALIZE } from '@workflow/serde';\n\n export class Point {\n // Using imported symbol\n static [WORKFLOW_SERIALIZE](instance) {\n return { x: instance.x };\n }\n\n // Using direct Symbol.for\n static [Symbol.for('workflow-deserialize')](data) {\n return new Point(data.x);\n }\n }\n `;\n expect(workflowSerdeImportPattern.test(source)).toBe(true);\n expect(workflowSerdeSymbolPattern.test(source)).toBe(true);\n });\n });\n\n describe('workflowSerdeComputedPropertyPattern', () => {\n it('should match [WORKFLOW_SERIALIZE] computed property', () => {\n const source = `static [WORKFLOW_SERIALIZE](instance) {}`;\n expect(workflowSerdeComputedPropertyPattern.test(source)).toBe(true);\n });\n\n it('should match [WORKFLOW_DESERIALIZE] computed property', () => {\n const source = `static [WORKFLOW_DESERIALIZE](data) {}`;\n expect(workflowSerdeComputedPropertyPattern.test(source)).toBe(true);\n });\n\n it('should match with whitespace inside brackets', () => {\n expect(\n workflowSerdeComputedPropertyPattern.test(`[ WORKFLOW_SERIALIZE ]`)\n ).toBe(true);\n expect(\n workflowSerdeComputedPropertyPattern.test(`[ WORKFLOW_DESERIALIZE ]`)\n ).toBe(true);\n });\n\n it('should match in bundled code where symbols are imported from chunks', () => {\n // This is the pattern seen in bundled packages like just-bash\n const source = `\n import {\n WORKFLOW_DESERIALIZE,\n WORKFLOW_SERIALIZE\n } from \"./chunks/chunk-453323QY.js\";\n\n var Bash = class _Bash {\n static [WORKFLOW_SERIALIZE](instance) {\n return { fs: instance.fs };\n }\n static [WORKFLOW_DESERIALIZE](serialized) {\n return Object.create(_Bash.prototype, {\n fs: { value: serialized.fs }\n });\n }\n };\n `;\n expect(workflowSerdeComputedPropertyPattern.test(source)).toBe(true);\n // Note: import pattern won't match because it's from a chunk, not @workflow/serde\n expect(workflowSerdeImportPattern.test(source)).toBe(false);\n });\n\n it('should not match partial names', () => {\n expect(\n workflowSerdeComputedPropertyPattern.test(`[WORKFLOW_SERIALIZE_EXTRA]`)\n ).toBe(false);\n expect(\n workflowSerdeComputedPropertyPattern.test(`[MY_WORKFLOW_SERIALIZE]`)\n ).toBe(false);\n });\n\n it('should not match string literals', () => {\n expect(\n workflowSerdeComputedPropertyPattern.test(`['WORKFLOW_SERIALIZE']`)\n ).toBe(false);\n expect(\n workflowSerdeComputedPropertyPattern.test(`[\"WORKFLOW_DESERIALIZE\"]`)\n ).toBe(false);\n });\n });\n\n describe('detectWorkflowPatterns', () => {\n it('should detect hasSerde for @workflow/serde import', () => {\n const source = `import { WORKFLOW_SERIALIZE } from '@workflow/serde';`;\n const result = detectWorkflowPatterns(source);\n expect(result.hasSerde).toBe(true);\n expect(result.hasSerdeImport).toBe(true);\n });\n\n it('should detect hasSerde for Symbol.for pattern', () => {\n const source = `static [Symbol.for('workflow-serialize')](instance) {}`;\n const result = detectWorkflowPatterns(source);\n expect(result.hasSerde).toBe(true);\n expect(result.hasSerdeSymbol).toBe(true);\n });\n\n it('should detect hasSerde for computed property pattern', () => {\n const source = `static [WORKFLOW_SERIALIZE](instance) {}`;\n const result = detectWorkflowPatterns(source);\n expect(result.hasSerde).toBe(true);\n });\n\n it('should detect hasSerde for bundled third-party packages', () => {\n // Simulates bundled output from packages like just-bash\n const source = `\n import {\n WORKFLOW_DESERIALIZE,\n WORKFLOW_SERIALIZE\n } from \"./chunks/chunk-ABC123.js\";\n\n var MyClass = class {\n static [WORKFLOW_SERIALIZE](instance) {\n return { data: instance.data };\n }\n static [WORKFLOW_DESERIALIZE](serialized) {\n return new MyClass(serialized.data);\n }\n };\n `;\n const result = detectWorkflowPatterns(source);\n expect(result.hasSerde).toBe(true);\n });\n\n it('should not detect hasSerde for unrelated code', () => {\n const source = `\n export class RegularClass {\n constructor(value) {\n this.value = value;\n }\n }\n `;\n const result = detectWorkflowPatterns(source);\n expect(result.hasSerde).toBe(false);\n });\n\n it('should detect both directive and serde patterns', () => {\n const source = `\n 'use step';\n import { WORKFLOW_SERIALIZE } from '@workflow/serde';\n \n export class Point {\n static [WORKFLOW_SERIALIZE](instance) {\n return { x: instance.x };\n }\n }\n `;\n const result = detectWorkflowPatterns(source);\n expect(result.hasDirective).toBe(true);\n expect(result.hasUseStep).toBe(true);\n expect(result.hasSerde).toBe(true);\n });\n });\n\n describe('isWorkflowSdkFile', () => {\n it('matches direct @workflow package path in node_modules', () => {\n expect(\n isWorkflowSdkFile(\n '/tmp/app/node_modules/@workflow/core/dist/serialization.js'\n )\n ).toBe(true);\n });\n\n it('matches direct workflow package path in node_modules', () => {\n expect(\n isWorkflowSdkFile('/tmp/app/node_modules/workflow/dist/runtime.js')\n ).toBe(true);\n });\n\n it('matches pnpm virtual store @workflow package path', () => {\n expect(\n isWorkflowSdkFile(\n '/tmp/app/node_modules/.pnpm/@workflow+core@4.1.0/node_modules/@workflow/core/dist/serialization.js'\n )\n ).toBe(true);\n });\n\n it('matches pnpm virtual store workflow package path', () => {\n expect(\n isWorkflowSdkFile(\n '/tmp/app/node_modules/.pnpm/workflow@4.1.0/node_modules/workflow/dist/runtime.js'\n )\n ).toBe(true);\n });\n\n it('does not match non-workflow package in pnpm store', () => {\n expect(\n isWorkflowSdkFile(\n '/tmp/app/node_modules/.pnpm/lodash@4.17.21/node_modules/lodash/lodash.js'\n )\n ).toBe(false);\n });\n });\n});\n"]}