FredKSchott / snowpack

ESM-powered frontend build tool. Instant, lightweight, unbundled development. ✌️
https://www.snowpack.dev
MIT License
19.48k stars 922 forks source link

[BUG] Transpiled files don't work in Safari #3180

Open beorn opened 3 years ago

beorn commented 3 years ago

Bug Report Quick Checklist

Describe the bug

The files from snowpack dev doesn't work in Safari, triggering this error in the Safari/WebKit console (from Parser.cpp in WebKit):

SyntaxError: Unexpected identifier 'as'. Expected 'from' before exported module name.

I'm guessing it's from an export line that doesn't include a 'from', such as:

% grep "^export .* as " .node_modules/.cache/**/*.js | grep -v from
./node_modules/.cache/snowpack/build/esrever@0.2.0/esrever.js:export { esrever as __moduleExports, reverse, version };
./node_modules/.cache/snowpack/build/immer@7.0.15/immer.js:export { on as Immer, vn as applyPatches, K as castDraft, $ as castImmutable, pn as createDraft, D as current, J as enableAllPlugins, T as enableES5, C as enableMapSet, F as enablePatches, ln as finishDraft, L as immerable, t as isDraft, r as isDraftable, H as nothing, e as original, an as produce, fn as produceWithPatches, cn as setAutoFreeze, sn as setUseProxies };

Perhaps some extra transpilation needs to happen for Safari by default? Potentially related to https://github.com/snowpackjs/snowpack/discussions/2354 as I tried to set target in tsconfig.json, but it was ignored.

Expected behavior

I was expecting Safari to work out-of-the-box.

jbuckner commented 3 years ago

Have you tried setting the target in the snowpack.config.js optimize section? ie:

optimize: {
  target: 'es2107'
}
beorn commented 3 years ago

Have you tried setting the target in the snowpack.config.js optimize section? ie:

optimize: {
  target: 'es2107'
}

Yeah, I just tried and getting the same error. Previously I was just using snowpack dev.