@@ -33,19 +33,9 @@ export async function compile(options: CompileOptions) {
33
33
} = options ;
34
34
const configPath =
35
35
options . resolvedConfig . status === "file" ? options . resolvedConfig . path : undefined ;
36
-
37
- // COPIED FROM compileProject()
38
- // const compileSpinner = spinner();
39
- // compileSpinner.start(`Building project in ${config.projectDir}`);
40
-
41
36
const taskFiles = await gatherTaskFiles ( config ) ;
42
- const workerFacade = readFileSync (
43
- resolve ( "./dist/workers/prod/worker-facade.js" ) ,
44
- // join(cliRootPath(), "workers", "prod", "worker-facade.js"),
45
- "utf-8"
46
- ) ;
37
+ const workerFacade = readFileSync ( resolve ( "./dist/workers/prod/worker-facade.js" ) , "utf-8" ) ;
47
38
48
- // const workerSetupPath = join(cliRootPath(), "workers", "prod", "worker-setup.js");
49
39
const workerSetupPath = resolve ( "./dist/workers/prod/worker-setup.js" ) ;
50
40
51
41
let workerContents = workerFacade
@@ -74,7 +64,6 @@ export async function compile(options: CompileOptions) {
74
64
const result = await build ( {
75
65
stdin : {
76
66
contents : workerContents ,
77
- // resolveDir: process.cwd(),
78
67
resolveDir : config . projectDir ,
79
68
sourcefile : "__entryPoint.ts" ,
80
69
} ,
@@ -87,11 +76,7 @@ export async function compile(options: CompileOptions) {
87
76
platform : "node" ,
88
77
format : "cjs" , // This is needed to support opentelemetry instrumentation that uses module patching
89
78
target : [ "node18" , "es2020" ] ,
90
- // outdir: "out",
91
79
outdir : resolve ( config . projectDir , "out" ) ,
92
- // banner: {
93
- // js: `process.on("uncaughtException", function(error, origin) { if (error instanceof Error) { process.send && process.send({ type: "EVENT", message: { type: "UNCAUGHT_EXCEPTION", payload: { error: { name: error.name, message: error.message, stack: error.stack }, origin }, version: "v1" } }); } else { process.send && process.send({ type: "EVENT", message: { type: "UNCAUGHT_EXCEPTION", payload: { error: { name: "Error", message: typeof error === "string" ? error : JSON.stringify(error) }, origin }, version: "v1" } }); } });`,
94
- // },
95
80
footer : {
96
81
js : "process.exit();" ,
97
82
} ,
@@ -112,31 +97,18 @@ export async function compile(options: CompileOptions) {
112
97
} ) ;
113
98
114
99
if ( result . errors . length > 0 ) {
115
- // compileSpinner.stop("Build failed, aborting deployment");
116
-
117
- // span.setAttributes({
118
- // "build.workerErrors": result.errors.map(
119
- // (error) => `Error: ${error.text} at ${error.location?.file}`
120
- // ),
121
- // });
122
-
123
100
throw new Error ( "Build failed, aborting deployment" ) ;
124
101
}
125
102
126
103
if ( options . outputMetafile ) {
127
104
await writeJSONFile ( join ( options . outputMetafile , "worker.json" ) , result . metafile ) ;
128
105
}
129
106
130
- const entryPointContents = readFileSync (
131
- resolve ( "./dist/workers/prod/entry-point.js" ) ,
132
- // join(cliRootPath(), "workers", "prod", "entry-point.js"),
133
- "utf-8"
134
- ) ;
107
+ const entryPointContents = readFileSync ( resolve ( "./dist/workers/prod/entry-point.js" ) , "utf-8" ) ;
135
108
136
109
const entryPointResult = await build ( {
137
110
stdin : {
138
111
contents : entryPointContents ,
139
- // resolveDir: process.cwd(),
140
112
resolveDir : config . projectDir ,
141
113
sourcefile : "index.ts" ,
142
114
} ,
@@ -150,7 +122,6 @@ export async function compile(options: CompileOptions) {
150
122
packages : "external" ,
151
123
format : "cjs" , // This is needed to support opentelemetry instrumentation that uses module patching
152
124
target : [ "node18" , "es2020" ] ,
153
- // outdir: "out",
154
125
outdir : resolve ( config . projectDir , "out" ) ,
155
126
define : {
156
127
__PROJECT_CONFIG__ : JSON . stringify ( config ) ,
@@ -161,14 +132,6 @@ export async function compile(options: CompileOptions) {
161
132
} ) ;
162
133
163
134
if ( entryPointResult . errors . length > 0 ) {
164
- // compileSpinner.stop("Build failed, aborting deployment");
165
-
166
- // span.setAttributes({
167
- // "build.entryPointErrors": entryPointResult.errors.map(
168
- // (error) => `Error: ${error.text} at ${error.location?.file}`
169
- // ),
170
- // });
171
-
172
135
throw new Error ( "Build failed, aborting deployment" ) ;
173
136
}
174
137
@@ -179,13 +142,9 @@ export async function compile(options: CompileOptions) {
179
142
) ;
180
143
}
181
144
182
- // Create a tmp directory to store the build
183
- // const tempDir = await createTempDir();
184
-
185
145
logger . debug ( `Writing compiled files to ${ tempDir } ` ) ;
186
146
187
147
// Get the metaOutput for the result build
188
- // const metaOutput = result.metafile!.outputs[posix.join("out", "stdin.js")];
189
148
const metaOutput =
190
149
result . metafile ! . outputs [
191
150
posix . join ( "e2e" , "fixtures" , basename ( config . projectDir ) , "out" , "stdin.js" )
@@ -194,8 +153,6 @@ export async function compile(options: CompileOptions) {
194
153
invariant ( metaOutput , "Meta output for the result build is missing" ) ;
195
154
196
155
// Get the metaOutput for the entryPoint build
197
- // const entryPointMetaOutput =
198
- // entryPointResult.metafile!.outputs[posix.join("out", "stdin.js")];
199
156
const entryPointMetaOutput =
200
157
entryPointResult . metafile ! . outputs [
201
158
posix . join ( "e2e" , "fixtures" , basename ( config . projectDir ) , "out" , "stdin.js" )
0 commit comments