@workflow/builders 5.0.0-beta.3 → 5.0.0-beta.31

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 (134) hide show
  1. package/dist/apply-swc-transform.d.ts +7 -2
  2. package/dist/apply-swc-transform.d.ts.map +1 -1
  3. package/dist/apply-swc-transform.js +10 -4
  4. package/dist/base-builder-logging.test.d.ts +2 -0
  5. package/dist/base-builder-logging.test.d.ts.map +1 -0
  6. package/dist/base-builder-logging.test.js +99 -0
  7. package/dist/base-builder.d.ts +127 -13
  8. package/dist/base-builder.d.ts.map +1 -1
  9. package/dist/base-builder.js +812 -102
  10. package/dist/build-queue.js +1 -1
  11. package/dist/config-helpers.d.ts +4 -1
  12. package/dist/config-helpers.d.ts.map +1 -1
  13. package/dist/config-helpers.js +63 -1
  14. package/dist/config-helpers.test.d.ts +2 -0
  15. package/dist/config-helpers.test.d.ts.map +1 -0
  16. package/dist/config-helpers.test.js +17 -0
  17. package/dist/constants.d.ts +31 -5
  18. package/dist/constants.d.ts.map +1 -1
  19. package/dist/constants.js +71 -19
  20. package/dist/constants.test.d.ts +2 -0
  21. package/dist/constants.test.d.ts.map +1 -0
  22. package/dist/constants.test.js +40 -0
  23. package/dist/discover-entries-esbuild-plugin.d.ts +3 -1
  24. package/dist/discover-entries-esbuild-plugin.d.ts.map +1 -1
  25. package/dist/discover-entries-esbuild-plugin.js +24 -4
  26. package/dist/discover-entries-esbuild-plugin.test.js +1 -1
  27. package/dist/esbuild-tsconfig.js +1 -1
  28. package/dist/esbuild-tsconfig.test.js +1 -1
  29. package/dist/external-package-warning.test.d.ts +2 -0
  30. package/dist/external-package-warning.test.d.ts.map +1 -0
  31. package/dist/external-package-warning.test.js +219 -0
  32. package/dist/fast-discovery.d.ts +20 -0
  33. package/dist/fast-discovery.d.ts.map +1 -0
  34. package/dist/fast-discovery.js +774 -0
  35. package/dist/fast-discovery.test.d.ts +2 -0
  36. package/dist/fast-discovery.test.d.ts.map +1 -0
  37. package/dist/fast-discovery.test.js +336 -0
  38. package/dist/get-input-files.test.js +34 -2
  39. package/dist/index.d.ts +8 -3
  40. package/dist/index.d.ts.map +1 -1
  41. package/dist/index.js +9 -4
  42. package/dist/module-specifier.d.ts +20 -2
  43. package/dist/module-specifier.d.ts.map +1 -1
  44. package/dist/module-specifier.js +92 -17
  45. package/dist/module-specifier.test.js +45 -3
  46. package/dist/node-compat-banner.d.ts +15 -0
  47. package/dist/node-compat-banner.d.ts.map +1 -0
  48. package/dist/node-compat-banner.js +15 -0
  49. package/dist/node-module-esbuild-plugin.d.ts.map +1 -1
  50. package/dist/node-module-esbuild-plugin.js +73 -23
  51. package/dist/node-module-esbuild-plugin.test.js +97 -1
  52. package/dist/optional-otel-api.d.ts +14 -0
  53. package/dist/optional-otel-api.d.ts.map +1 -0
  54. package/dist/optional-otel-api.js +14 -0
  55. package/dist/optional-pg-native-alias.d.ts +2 -0
  56. package/dist/optional-pg-native-alias.d.ts.map +1 -0
  57. package/dist/optional-pg-native-alias.js +3 -0
  58. package/dist/optional-pg-native.d.ts +3 -0
  59. package/dist/optional-pg-native.d.ts.map +1 -0
  60. package/dist/optional-pg-native.js +3 -0
  61. package/dist/optional-typescript-alias.d.ts +2 -0
  62. package/dist/optional-typescript-alias.d.ts.map +1 -0
  63. package/dist/optional-typescript-alias.js +3 -0
  64. package/dist/optional-typescript.d.ts +3 -0
  65. package/dist/optional-typescript.d.ts.map +1 -0
  66. package/dist/optional-typescript.js +9 -0
  67. package/dist/pseudo-package-esbuild-plugin.js +1 -1
  68. package/dist/pseudo-package-esbuild-plugin.test.js +1 -1
  69. package/dist/request-converter.js +1 -1
  70. package/dist/resolve-sourcemap.test.d.ts +2 -0
  71. package/dist/resolve-sourcemap.test.d.ts.map +1 -0
  72. package/dist/resolve-sourcemap.test.js +194 -0
  73. package/dist/serde-checker.js +1 -1
  74. package/dist/standalone.d.ts +0 -3
  75. package/dist/standalone.d.ts.map +1 -1
  76. package/dist/standalone.js +12 -41
  77. package/dist/step-source-registration.test.d.ts +2 -0
  78. package/dist/step-source-registration.test.d.ts.map +1 -0
  79. package/dist/step-source-registration.test.js +82 -0
  80. package/dist/swc-esbuild-plugin.d.ts +10 -0
  81. package/dist/swc-esbuild-plugin.d.ts.map +1 -1
  82. package/dist/swc-esbuild-plugin.js +116 -14
  83. package/dist/swc-esbuild-plugin.test.js +370 -6
  84. package/dist/transform-utils.d.ts.map +1 -1
  85. package/dist/transform-utils.js +45 -6
  86. package/dist/transform-utils.test.js +78 -6
  87. package/dist/types.d.ts +38 -2
  88. package/dist/types.d.ts.map +1 -1
  89. package/dist/types.js +1 -1
  90. package/dist/vercel-build-output-api.d.ts +0 -2
  91. package/dist/vercel-build-output-api.d.ts.map +1 -1
  92. package/dist/vercel-build-output-api.js +31 -59
  93. package/dist/workflow-alias.js +1 -1
  94. package/dist/workflow-alias.test.js +1 -1
  95. package/dist/workflows-extractor.js +8 -3
  96. package/dist/workflows-extractor.test.d.ts +2 -0
  97. package/dist/workflows-extractor.test.d.ts.map +1 -0
  98. package/dist/workflows-extractor.test.js +70 -0
  99. package/dist/world-target.d.ts +20 -0
  100. package/dist/world-target.d.ts.map +1 -0
  101. package/dist/world-target.js +74 -0
  102. package/dist/world-target.test.d.ts +2 -0
  103. package/dist/world-target.test.d.ts.map +1 -0
  104. package/dist/world-target.test.js +106 -0
  105. package/package.json +9 -7
  106. package/dist/apply-swc-transform.js.map +0 -1
  107. package/dist/base-builder.js.map +0 -1
  108. package/dist/build-queue.js.map +0 -1
  109. package/dist/config-helpers.js.map +0 -1
  110. package/dist/constants.js.map +0 -1
  111. package/dist/discover-entries-esbuild-plugin.js.map +0 -1
  112. package/dist/discover-entries-esbuild-plugin.test.js.map +0 -1
  113. package/dist/esbuild-tsconfig.js.map +0 -1
  114. package/dist/esbuild-tsconfig.test.js.map +0 -1
  115. package/dist/get-input-files.test.js.map +0 -1
  116. package/dist/index.js.map +0 -1
  117. package/dist/module-specifier.js.map +0 -1
  118. package/dist/module-specifier.test.js.map +0 -1
  119. package/dist/node-module-esbuild-plugin.js.map +0 -1
  120. package/dist/node-module-esbuild-plugin.test.js.map +0 -1
  121. package/dist/pseudo-package-esbuild-plugin.js.map +0 -1
  122. package/dist/pseudo-package-esbuild-plugin.test.js.map +0 -1
  123. package/dist/request-converter.js.map +0 -1
  124. package/dist/serde-checker.js.map +0 -1
  125. package/dist/standalone.js.map +0 -1
  126. package/dist/swc-esbuild-plugin.js.map +0 -1
  127. package/dist/swc-esbuild-plugin.test.js.map +0 -1
  128. package/dist/transform-utils.js.map +0 -1
  129. package/dist/transform-utils.test.js.map +0 -1
  130. package/dist/types.js.map +0 -1
  131. package/dist/vercel-build-output-api.js.map +0 -1
  132. package/dist/workflow-alias.js.map +0 -1
  133. package/dist/workflow-alias.test.js.map +0 -1
  134. package/dist/workflows-extractor.js.map +0 -1
@@ -1 +0,0 @@
1
- {"version":3,"file":"module-specifier.js","sourceRoot":"","sources":["../src/module-specifier.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACnD,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,OAAO,EAAE,GAAG,EAAE,MAAM,WAAW,CAAC;AA2BlE;;;GAGG;AACH,MAAM,gBAAgB,GAAG,IAAI,GAAG,EAA8B,CAAC;AAE/D;;;GAGG;AACH,SAAS,eAAe,CAAC,QAAgB;IACvC,IAAI,GAAG,GAAG,OAAO,CAAC,QAAQ,CAAC,CAAC;IAE5B,gEAAgE;IAChE,MAAM,WAAW,GAAa,EAAE,CAAC;IAEjC,mDAAmD;IACnD,OAAO,GAAG,KAAK,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC;QAC5B,oBAAoB;QACpB,MAAM,MAAM,GAAG,gBAAgB,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;QACzC,IAAI,MAAM,KAAK,SAAS,EAAE,CAAC;YACzB,mEAAmE;YACnE,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AG,OAAO,EAAE;oBACnC,SAAS,EAAE,IAAI;iBAChB,CAAC;YACJ,CAAC;YAED,kEAAkE;YAClE,sEAAsE;YACtE,gEAAgE;YAChE,IAAI,CAAC,oBAAoB,CAAC,QAAQ,EAAE,GAAG,CAAC,EAAE,CAAC;gBACzC,OAAO;oBACL,UAAU,EAAE,oBAAoB,CAAC,QAAQ,EAAE,WAAW,CAAC;oBACvD,SAAS,EAAE,KAAK;iBACjB,CAAC;YACJ,CAAC;YAED,OAAO;gBACL,UAAU,EAAE,GAAG,CAAC,IAAI;gBACpB,SAAS,EAAE,IAAI;aAChB,CAAC;QACJ,CAAC;IACH,CAAC;IAED,qCAAqC;IACrC,OAAO;QACL,UAAU,EAAE,oBAAoB,CAAC,QAAQ,EAAE,WAAW,CAAC;QACvD,SAAS,EAAE,KAAK;KACjB,CAAC;AACJ,CAAC","sourcesContent":["import { existsSync, readFileSync } from 'node:fs';\nimport { dirname, join, relative, resolve, sep } from 'node:path';\n\n/**\n * Result of resolving a module specifier for a file.\n */\nexport interface ModuleSpecifierResult {\n /**\n * The module specifier to use for ID generation.\n * - For packages: \"{name}@{version}\" or \"{name}/{subpath}@{version}\"\n * (e.g., \"point@1.0.0\", \"@myorg/shared@2.0.0\", \"workflow/internal/builtins@4.0.0\")\n * - For local files: undefined (plugin will use default \"./relative/path\" format)\n */\n moduleSpecifier: string | undefined;\n}\n\n/**\n * Parsed package.json data with directory information.\n */\ninterface PackageInfo {\n name: string;\n version: string;\n dir: string;\n exports?: Record<string, unknown>;\n main?: string;\n module?: string;\n}\n\n/**\n * Cache for package.json lookups to avoid repeated filesystem reads.\n * Maps directory path to parsed package.json info or null if not found.\n */\nconst packageJsonCache = new Map<string, PackageInfo | null>();\n\n/**\n * Find and read the nearest package.json for a given file path.\n * Results are cached for performance.\n */\nfunction findPackageJson(filePath: string): PackageInfo | null {\n let dir = dirname(filePath);\n\n // Track directories we've visited so we can back-fill the cache\n const visitedDirs: string[] = [];\n\n // Walk up the directory tree until we hit the root\n while (dir !== dirname(dir)) {\n // Check cache first\n const cached = packageJsonCache.get(dir);\n if (cached !== undefined) {\n // Back-fill cache for all visited directories with the same result\n for (const visitedDir of visitedDirs) {\n packageJsonCache.set(visitedDir, cached);\n }\n return cached;\n }\n\n visitedDirs.push(dir);\n\n const packageJsonPath = join(dir, 'package.json');\n if (existsSync(packageJsonPath)) {\n try {\n const content = readFileSync(packageJsonPath, 'utf-8');\n const parsed = JSON.parse(content);\n if (parsed.name && parsed.version) {\n const result: PackageInfo = {\n name: parsed.name,\n version: parsed.version,\n dir,\n exports: parsed.exports,\n main: parsed.main,\n module: parsed.module,\n };\n // Cache the result for this directory and all visited directories\n packageJsonCache.set(dir, result);\n for (const visitedDir of visitedDirs) {\n packageJsonCache.set(visitedDir, result);\n }\n return result;\n }\n } catch {\n // Invalid JSON or missing fields, continue searching\n }\n }\n\n dir = dirname(dir);\n }\n\n // No package.json found - cache null for all visited directories\n for (const visitedDir of visitedDirs) {\n packageJsonCache.set(visitedDir, null);\n }\n\n return null;\n}\n\n/**\n * Resolve the export subpath for a file within a package.\n * Looks up the package.json exports field to find which subpath maps to the file.\n *\n * @param filePath - Absolute path to the file\n * @param pkg - Package info from findPackageJson\n * @returns The subpath (e.g., \"/internal/builtins\") or empty string for root export\n */\nfunction resolveExportSubpath(filePath: string, pkg: PackageInfo): string {\n if (!pkg.exports || typeof pkg.exports !== 'object') {\n return '';\n }\n\n // Get the relative path from package root to the file\n const normalizedFilePath = filePath.replace(/\\\\/g, '/');\n const normalizedPkgDir = pkg.dir.replace(/\\\\/g, '/');\n const relativePath = normalizedFilePath.startsWith(normalizedPkgDir + '/')\n ? './' + normalizedFilePath.substring(normalizedPkgDir.length + 1)\n : null;\n\n if (!relativePath) {\n return '';\n }\n\n // Search through exports to find a matching subpath\n for (const [subpath, target] of Object.entries(pkg.exports)) {\n const resolvedTarget = resolveExportTarget(target);\n if (\n resolvedTarget &&\n normalizeExportPath(resolvedTarget) === relativePath\n ) {\n // Found a match - return the subpath without the leading \".\"\n // e.g., \"./internal/builtins\" -> \"/internal/builtins\"\n return subpath === '.' ? '' : subpath.substring(1);\n }\n }\n\n return '';\n}\n\n/**\n * Resolve an export target to a file path, handling conditional exports and arrays.\n */\nfunction resolveExportTarget(target: unknown): string | null {\n if (typeof target === 'string') {\n return target;\n }\n\n // Handle array exports (fallback chains)\n if (Array.isArray(target)) {\n for (const item of target) {\n const resolved = resolveExportTarget(item);\n if (resolved) return resolved;\n }\n return null;\n }\n\n if (target && typeof target === 'object') {\n // Conditional export - try common conditions in order of preference\n const conditions = ['workflow', 'default', 'require', 'import', 'node'];\n for (const condition of conditions) {\n const value = (target as Record<string, unknown>)[condition];\n if (typeof value === 'string') {\n return value;\n }\n // Handle nested conditionals or arrays\n if (value && typeof value === 'object') {\n const nested = resolveExportTarget(value);\n if (nested) return nested;\n }\n }\n }\n\n return null;\n}\n\n/**\n * Normalize an export path for comparison.\n */\nfunction normalizeExportPath(path: string): string {\n // Ensure it starts with ./\n if (!path.startsWith('./')) {\n return './' + path;\n }\n return path;\n}\n\n/**\n * Check if a file path is inside node_modules.\n */\nfunction isInNodeModules(filePath: string): boolean {\n const normalizedPath = filePath.split(sep).join('/');\n return normalizedPath.includes('/node_modules/');\n}\n\n/**\n * Cache for project dependencies to avoid repeated filesystem reads.\n * Maps project root to set of dependency package names.\n */\nconst projectDepsCache = new Map<string, Set<string>>();\n\n/**\n * Get all dependencies (including devDependencies) for a project.\n */\nfunction getProjectDependencies(projectRoot: string): Set<string> {\n const cached = projectDepsCache.get(projectRoot);\n if (cached) {\n return cached;\n }\n\n const deps = new Set<string>();\n const pkgPath = join(projectRoot, 'package.json');\n\n if (existsSync(pkgPath)) {\n try {\n const content = readFileSync(pkgPath, 'utf-8');\n const parsed = JSON.parse(content);\n\n // Collect all dependency types\n for (const depType of [\n 'dependencies',\n 'devDependencies',\n 'peerDependencies',\n 'optionalDependencies',\n ]) {\n const depObj = parsed[depType];\n if (depObj && typeof depObj === 'object') {\n for (const name of Object.keys(depObj)) {\n deps.add(name);\n }\n }\n }\n } catch {\n // Invalid JSON or file not readable\n }\n }\n\n projectDepsCache.set(projectRoot, deps);\n return deps;\n}\n\n/**\n * Check if a file path is inside a workspace package that is a dependency of the project.\n * This is a heuristic - we check if the file is in a directory with a package.json\n * that has a \"name\" field, is NOT in node_modules, and is listed as a dependency\n * of the project.\n */\nfunction isWorkspacePackage(filePath: string, projectRoot: string): boolean {\n if (isInNodeModules(filePath)) {\n return false;\n }\n\n const pkg = findPackageJson(filePath);\n if (!pkg) {\n return false;\n }\n\n // Check if the package.json is not the root package.json\n // Use resolve() to normalize paths for cross-platform comparison\n const rootPkgDir = resolve(projectRoot);\n const pkgDir = resolve(pkg.dir);\n\n // If the package directory is the project root, it's not a workspace package\n if (pkgDir === rootPkgDir) {\n return false;\n }\n\n // Found a package.json that's not the root.\n // Only treat it as a workspace package if it's actually a dependency\n // of the current project. This prevents sibling apps in a monorepo\n // from being incorrectly treated as importable packages.\n const projectDeps = getProjectDependencies(projectRoot);\n return projectDeps.has(pkg.name);\n}\n\n/**\n * Resolve the module specifier for a file.\n *\n * @param filePath - Absolute path to the file being transformed\n * @param projectRoot - Absolute path to the project root (usually process.cwd())\n * @returns The module specifier result\n *\n * @example\n * // File in node_modules (root export)\n * resolveModuleSpecifier('/project/node_modules/point/dist/index.js', '/project')\n * // => { moduleSpecifier: 'point@1.0.0' }\n *\n * @example\n * // File in node_modules (subpath export)\n * resolveModuleSpecifier('/project/node_modules/workflow/dist/internal/builtins.js', '/project')\n * // => { moduleSpecifier: 'workflow/internal/builtins@4.0.0' }\n *\n * @example\n * // File in workspace package\n * resolveModuleSpecifier('/project/packages/shared/src/utils.ts', '/project')\n * // => { moduleSpecifier: '@myorg/shared@0.0.0' }\n *\n * @example\n * // Local app file\n * resolveModuleSpecifier('/project/src/workflows/order.ts', '/project')\n * // => { moduleSpecifier: undefined }\n */\nexport function resolveModuleSpecifier(\n filePath: string,\n projectRoot: string\n): ModuleSpecifierResult {\n // Check if file is in node_modules or a workspace package\n const inNodeModules = isInNodeModules(filePath);\n const inWorkspace =\n !inNodeModules && isWorkspacePackage(filePath, projectRoot);\n\n if (!inNodeModules && !inWorkspace) {\n // Local app file - use default relative path format\n return { moduleSpecifier: undefined };\n }\n\n // Find the package.json for this file\n const pkg = findPackageJson(filePath);\n if (!pkg) {\n // Couldn't find package.json - fall back to default\n return { moduleSpecifier: undefined };\n }\n\n // Resolve the export subpath (e.g., \"/internal/builtins\" for \"workflow/internal/builtins\")\n const subpath = resolveExportSubpath(filePath, pkg);\n\n // Return the module specifier as \"name/subpath@version\" or \"name@version\"\n const specifier = subpath\n ? `${pkg.name}${subpath}@${pkg.version}`\n : `${pkg.name}@${pkg.version}`;\n\n return {\n moduleSpecifier: specifier,\n };\n}\n\n/**\n * Clear the package.json cache. Useful for testing or when package.json files may have changed.\n */\nexport function clearModuleSpecifierCache(): void {\n packageJsonCache.clear();\n projectDepsCache.clear();\n}\n\n/**\n * Convert a file path to a relative import path from project root.\n */\nfunction toRelativeImportPath(filePath: string, projectRoot: string): string {\n const normalizedProjectRoot = projectRoot.replace(/\\\\/g, '/');\n const normalizedFilePath = filePath.replace(/\\\\/g, '/');\n\n let relativePath: string;\n if (normalizedFilePath.startsWith(normalizedProjectRoot + '/')) {\n relativePath = normalizedFilePath.substring(\n normalizedProjectRoot.length + 1\n );\n } else {\n // File is outside project root, use the full path segments after common ancestor\n relativePath = relative(projectRoot, filePath).replace(/\\\\/g, '/');\n }\n\n // Ensure relative paths start with ./\n if (!relativePath.startsWith('.')) {\n relativePath = `./${relativePath}`;\n }\n\n return relativePath;\n}\n\n/**\n * Returns true when package exports include a root entry (\".\").\n * String/array/conditional object exports are all considered root exports.\n */\nfunction hasRootExport(exportsField: unknown): boolean {\n if (typeof exportsField === 'string' || Array.isArray(exportsField)) {\n return true;\n }\n\n if (!exportsField || typeof exportsField !== 'object') {\n return false;\n }\n\n const keys = Object.keys(exportsField as Record<string, unknown>);\n // Conditional exports object (e.g. { \"import\": \"...\", \"default\": \"...\" })\n // represents the root export.\n if (keys.length > 0 && keys.every((key) => !key.startsWith('.'))) {\n return true;\n }\n\n return '.' in (exportsField as Record<string, unknown>);\n}\n\n/**\n * Normalize a package target path to a comparable package-relative path.\n * Returns null for invalid/unsupported paths.\n */\nfunction normalizePackageTargetPath(path: string): string | null {\n const normalized = path.replace(/\\\\/g, '/');\n if (normalized.startsWith('./')) {\n return normalized.substring(2);\n }\n if (normalized.startsWith('/')) {\n return normalized.substring(1);\n }\n return normalized;\n}\n\n/**\n * Returns true if filePath is the package root entrypoint.\n * This checks root exports first, then main/module/index fallbacks when exports are absent.\n */\nfunction isRootEntrypointFile(filePath: string, pkg: PackageInfo): boolean {\n const normalizedFilePath = filePath.replace(/\\\\/g, '/');\n const normalizedPkgDir = pkg.dir.replace(/\\\\/g, '/');\n\n if (!normalizedFilePath.startsWith(normalizedPkgDir + '/')) {\n return false;\n }\n\n const relativeFilePath = normalizedFilePath.substring(\n normalizedPkgDir.length + 1\n );\n\n if (pkg.exports) {\n let rootTarget: unknown;\n\n if (\n typeof pkg.exports === 'object' &&\n !Array.isArray(pkg.exports) &&\n '.' in pkg.exports\n ) {\n rootTarget = (pkg.exports as Record<string, unknown>)['.'];\n } else if (hasRootExport(pkg.exports)) {\n rootTarget = pkg.exports;\n } else {\n return false;\n }\n\n const resolvedTarget = resolveExportTarget(rootTarget);\n if (!resolvedTarget) {\n return false;\n }\n\n const normalizedTarget = normalizePackageTargetPath(resolvedTarget);\n return normalizedTarget === relativeFilePath;\n }\n\n const rootCandidates = [\n pkg.module,\n pkg.main,\n 'index.js',\n 'index.mjs',\n 'index.cjs',\n 'index.ts',\n 'index.mts',\n 'index.cts',\n ]\n .filter((candidate): candidate is string => typeof candidate === 'string')\n .map((candidate) => normalizePackageTargetPath(candidate))\n .filter((candidate): candidate is string => candidate !== null);\n\n return rootCandidates.includes(relativeFilePath);\n}\n\n/**\n * Result of resolving an import path for a file.\n */\nexport interface ImportPathResult {\n /**\n * The import path to use.\n * - For workspace packages: the package name (e.g., \"@myorg/shared\")\n * - For node_modules packages: the package name\n * - For local files: a relative path (e.g., \"./src/workflows/order.ts\")\n */\n importPath: string;\n\n /**\n * Whether this file is from a package (workspace or node_modules).\n * When true, the import should go through package resolution which respects export conditions.\n */\n isPackage: boolean;\n}\n\n/**\n * Get the import path to use for a file in a bundle's virtual entry.\n *\n * For workspace packages and node_modules packages, returns the package name\n * so that bundler resolution will respect package.json exports and conditions.\n *\n * For local app files, returns a relative path.\n *\n * @param filePath - Absolute path to the file\n * @param projectRoot - Absolute path to the project root\n * @returns The import path and whether it's a package\n *\n * @example\n * // Workspace package\n * getImportPath('/project/packages/shared/src/index.ts', '/project')\n * // => { importPath: '@myorg/shared', isPackage: true }\n *\n * @example\n * // Local app file\n * getImportPath('/project/src/workflows/order.ts', '/project')\n * // => { importPath: './src/workflows/order.ts', isPackage: false }\n */\nexport function getImportPath(\n filePath: string,\n projectRoot: string\n): ImportPathResult {\n // Check if file is in node_modules or a workspace package\n const inNodeModules = isInNodeModules(filePath);\n const inWorkspace =\n !inNodeModules && isWorkspacePackage(filePath, projectRoot);\n\n if (inNodeModules || inWorkspace) {\n // Find the package.json for this file\n const pkg = findPackageJson(filePath);\n if (pkg) {\n const isDirectProjectDependency = getProjectDependencies(projectRoot).has(\n pkg.name\n );\n const canUsePackageSpecifier = inWorkspace || isDirectProjectDependency;\n\n // For transitive node_modules dependencies under strict package managers\n // (for example, pnpm), importing by package name can fail. Use a direct\n // file path import in those cases.\n if (!canUsePackageSpecifier) {\n return {\n importPath: toRelativeImportPath(filePath, projectRoot),\n isPackage: false,\n };\n }\n\n // Prefer a package subpath import when this file maps to an export.\n // This preserves the exact module being bundled while still respecting\n // package export conditions.\n // Note: resolveExportSubpath returns \"\" for both root \".\" matches and\n // no match; root entrypoints are intentionally handled below via\n // isRootEntrypointFile().\n const subpath = resolveExportSubpath(filePath, pkg);\n if (subpath) {\n return {\n importPath: `${pkg.name}${subpath}`,\n isPackage: true,\n };\n }\n\n // Only import package root when this file is the root entrypoint.\n // For deep/internal files, fall back to direct relative imports so we\n // don't accidentally import a non-existent or different module.\n if (!isRootEntrypointFile(filePath, pkg)) {\n return {\n importPath: toRelativeImportPath(filePath, projectRoot),\n isPackage: false,\n };\n }\n\n return {\n importPath: pkg.name,\n isPackage: true,\n };\n }\n }\n\n // Local app file - use relative path\n return {\n importPath: toRelativeImportPath(filePath, projectRoot),\n isPackage: false,\n };\n}\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"module-specifier.test.js","sourceRoot":"","sources":["../src/module-specifier.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AACxE,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AACjC,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,QAAQ,CAAC;AACrE,OAAO,EACL,yBAAyB,EACzB,aAAa,EACb,sBAAsB,GACvB,MAAM,uBAAuB,CAAC;AAE/B,SAAS,SAAS,CAAC,IAAY,EAAE,KAAc;IAC7C,SAAS,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;IAC9C,aAAa,CAAC,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC,EAAE,OAAO,CAAC,CAAC;AAC/D,CAAC;AAED,SAAS,SAAS,CAAC,IAAY,EAAE,QAAQ,GAAG,EAAE;IAC5C,SAAS,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;IAC9C,aAAa,CAAC,IAAI,EAAE,QAAQ,EAAE,OAA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S,CAAC,IAAI,CAAC,UAAU,EAAE,cAAc,CAAC,EAAE;YAC1C,IAAI,EAAE,MAAM;YACZ,OAAO,EAAE,OAAO;SACjB,CAAC,CAAC;QAEH,SAAS,CAAC,QAAQ,EAAE,mBAAmB,CAAC,CAAC;QAEzC,MAAM,CAAC,sBAAsB,CAAC,QAAQ,EAAE,WAAW,CAAC,CAAC,CAAC,OAAO,CAAC;YAC5D,eAAe,EAAE,YAAY;SAC9B,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","sourcesContent":["import { mkdirSync, mkdtempSync, rmSync, writeFileSync } from 'node:fs';\nimport { tmpdir } from 'node:os';\nimport { dirname, join } from 'node:path';\nimport { afterEach, beforeEach, describe, expect, it } from 'vitest';\nimport {\n clearModuleSpecifierCache,\n getImportPath,\n resolveModuleSpecifier,\n} from './module-specifier.js';\n\nfunction writeJson(path: string, value: unknown): void {\n mkdirSync(dirname(path), { recursive: true });\n writeFileSync(path, JSON.stringify(value, null, 2), 'utf-8');\n}\n\nfunction writeFile(path: string, contents = ''): void {\n mkdirSync(dirname(path), { recursive: true });\n writeFileSync(path, contents, 'utf-8');\n}\n\ndescribe('getImportPath', () => {\n let testRoot: string;\n\n beforeEach(() => {\n clearModuleSpecifierCache();\n testRoot = mkdtempSync(join(tmpdir(), 'workflow-module-specifier-'));\n });\n\n afterEach(() => {\n clearModuleSpecifierCache();\n rmSync(testRoot, { recursive: true, force: true });\n });\n\n it('uses package subpath import when file matches an export subpath', () => {\n const projectRoot = join(testRoot, 'apps/chat');\n const workspacePkgDir = join(testRoot, 'packages/agent');\n const filePath = join(workspacePkgDir, 'src/server.ts');\n\n writeJson(join(projectRoot, 'package.json'), {\n name: 'chat',\n dependencies: { '@internal/agent': 'workspace:*' },\n });\n\n writeJson(join(workspacePkgDir, 'package.json'), {\n name: '@internal/agent',\n version: '1.0.0',\n exports: {\n './server': './src/server.ts',\n },\n });\n\n writeFile(filePath, `'use step';\\n`);\n\n expect(getImportPath(filePath, projectRoot)).toEqual({\n importPath: '@internal/agent/server',\n isPackage: true,\n });\n });\n\n it('falls back to relative import when package has no root export', () => {\n const projectRoot = join(testRoot, 'apps/chat');\n const workspacePkgDir = join(testRoot, 'packages/agent');\n const filePath = join(workspacePkgDir, 'src/server.ts');\n\n writeJson(join(projectRoot, 'package.json'), {\n name: 'chat',\n dependencies: { '@internal/agent': 'workspace:*' },\n });\n\n writeJson(join(workspacePkgDir, 'package.json'), {\n name: '@internal/agent',\n version: '1.0.0',\n exports: {\n './server': './dist/server.js',\n },\n });\n\n writeFile(filePath, `'use step';\\n`);\n\n expect(getImportPath(filePath, projectRoot)).toEqual({\n importPath: '../../packages/agent/src/server.ts',\n isPackage: false,\n });\n });\n\n it('uses package root import for root exports', () => {\n const projectRoot = join(testRoot, 'apps/chat');\n const workspacePkgDir = join(testRoot, 'packages/agent');\n const filePath = join(workspacePkgDir, 'src/index.ts');\n\n writeJson(join(projectRoot, 'package.json'), {\n name: 'chat',\n dependencies: { '@internal/agent': 'workspace:*' },\n });\n\n writeJson(join(workspacePkgDir, 'package.json'), {\n name: '@internal/agent',\n version: '1.0.0',\n exports: {\n '.': './src/index.ts',\n },\n });\n\n writeFile(filePath, `'use workflow';\\n`);\n\n expect(getImportPath(filePath, projectRoot)).toEqual({\n importPath: '@internal/agent',\n isPackage: true,\n });\n });\n\n it('uses package root import when package module points to file', () => {\n const projectRoot = join(testRoot, 'apps/chat');\n const workspacePkgDir = join(testRoot, 'packages/agent');\n const filePath = join(workspacePkgDir, 'src/index.mjs');\n\n writeJson(join(projectRoot, 'package.json'), {\n name: 'chat',\n dependencies: { '@internal/agent': 'workspace:*' },\n });\n\n writeJson(join(workspacePkgDir, 'package.json'), {\n name: '@internal/agent',\n version: '1.0.0',\n module: './src/index.mjs',\n main: './dist/index.cjs',\n });\n\n writeFile(filePath, `'use workflow';\\n`);\n\n expect(getImportPath(filePath, projectRoot)).toEqual({\n importPath: '@internal/agent',\n isPackage: true,\n });\n });\n\n it('uses package root import for conditional root exports', () => {\n const projectRoot = join(testRoot, 'apps/chat');\n const workspacePkgDir = join(testRoot, 'packages/agent');\n const filePath = join(workspacePkgDir, 'src/index.js');\n\n writeJson(join(projectRoot, 'package.json'), {\n name: 'chat',\n dependencies: { '@internal/agent': 'workspace:*' },\n });\n\n writeJson(join(workspacePkgDir, 'package.json'), {\n name: '@internal/agent',\n version: '1.0.0',\n exports: {\n '.': {\n import: './src/index.mjs',\n default: './src/index.js',\n },\n },\n });\n\n writeFile(filePath, `'use workflow';\\n`);\n\n expect(getImportPath(filePath, projectRoot)).toEqual({\n importPath: '@internal/agent',\n isPackage: true,\n });\n });\n\n it('falls back to relative import for deep files in packages without exports', () => {\n const projectRoot = join(testRoot, 'apps/chat');\n const workspacePkgDir = join(testRoot, 'packages/agent');\n const filePath = join(workspacePkgDir, 'lib/tools/dynamic/workflow.ts');\n\n writeJson(join(projectRoot, 'package.json'), {\n name: 'chat',\n dependencies: { '@internal/agent': 'workspace:*' },\n });\n\n writeJson(join(workspacePkgDir, 'package.json'), {\n name: '@internal/agent',\n version: '1.0.0',\n });\n\n writeFile(filePath, `'use workflow';\\n`);\n\n expect(getImportPath(filePath, projectRoot)).toEqual({\n importPath: '../../packages/agent/lib/tools/dynamic/workflow.ts',\n isPackage: false,\n });\n });\n\n it('uses package root import when package main points to file', () => {\n const projectRoot = join(testRoot, 'apps/chat');\n const workspacePkgDir = join(testRoot, 'packages/agent');\n const filePath = join(workspacePkgDir, 'src/index.ts');\n\n writeJson(join(projectRoot, 'package.json'), {\n name: 'chat',\n dependencies: { '@internal/agent': 'workspace:*' },\n });\n\n writeJson(join(workspacePkgDir, 'package.json'), {\n name: '@internal/agent',\n version: '1.0.0',\n main: './src/index.ts',\n });\n\n writeFile(filePath, `'use step';\\n`);\n\n expect(getImportPath(filePath, projectRoot)).toEqual({\n importPath: '@internal/agent',\n isPackage: true,\n });\n });\n\n it('uses package subpath import for direct node_modules dependencies', () => {\n const projectRoot = join(testRoot, 'apps/chat');\n const packageDir = join(testRoot, 'apps/chat/node_modules/@workflow/core');\n const filePath = join(packageDir, 'dist/serialization.js');\n\n writeJson(join(projectRoot, 'package.json'), {\n name: 'chat',\n dependencies: { '@workflow/core': '1.0.0' },\n });\n\n writeJson(join(packageDir, 'package.json'), {\n name: '@workflow/core',\n version: '1.0.0',\n exports: {\n './serialization': './dist/serialization.js',\n },\n });\n\n writeFile(filePath, `'use workflow';\\n`);\n\n expect(getImportPath(filePath, projectRoot)).toEqual({\n importPath: '@workflow/core/serialization',\n isPackage: true,\n });\n });\n\n it('falls back to relative import for transitive node_modules dependencies', () => {\n const projectRoot = join(testRoot, 'apps/chat');\n const packageDir = join(testRoot, 'apps/chat/node_modules/@workflow/core');\n const filePath = join(packageDir, 'dist/serialization.js');\n\n writeJson(join(projectRoot, 'package.json'), {\n name: 'chat',\n dependencies: { workflow: '1.0.0' },\n });\n\n writeJson(join(packageDir, 'package.json'), {\n name: '@workflow/core',\n version: '1.0.0',\n exports: {\n './serialization': './dist/serialization.js',\n },\n });\n\n writeFile(filePath, `'use workflow';\\n`);\n\n expect(getImportPath(filePath, projectRoot)).toEqual({\n importPath: './node_modules/@workflow/core/dist/serialization.js',\n isPackage: false,\n });\n });\n\n it('treats a workspace package file as local when projectRoot is the package itself', () => {\n const projectRoot = join(testRoot, 'packages/vade');\n const filePath = join(\n projectRoot,\n 'src/internal/message/workflow/handle-message.ts'\n );\n\n writeJson(join(projectRoot, 'package.json'), {\n name: 'vade',\n version: '0.0.0',\n });\n\n writeFile(filePath, `'use workflow';\\n`);\n\n expect(resolveModuleSpecifier(filePath, projectRoot)).toEqual({\n moduleSpecifier: undefined,\n });\n });\n\n it('uses the consuming app root to resolve workspace package workflow ids', () => {\n const projectRoot = join(testRoot, 'apps/chat');\n const packageDir = join(testRoot, 'packages/vade');\n const filePath = join(\n packageDir,\n 'src/internal/message/workflow/handle-message.ts'\n );\n\n writeJson(join(projectRoot, 'package.json'), {\n name: 'chat',\n dependencies: { vade: 'workspace:*' },\n });\n\n writeJson(join(packageDir, 'package.json'), {\n name: 'vade',\n version: '0.0.0',\n });\n\n writeFile(filePath, `'use workflow';\\n`);\n\n expect(resolveModuleSpecifier(filePath, projectRoot)).toEqual({\n moduleSpecifier: 'vade@0.0.0',\n });\n });\n});\n"]}
@@ -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,CAAC;AAE3D,6CAA6C;AAC7C,8CAA8C;AAC9C,oDAAoD;AACpD,+DAA+D;AAC/D,MAAM,kBAAkB,GAAG,IAAI,cAAc,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC;AAE3D,qBAAqB;AACrB,wBAAwB;AACxB,oDAAoD;AACpD,MAAM,eAAe,GAAG,WAAW,CAAC;AAEpC,kDAAkD;AAClD,MAAM,mBAAmB,GAAG,IAAI,MAAM,CACpC,aAAa,kBAAkB,cAAc,CAC9C,CAAC;AASF;;;;GAIG;AACH,MAAM,UAAU,cAAc,CAAC,QAAgB;IAC7C,MAAM,UAAU,GAAG,QAAQ,CAAC,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC;IAChD,MAAM,MAAM,GAAG,gBAAgB,CAAC;IAChC,MAAM,GAAG,GAAG,UAAU,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC;IAC3C,IAAI,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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://workflow-sdk.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://workflow-sdk.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,C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AAC,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,IAAI,EAAE,MAAM,WAAW,CAAC;AAEjC,OAAO,KAAK,OAAO,MAAM,SAAS,CAAC;AACnC,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,QAAQ,CAAC;AAC9C,OAAO,EACL,yBAAyB,EACzB,eAAe,GAChB,MAAM,oCAAoC,CAAC;AAE5C,wEAAwE;AACxE,MAAM,UAAU,GAAG,YAAY,CAAC,MAAM,EAAE,CAAC,CAAC;AAE1C,KAAK,UAAU,eAAe,CAC5B,MAAc,EACd,UAA4B,CAAC,yBAAyB,EAAE,CAAC;IAEzD,MAAM,OAAO,GAAG,WAAW,CAAC,IAAI,CAAC,UAAU,EAAE,6BAA6B,CAAC,CAAC,CAAC;IAC7E,MAAM,SAAS,GAAG,IAAI,CAAC,OAAO,EAAE,aAAa,CAAC,CAAC;IAC/C,aAAa,CAAC,SAAS,EAAE,MAAM,CAAC,CA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F,MAAM,SAAS,GAAG,IAAI,CAAC,OAAO,EAAE,aAAa,CAAC,CAAC;QAC/C,aAAa,CAAC,SAAS,EAAE,QAAQ,CAAC,CAAC;QAEnC,IAAI,CAAC;YACH,MAAM,MAAM,GAAG,MAAM,OAAO,CAAC,KAAK,CAAC;gBACjC,WAAW,EAAE,CAAC,SAAS,CAAC;gBACxB,MAAM,EAAE,IAAI;gBACZ,KAAK,EAAE,KAAK;gBACZ,QAAQ,EAAE,SAAS;gBACnB,MAAM,EAAE,KAAK;gBACb,QAAQ,EAAE,QAAQ;gBAClB,6CAA6C;aAC9C,CAAC,CAAC;YAEH,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC;YACtC,MAAM,MAAM,GAAG,MAAM,CAAC,WAAW,EAAE,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;YAC5C,MAAM,CAAC,MAAM,CAAC,CAAC,WAAW,EAAE,CAAC;YAE7B,0DAA0D;YAC1D,MAAM,CAAC,MAAM,CAAC,CAAC,SAAS,CAAC,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,OAAO,EAAE,sBAAsB,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\nexport { NORMALIZE_REQUEST_CODE };\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"serde-checker.js","sourceRoot":"","sources":["../src/serde-checker.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,cAAc,MAAM,iBAAiB,CAAC;AAG7C,kFAAkF;AAClF,6EAA6E;AAC7E,MAAM,YA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G,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,aAAa,GAAG,MAAM,IAAI,CAAC,gBAAgB,CAAC,OAAO,CAAC,CAAC;QAC3D,MAAM,iBAAiB,GAAG,MAAM,IAAI,CAAC,oBAAoB,CAAC,OAAO,CAAC,CAAC;QACnE,MAAM,IAAI,CAAC,oBAAoB,EAAE,CAAC;QA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C;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,gCAAgC,EAAE,MAAM,qBAAqB,CAAC;AAgCvE,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;IACd,UAAU,EAAE,CAAC,MAAM,CAAC;IACpB,SAAS,EAAE,CAAC,OAAO,CAAC;IACpB,KAAK,EAAE,EAAE;IACT,cAAc,EAAE,KAAK;IACrB,cAAc,EAAE,KAAK;IACrB,cAAc,EAAE,KAAK;IACrB,YAAY,EAAE,EAAE;CACjB,CAAC;AAEF,MAAM,wBAAwB,GAAG;IAC/B,GAAG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,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","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 { resolveWorkflowAliasRelativePath } from './workflow-alias.js';\n\nexport interface SwcPluginOptions {\n mode: 'step' | 'workflow';\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 * 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\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 = resolvedPath.replace(/\\\\/g, '/');\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\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 // When the resolved file lives inside node_modules, let\n // esbuild bundle it rather than externalizing with a deeply\n // nested relative path. Downstream bundlers (Rollup/Vite)\n // can't rewrite opaque `__require()` calls in CJS shims, so\n // relative paths computed for `outdir` break once the output\n // is rebundled to a different directory.\n if (normalizedResolvedPath.includes('/node_modules/')) {\n return null; // let esbuild bundle it\n }\n\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"]}
@@ -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,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAE1D,MAAM,UAAU,GAAG,YAAY,CAAC,MAAM,EAAE,CAAC,CAAC;AAE1C,SAAS,SAAS,CAAC,IAAY,EAAE,QAAQ,GAAG,EAAE;IAC5C,SAAS,CAAC,OAAO,CAA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C,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 { 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 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 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\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;A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AO,QAAQ,CAAC,YAAY,IAAI,QAAQ,CAAC,QAAQ,CAAC;AACpD,CAAC;AAED;;;;;GAKG;AACH,MAAM,CAAC,MAAM,uBAAuB,GAClC,yKAAyK,CAAC","sourcesContent":["/**\n * Shared utilities for detecting files that need 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/**\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 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 always transformed; the SWC plugin performs\n * AST-level extraction/filtering to determine whether they actually define\n * serde classes\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 return patterns.hasDirective || patterns.hasSerde;\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"]}