@@ -2,7 +2,7 @@ import { esbuildDecorators } from "@anatine/esbuild-decorators";
22import { build } from "esbuild" ;
33import { readFileSync } from "node:fs" ;
44import { writeFile } from "node:fs/promises" ;
5- import { basename , join , posix , resolve } from "node:path" ;
5+ import { basename , join , posix , relative , resolve , sep } from "node:path" ;
66import invariant from "tiny-invariant" ;
77
88import {
@@ -15,9 +15,12 @@ import { writeJSONFile } from "../src/utilities/fileSystem.js";
1515import { logger } from "../src/utilities/logger.js" ;
1616import { createTaskFileImports , gatherTaskFiles } from "../src/utilities/taskFiles.js" ;
1717import { escapeImportPath } from "../src/utilities/windows.js" ;
18+ import { E2EJavascriptProject } from "./javascriptProject.js" ;
19+ import { PackageManager } from "../src/utilities/getUserPackageManager.js" ;
1820
1921type CompileOptions = {
2022 outputMetafile ?: string ;
23+ packageManager : PackageManager ;
2124 resolvedConfig : ReadConfigResult ;
2225 tempDir : string ;
2326} ;
@@ -28,6 +31,7 @@ export async function compile(options: CompileOptions) {
2831 }
2932
3033 const {
34+ packageManager,
3135 tempDir,
3236 resolvedConfig : { config } ,
3337 } = options ;
@@ -61,6 +65,9 @@ export async function compile(options: CompileOptions) {
6165 ) ;
6266 }
6367
68+ const e2eJsProject = new E2EJavascriptProject ( config . projectDir , packageManager ) ;
69+ const directDependenciesMeta = await e2eJsProject . extractDirectDependenciesMeta ( ) ;
70+
6471 const result = await build ( {
6572 stdin : {
6673 contents : workerContents ,
@@ -86,7 +93,12 @@ export async function compile(options: CompileOptions) {
8693 } ,
8794 plugins : [
8895 mockServerOnlyPlugin ( ) ,
89- bundleDependenciesPlugin ( "workerFacade" , config . dependenciesToBundle , config . tsconfigPath ) ,
96+ bundleDependenciesPlugin (
97+ "workerFacade" ,
98+ directDependenciesMeta ,
99+ config . dependenciesToBundle ,
100+ config . tsconfigPath
101+ ) ,
90102 workerSetupImportConfigPlugin ( configPath ) ,
91103 esbuildDecorators ( {
92104 tsconfig : config . tsconfigPath ,
@@ -127,7 +139,12 @@ export async function compile(options: CompileOptions) {
127139 __PROJECT_CONFIG__ : JSON . stringify ( config ) ,
128140 } ,
129141 plugins : [
130- bundleDependenciesPlugin ( "entryPoint.ts" , config . dependenciesToBundle , config . tsconfigPath ) ,
142+ bundleDependenciesPlugin (
143+ "entryPoint.ts" ,
144+ directDependenciesMeta ,
145+ config . dependenciesToBundle ,
146+ config . tsconfigPath
147+ ) ,
131148 ] ,
132149 } ) ;
133150
@@ -145,17 +162,22 @@ export async function compile(options: CompileOptions) {
145162 logger . debug ( `Writing compiled files to ${ tempDir } ` ) ;
146163
147164 // Get the metaOutput for the result build
165+ const pathsToProjectDir = relative (
166+ join ( process . cwd ( ) , "e2e" , "fixtures" ) ,
167+ config . projectDir
168+ ) . split ( sep ) ;
169+
148170 const metaOutput =
149171 result . metafile ! . outputs [
150- posix . join ( "e2e" , "fixtures" , basename ( config . projectDir ) , "out" , "stdin.js" )
172+ posix . join ( "e2e" , "fixtures" , ... pathsToProjectDir , "out" , "stdin.js" )
151173 ] ;
152174
153175 invariant ( metaOutput , "Meta output for the result build is missing" ) ;
154176
155177 // Get the metaOutput for the entryPoint build
156178 const entryPointMetaOutput =
157179 entryPointResult . metafile ! . outputs [
158- posix . join ( "e2e" , "fixtures" , basename ( config . projectDir ) , "out" , "stdin.js" )
180+ posix . join ( "e2e" , "fixtures" , ... pathsToProjectDir , "out" , "stdin.js" )
159181 ] ;
160182
161183 invariant ( entryPointMetaOutput , "Meta output for the entryPoint build is missing" ) ;
0 commit comments