glimmerjs / glimmer-blueprint

[MOVED] This package is now part of the Glimmer.js monorepo
https://github.com/glimmerjs/glimmer.js
25 stars 13 forks source link

`ember build -e prod` outputs JS that triggers Safari 10 bug "Cannot declare a let variable twice" #58

Closed bantic closed 6 years ago

bantic commented 7 years ago

Creating a new glimmer app from the blueprint and building for production outputs code that contains a let declaration shadowing a function parameter. This is syntactically valid ES but Safari 10 has a bug related to this and complains "Cannot declare a let variable twice".

This is the Safari bug (it's fixed and in Safari Technology Preview): https://bugs.webkit.org/show_bug.cgi?id=171041

uglify-es has a workaround for this bug — they added a safari10 mangle option. Adding the following to the ember-cli-build.js fixes the issue:

    'ember-cli-uglify': {
      uglify: {
        mangle: {
          safari10: true
        }
      }
    },

The steps I took to reproduce:

➜  201-created ember version
ember-cli: 2.14.0-beta.2
node: 6.9.1
os: darwin x64
➜  201-created ember new my-glimmer-app -b @glimmer/blueprint
installing blueprint
  create .editorconfig
  create .watchmanconfig
  create README.md
  create config/environment.js
  create config/module-map.d.ts
  create config/resolver-configuration.d.ts
  create config/targets.js
  create ember-cli-build.js
  create .gitignore
  create package.json
  create public/robots.txt
  create src/index.ts
  create src/main.ts
  create src/ui/components/my-glimmer-app/component-test.ts
  create src/ui/components/my-glimmer-app/component.ts
  create src/ui/components/my-glimmer-app/template.hbs
  create src/ui/index.html
  create src/ui/styles/app.scss
  create src/utils/test-helpers/test-helper.ts
  create testem.json
  create tsconfig.json
  create yarn.lock
Yarn: Installed dependencies
Successfully initialized git.
➜  201-created cd my-glimmer-app
➜  my-glimmer-app git:(master) ember serve -e production
Livereload server on http://localhost:49153

Build successful (5622ms) – Serving on http://localhost:4200/

Slowest Nodes (totalTime => 5% )              | Total (avg)
----------------------------------------------+---------------------
RollupWithDependencies (1)                    | 2508ms
UglifyWriter (1)                              | 1579ms
TypeScript (1)                                | 1364ms

Visiting localhost:4200 in Safari 10 shows the javascript error in the console, and the app doesn't load.

acorncom commented 6 years ago

As mentioned in https://github.com/glimmerjs/glimmer-application-pipeline/issues/123#issuecomment-339307712 looks like we can close this issue too