sveltejs/template

Svelte await blocks cause breaking errors in Terser's compression step

igneosaur opened this issue · 6 comments

Problem?

Terser is doing its thing for production builds. It carries out a second compression on bundle.js that results in a breaking JS error if any Svelte files contain {#await ...} blocks.

Recreate the bug

  1. Add a Svelte file with an await block into your application
  2. Run a production build npm run build
  3. Serve up the public directory
  4. Observe dead site

Screenshot 2019-08-30 at 17 18 17

Fix

Since the second pass of compression on bundle.js is superfluous and causes a bug, it should be removed from the Terser plugin's build step. #58

It works good the await for me with default terser() call.

Can you push a reproduction on github?

I saw the repo. I'm trying to understand the problem.

I found the problem: is not terser.

The problem is with sveltejs: 3.9.1.

With sveltejs: 3.9.0 it works fine!

We should open an issue.

Opened: sveltejs/svelte#3483.

Please do not remove your fork, @igneosaur. Thanks.

Closing this in favor of this issue, which perhaps can be used to try to narrow down a repro to open against Terser.