polymer-starter-kit icon indicating copy to clipboard operation
polymer-starter-kit copied to clipboard

SyntaxError: import declarations may only appear at top level of a module

Open creativeautomaton opened this issue 6 years ago • 3 comments

Description

The switch import on the _pageChanged(page) function that controls routing seems to be broken.. I recieve a ' SyntaxError: import declarations may only appear at top level of a module ' in my error console and the app breaks. This is from my app but also a clean install of the prrl pattern polymer app using polymer-cli init.

Expected outcome

routing should have worked but this error happens?

Actual outcome

app breaks and not routing occurs. only index.html is loaded.

Live Demo

Steps to reproduce

  1. polymer init

  2. choose the prrl pattern app with navigation

  3. npm install

  4. polymer serve

  5. get error message.

Browsers Affected

  • [ ] Chrome
  • [ ] Edge
  • [ ] Firefox
  • [ ] IE 11
  • [ ] Safari 8
  • [ ] Safari 9

creativeautomaton avatar Jun 29 '18 14:06 creativeautomaton

What browser and what version of the CLI are you using? Dynamic import() statements require browser support, but the latest polymer-cli (polymer serve) will covert them to AMD modules if the request comes from a browser with no support.

keanulee avatar Jun 29 '18 21:06 keanulee

@keanulee I just ran into this today with the starter-kit, for me, its post-build (i'll try to convert them to AMD modules) but the my browser is the current Firefox ESR 60.x.

ruckc avatar Feb 15 '19 20:02 ruckc

FF still doesn't support dynamic import - https://caniuse.com/#feat=es6-module-dynamic-import

keanulee avatar Feb 15 '19 20:02 keanulee