From 7cdb7a65819342c6d334c79defc697d531d5cbf4 Mon Sep 17 00:00:00 2001 From: Braden Wiggins <55504972+FractalHQ@users.noreply.github.com> Date: Thu, 2 Feb 2023 11:11:37 -0500 Subject: [PATCH] fix: add optional chaining back to `finalise` hook (#8846) * fix: add optional chaining back to `finalise` hook * add a test * remove check task * Update .changeset/grumpy-islands-collect.md --------- Co-authored-by: Rich Harris --- .changeset/grumpy-islands-collect.md | 5 ++++ packages/kit/src/exports/vite/index.js | 2 +- .../build-errors/apps/syntax-error/.gitignore | 7 ++++++ .../build-errors/apps/syntax-error/.npmrc | 1 + .../apps/syntax-error/package.json | 18 ++++++++++++++ .../apps/syntax-error/src/app.html | 12 +++++++++ .../apps/syntax-error/src/lib/test.server.js | 1 + .../apps/syntax-error/src/routes/+page.svelte | 1 + .../apps/syntax-error/static/favicon.png | Bin 0 -> 1571 bytes .../apps/syntax-error/svelte.config.js | 4 +++ .../apps/syntax-error/tsconfig.json | 19 +++++++++++++++ .../apps/syntax-error/vite.config.js | 14 +++++++++++ .../kit/test/build-errors/syntax-error.js | 23 ++++++++++++++++++ pnpm-lock.yaml | 14 +++++++++++ 14 files changed, 120 insertions(+), 1 deletion(-) create mode 100644 .changeset/grumpy-islands-collect.md create mode 100644 packages/kit/test/build-errors/apps/syntax-error/.gitignore create mode 100644 packages/kit/test/build-errors/apps/syntax-error/.npmrc create mode 100644 packages/kit/test/build-errors/apps/syntax-error/package.json create mode 100644 packages/kit/test/build-errors/apps/syntax-error/src/app.html create mode 100644 packages/kit/test/build-errors/apps/syntax-error/src/lib/test.server.js create mode 100644 packages/kit/test/build-errors/apps/syntax-error/src/routes/+page.svelte create mode 100644 packages/kit/test/build-errors/apps/syntax-error/static/favicon.png create mode 100644 packages/kit/test/build-errors/apps/syntax-error/svelte.config.js create mode 100644 packages/kit/test/build-errors/apps/syntax-error/tsconfig.json create mode 100644 packages/kit/test/build-errors/apps/syntax-error/vite.config.js create mode 100644 packages/kit/test/build-errors/syntax-error.js diff --git a/.changeset/grumpy-islands-collect.md b/.changeset/grumpy-islands-collect.md new file mode 100644 index 000000000000..25e3ab4c7740 --- /dev/null +++ b/.changeset/grumpy-islands-collect.md @@ -0,0 +1,5 @@ +--- +'@sveltejs/kit': patch +--- + +fix: preserve build error messages diff --git a/packages/kit/src/exports/vite/index.js b/packages/kit/src/exports/vite/index.js index 57fd9dd7dd03..6d7a639c0d2b 100644 --- a/packages/kit/src/exports/vite/index.js +++ b/packages/kit/src/exports/vite/index.js @@ -725,7 +725,7 @@ function kit({ svelte_config }) { sequential: true, async handler() { if (!vite_config.build.ssr) return; - await finalise(); + await finalise?.(); } } }; diff --git a/packages/kit/test/build-errors/apps/syntax-error/.gitignore b/packages/kit/test/build-errors/apps/syntax-error/.gitignore new file mode 100644 index 000000000000..cbee71f70e92 --- /dev/null +++ b/packages/kit/test/build-errors/apps/syntax-error/.gitignore @@ -0,0 +1,7 @@ +.DS_Store +node_modules +/build +/.svelte-kit +/package +.env.* +!.env.example diff --git a/packages/kit/test/build-errors/apps/syntax-error/.npmrc b/packages/kit/test/build-errors/apps/syntax-error/.npmrc new file mode 100644 index 000000000000..b6f27f135954 --- /dev/null +++ b/packages/kit/test/build-errors/apps/syntax-error/.npmrc @@ -0,0 +1 @@ +engine-strict=true diff --git a/packages/kit/test/build-errors/apps/syntax-error/package.json b/packages/kit/test/build-errors/apps/syntax-error/package.json new file mode 100644 index 000000000000..0d57ac6c90b6 --- /dev/null +++ b/packages/kit/test/build-errors/apps/syntax-error/package.json @@ -0,0 +1,18 @@ +{ + "name": "syntax-error", + "version": "0.0.1", + "private": true, + "scripts": { + "dev": "vite dev", + "build": "vite build", + "preview": "vite preview" + }, + "devDependencies": { + "@sveltejs/kit": "workspace:^", + "svelte": "^3.55.1", + "svelte-check": "^3.0.2", + "typescript": "^4.9.4", + "vite": "^4.0.4" + }, + "type": "module" +} diff --git a/packages/kit/test/build-errors/apps/syntax-error/src/app.html b/packages/kit/test/build-errors/apps/syntax-error/src/app.html new file mode 100644 index 000000000000..5b53ef7e3ae7 --- /dev/null +++ b/packages/kit/test/build-errors/apps/syntax-error/src/app.html @@ -0,0 +1,12 @@ + + + + + + + %sveltekit.head% + + +
%sveltekit.body%
+ + diff --git a/packages/kit/test/build-errors/apps/syntax-error/src/lib/test.server.js b/packages/kit/test/build-errors/apps/syntax-error/src/lib/test.server.js new file mode 100644 index 000000000000..770268db581d --- /dev/null +++ b/packages/kit/test/build-errors/apps/syntax-error/src/lib/test.server.js @@ -0,0 +1 @@ +export const should_explode = 'boom'; diff --git a/packages/kit/test/build-errors/apps/syntax-error/src/routes/+page.svelte b/packages/kit/test/build-errors/apps/syntax-error/src/routes/+page.svelte new file mode 100644 index 000000000000..514b2627654e --- /dev/null +++ b/packages/kit/test/build-errors/apps/syntax-error/src/routes/+page.svelte @@ -0,0 +1 @@ +
Px)-AP12RCwC$UE6KzI1p6{F2N z1VK2vi|pOpn{~#djwYcWXTI_im_u^TJgMZ4JMOsSj!0ma>B?-(Hr@X&W@|R-$}W@Z zgj#$x=!~7LGqHW?IO8+*oE1MyDp!G=L0#^lUx?;!fXv@l^6SvTnf^ac{5OurzC#ZMYc20lI%HhX816AYVs1T3heS1*WaWH z%;x>)-J}YB5#CLzU@GBR6sXYrD>Vw(Fmt#|JP;+}<#6b63Ike{Fuo!?M{yEffez;| zp!PfsuaC)>h>-AdbnwN13g*1LowNjT5?+lFVd#9$!8Z9HA|$*6dQ8EHLu}U|obW6f z2%uGv?vr=KNq7YYa2Roj;|zooo<)lf=&2yxM@e`kM$CmCR#x>gI>I|*Ubr({5Y^rb zghxQU22N}F51}^yfDSt786oMTc!W&V;d?76)9KXX1 z+6Okem(d}YXmmOiZq$!IPk5t8nnS{%?+vDFz3BevmFNgpIod~R{>@#@5x9zJKEHLHv!gHeK~n)Ld!M8DB|Kfe%~123&Hz1Z(86nU7*G5chmyDe ziV7$pB7pJ=96hpxHv9rCR29%bLOXlKU<_13_M8x)6;P8E1Kz6G<&P?$P^%c!M5`2` zfY2zg;VK5~^>TJGQzc+33-n~gKt{{of8GzUkWmU110IgI0DLxRIM>0US|TsM=L|@F z0Bun8U!cRB7-2apz=y-7*UxOxz@Z0)@QM)9wSGki1AZ38ceG7Q72z5`i;i=J`ILzL z@iUO?SBBG-0cQuo+an4TsLy-g-x;8P4UVwk|D8{W@U1Zi z!M)+jqy@nQ$p?5tsHp-6J304Q={v-B>66$P0IDx&YT(`IcZ~bZfmn11#rXd7<5s}y zBi9eim&zQc0Dk|2>$bs0PnLmDfMP5lcXRY&cvJ=zKxI^f0%-d$tD!`LBf9^jMSYUA zI8U?CWdY@}cRq6{5~y+)#h1!*-HcGW@+gZ4B};0OnC~`xQOyH19z*TA!!BJ%9s0V3F?CAJ{hTd#*tf+ur-W9MOURF-@B77_-OshsY}6 zOXRY=5%C^*26z?l)1=$bz30!so5tfABdSYzO+H=CpV~aaUefmjvfZ3Ttu9W&W3Iu6 zROlh0MFA5h;my}8lB0tAV-Rvc2Zs_CCSJnx@d`**$idgy-iMob4dJWWw|21b4NB=LfsYp0Aeh{Ov)yztQi;eL4y5 zMi>8^SzKqk8~k?UiQK^^-5d8c%bV?$F8%X~czyiaKCI2=UH { + try { + execSync('pnpm build', { + cwd: path.join(process.cwd(), 'apps/syntax-error'), + stdio: 'pipe', + timeout: 60000 + }); + } catch (err) { + assert.ok( + err.message.includes('Unexpected end of input'), + `received unexpected exception message ${err.message}` + ); + return; + } + assert.unreachable(); +}); + +test.run(); diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 27a0542a8f24..f0be98413f85 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -574,6 +574,20 @@ importers: typescript: 4.9.4 vite: 4.0.4 + packages/kit/test/build-errors/apps/syntax-error: + specifiers: + '@sveltejs/kit': workspace:^ + svelte: ^3.55.1 + svelte-check: ^3.0.2 + typescript: ^4.9.4 + vite: ^4.0.4 + devDependencies: + '@sveltejs/kit': link:../../../.. + svelte: 3.55.1 + svelte-check: 3.0.2_svelte@3.55.1 + typescript: 4.9.4 + vite: 4.0.4 + packages/kit/test/prerendering/basics: specifiers: '@sveltejs/kit': workspace:^