@@ -2,7 +2,7 @@ import { esbuildDecorators } from "@anatine/esbuild-decorators";
2
2
import { build } from "esbuild" ;
3
3
import { readFileSync } from "node:fs" ;
4
4
import { 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" ;
6
6
import invariant from "tiny-invariant" ;
7
7
8
8
import {
@@ -15,9 +15,12 @@ import { writeJSONFile } from "../src/utilities/fileSystem.js";
15
15
import { logger } from "../src/utilities/logger.js" ;
16
16
import { createTaskFileImports , gatherTaskFiles } from "../src/utilities/taskFiles.js" ;
17
17
import { escapeImportPath } from "../src/utilities/windows.js" ;
18
+ import { E2EJavascriptProject } from "./javascriptProject.js" ;
19
+ import { PackageManager } from "../src/utilities/getUserPackageManager.js" ;
18
20
19
21
type CompileOptions = {
20
22
outputMetafile ?: string ;
23
+ packageManager : PackageManager ;
21
24
resolvedConfig : ReadConfigResult ;
22
25
tempDir : string ;
23
26
} ;
@@ -28,6 +31,7 @@ export async function compile(options: CompileOptions) {
28
31
}
29
32
30
33
const {
34
+ packageManager,
31
35
tempDir,
32
36
resolvedConfig : { config } ,
33
37
} = options ;
@@ -61,6 +65,9 @@ export async function compile(options: CompileOptions) {
61
65
) ;
62
66
}
63
67
68
+ const e2eJsProject = new E2EJavascriptProject ( config . projectDir , packageManager ) ;
69
+ const directDependenciesMeta = await e2eJsProject . extractDirectDependenciesMeta ( ) ;
70
+
64
71
const result = await build ( {
65
72
stdin : {
66
73
contents : workerContents ,
@@ -86,7 +93,12 @@ export async function compile(options: CompileOptions) {
86
93
} ,
87
94
plugins : [
88
95
mockServerOnlyPlugin ( ) ,
89
- bundleDependenciesPlugin ( "workerFacade" , config . dependenciesToBundle , config . tsconfigPath ) ,
96
+ bundleDependenciesPlugin (
97
+ "workerFacade" ,
98
+ directDependenciesMeta ,
99
+ config . dependenciesToBundle ,
100
+ config . tsconfigPath
101
+ ) ,
90
102
workerSetupImportConfigPlugin ( configPath ) ,
91
103
esbuildDecorators ( {
92
104
tsconfig : config . tsconfigPath ,
@@ -127,7 +139,12 @@ export async function compile(options: CompileOptions) {
127
139
__PROJECT_CONFIG__ : JSON . stringify ( config ) ,
128
140
} ,
129
141
plugins : [
130
- bundleDependenciesPlugin ( "entryPoint.ts" , config . dependenciesToBundle , config . tsconfigPath ) ,
142
+ bundleDependenciesPlugin (
143
+ "entryPoint.ts" ,
144
+ directDependenciesMeta ,
145
+ config . dependenciesToBundle ,
146
+ config . tsconfigPath
147
+ ) ,
131
148
] ,
132
149
} ) ;
133
150
@@ -145,17 +162,22 @@ export async function compile(options: CompileOptions) {
145
162
logger . debug ( `Writing compiled files to ${ tempDir } ` ) ;
146
163
147
164
// Get the metaOutput for the result build
165
+ const pathsToProjectDir = relative (
166
+ join ( process . cwd ( ) , "e2e" , "fixtures" ) ,
167
+ config . projectDir
168
+ ) . split ( sep ) ;
169
+
148
170
const metaOutput =
149
171
result . metafile ! . outputs [
150
- posix . join ( "e2e" , "fixtures" , basename ( config . projectDir ) , "out" , "stdin.js" )
172
+ posix . join ( "e2e" , "fixtures" , ... pathsToProjectDir , "out" , "stdin.js" )
151
173
] ;
152
174
153
175
invariant ( metaOutput , "Meta output for the result build is missing" ) ;
154
176
155
177
// Get the metaOutput for the entryPoint build
156
178
const entryPointMetaOutput =
157
179
entryPointResult . metafile ! . outputs [
158
- posix . join ( "e2e" , "fixtures" , basename ( config . projectDir ) , "out" , "stdin.js" )
180
+ posix . join ( "e2e" , "fixtures" , ... pathsToProjectDir , "out" , "stdin.js" )
159
181
] ;
160
182
161
183
invariant ( entryPointMetaOutput , "Meta output for the entryPoint build is missing" ) ;
0 commit comments