You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
it('converts known user-code Vite errors to AbortError',()=>{
20
+
consterror=newError(
21
+
'Failed to parse source for import analysis because the content contains invalid JS syntax. If you are using JSX, make sure to name the file with the .jsx or .tsx extension.',
staticdescriptionWithMarkdown=`Builds a Hydrogen storefront for production. The client and app worker files are compiled to a \`/dist\` folder in your Hydrogen project directory.`;
39
53
@@ -168,111 +182,119 @@ export async function runBuild({
168
182
letclientBuildStatus: DeferredPromise;
169
183
170
184
// Client build first
171
-
constclientBuild=awaitvite.build({
172
-
...commonConfig,
173
-
build: {
174
-
emptyOutDir: true,
175
-
copyPublicDir: true,
176
-
// Disable client sourcemaps in production by default
177
-
sourcemap:
178
-
forceClientSourcemap??
179
-
(process.env.NODE_ENV!=='production'&&sourcemap),
180
-
watch: watch ? {} : null,
181
-
},
182
-
server: {
183
-
watch: watch ? {} : null,
184
-
},
185
-
plugins: [
186
-
{
187
-
name: 'hydrogen:cli:client',
188
-
buildStart(){
189
-
clientBuildStatus?.resolve();
190
-
clientBuildStatus=deferPromise();
191
-
},
192
-
buildEnd(error){
193
-
if(error)clientBuildStatus.reject(error);
194
-
},
195
-
writeBundle(){
196
-
clientBuildStatus.resolve();
197
-
},
198
-
closeWatcher(){
199
-
// End build process if watcher is closed
200
-
this.error(newError('Process exited before client build finished.'));
201
-
},
185
+
constclientBuild=awaitvite
186
+
.build({
187
+
...commonConfig,
188
+
build: {
189
+
emptyOutDir: true,
190
+
copyPublicDir: true,
191
+
// Disable client sourcemaps in production by default
192
+
sourcemap:
193
+
forceClientSourcemap??
194
+
(process.env.NODE_ENV!=='production'&&sourcemap),
195
+
watch: watch ? {} : null,
196
+
},
197
+
server: {
198
+
watch: watch ? {} : null,
202
199
},
203
-
],
204
-
});
200
+
plugins: [
201
+
{
202
+
name: 'hydrogen:cli:client',
203
+
buildStart(){
204
+
clientBuildStatus?.resolve();
205
+
clientBuildStatus=deferPromise();
206
+
},
207
+
buildEnd(error){
208
+
if(error)clientBuildStatus.reject(error);
209
+
},
210
+
writeBundle(){
211
+
clientBuildStatus.resolve();
212
+
},
213
+
closeWatcher(){
214
+
// End build process if watcher is closed
215
+
this.error(
216
+
newError('Process exited before client build finished.'),
217
+
);
218
+
},
219
+
},
220
+
],
221
+
})
222
+
.catch(rethrowAsUserError);
205
223
206
224
console.log('');
207
225
208
226
letserverBuildStatus: DeferredPromise;
209
227
210
228
// Server/SSR build
211
-
constserverBuild=awaitvite.build({
212
-
...commonConfig,
213
-
build: {
214
-
sourcemap,
215
-
ssr: ssrEntry??true,
216
-
emptyOutDir: false,
217
-
copyPublicDir: false,
218
-
minify: serverMinify,
219
-
// Ensure the server rebuild start after the client one
220
-
watch: watch ? {buildDelay: 100} : null,
221
-
},
222
-
server: {
223
-
watch: watch ? {} : null,
224
-
},
225
-
plugins: [
226
-
{
227
-
name: 'hydrogen:cli:server',
228
-
asyncbuildStart(){
229
-
// Wait for the client build to finish in watch mode
230
-
// before starting the server build to access the
231
-
// Remix manifest from file disk.
232
-
awaitclientBuildStatus.promise;
233
-
234
-
// Keep track of server builds to wait for them to finish
235
-
// before cleaning up resources in watch mode. Otherwise,
236
-
// it might complain about missing files and loop infinitely.
237
-
serverBuildStatus?.resolve();
238
-
serverBuildStatus=deferPromise();
239
-
awaitonServerBuildStart?.();
240
-
},
241
-
asyncwriteBundle(){
242
-
if(serverBuildStatus?.state!=='rejected'){
243
-
awaitonServerBuildFinish?.();
244
-
}
245
-
246
-
serverBuildStatus.resolve();
247
-
},
248
-
closeWatcher(){
249
-
// End build process if watcher is closed
250
-
this.error(newError('Process exited before server build finished.'));
251
-
},
229
+
constserverBuild=awaitvite
230
+
.build({
231
+
...commonConfig,
232
+
build: {
233
+
sourcemap,
234
+
ssr: ssrEntry??true,
235
+
emptyOutDir: false,
236
+
copyPublicDir: false,
237
+
minify: serverMinify,
238
+
// Ensure the server rebuild start after the client one
239
+
watch: watch ? {buildDelay: 100} : null,
252
240
},
253
-
...(bundleStats
254
-
? [
255
-
hydrogenBundleAnalyzer({
256
-
minify: serverMinify
257
-
? (code,filepath)=>
258
-
vite
259
-
.transformWithEsbuild(code,filepath,{
260
-
minify: true,
261
-
minifyWhitespace: true,
262
-
minifySyntax: true,
263
-
minifyIdentifiers: true,
264
-
sourcemap: false,
265
-
treeShaking: false,// Tree-shaking would drop most exports in routes
266
-
legalComments: 'none',
267
-
target: 'esnext',
268
-
})
269
-
.then((result)=>result.code)
270
-
: undefined,
271
-
}),
272
-
]
273
-
: []),
274
-
],
275
-
});
241
+
server: {
242
+
watch: watch ? {} : null,
243
+
},
244
+
plugins: [
245
+
{
246
+
name: 'hydrogen:cli:server',
247
+
asyncbuildStart(){
248
+
// Wait for the client build to finish in watch mode
249
+
// before starting the server build to access the
250
+
// Remix manifest from file disk.
251
+
awaitclientBuildStatus.promise;
252
+
253
+
// Keep track of server builds to wait for them to finish
254
+
// before cleaning up resources in watch mode. Otherwise,
255
+
// it might complain about missing files and loop infinitely.
256
+
serverBuildStatus?.resolve();
257
+
serverBuildStatus=deferPromise();
258
+
awaitonServerBuildStart?.();
259
+
},
260
+
asyncwriteBundle(){
261
+
if(serverBuildStatus?.state!=='rejected'){
262
+
awaitonServerBuildFinish?.();
263
+
}
264
+
265
+
serverBuildStatus.resolve();
266
+
},
267
+
closeWatcher(){
268
+
// End build process if watcher is closed
269
+
this.error(
270
+
newError('Process exited before server build finished.'),
271
+
);
272
+
},
273
+
},
274
+
...(bundleStats
275
+
? [
276
+
hydrogenBundleAnalyzer({
277
+
minify: serverMinify
278
+
? (code,filepath)=>
279
+
vite
280
+
.transformWithEsbuild(code,filepath,{
281
+
minify: true,
282
+
minifyWhitespace: true,
283
+
minifySyntax: true,
284
+
minifyIdentifiers: true,
285
+
sourcemap: false,
286
+
treeShaking: false,// Tree-shaking would drop most exports in routes
0 commit comments