Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Parse error for Polymer 3.0.0-pre.12 #363

Closed
justinfagnani opened this issue Mar 23, 2018 · 7 comments
Closed

Parse error for Polymer 3.0.0-pre.12 #363

justinfagnani opened this issue Mar 23, 2018 · 7 comments

Comments

@justinfagnani
Copy link

See this blitz: https://stackblitz.com/edit/hello-polymer-3?file=example.js

Not sure what the error here is, the module loads in Chrome.

@EricSimons
Copy link
Member

EricSimons commented Mar 23, 2018

@justinfagnani this is a problem with our import tracing/compiling; since example.js is being dynamically imported the @polymer/polymer/polymer-element.js file isn't transpiled AoT (and thus throws this error).

Besides the upcoming static asset support we've chatted about, this can be solved in 2 ways right now:

  1. Use normal ESM imports instead of dynamic imports (enables our tracer to do AoT compilation of all dependencies)
  2. Use a normal ESM import to initially dev the example, then switch it to a dynamic import. When you hit save we actually save a cached version of your current compiled bundle, so the transpiled polymer files will continue to persist.

I know this is not super ideal- our upcoming upgrades to the bundler and dev server should completely eliminate all of these weird quirks though. Thanks for hanging in there :)

@justinfagnani
Copy link
Author

Shouldn't it be fine if the file isn't transpiled? Seems like some other part of the toolchain doesn't have an up-to-date parser maybe.

In our case we can't use a normal JS import, because we have to wait for the polyfills to load before running app code. I tried using our blocking polyfill loader, but without complete control over index.html, the script tag for index.js is being inserted before the polyfill script tags, making the blocking/document.write behavior not work.

@EricSimons
Copy link
Member

In order for ESM modules to be added to System's registry it needs to be compiled to either System.register or CJS format. With static asset support you'll be able to leverage module scripts though, which (obv) doesn't require any compilation/etc.

Regarding polyfill loader/scripts in index.html: all scripts listed in index.html should be loaded & executed in order. Are you seeing this behave otherwise?

@justinfagnani
Copy link
Author

What I was seeing for the blitz above was that the injected script tag for index.js was being run before the script tags I had statically in index.html. I'd rather add my own script tag for index.js and have full control.

@EricSimons
Copy link
Member

Were you placing the script tag in head? If so, it should be guaranteed execute before index.js.

Adding own script tag for index.js will be enabled w/ new dev server static asset support :)

@justinfagnani
Copy link
Author

I'll try it again and report back.

Awesome news again :)

@justinfagnani justinfagnani changed the title Parse error for Polymer 3.0.0-re.12 Parse error for Polymer 3.0.0-pre.12 Mar 31, 2018
@purplem1lk
Copy link
Contributor

Thank you for your patience - The latest project link is no longer working and we are unable to move forward with this issue and will be closing this accordingly. We are launching new core technology into beta this month that should resolve this issue. If this issue persists, feel free to tag me or reopen this issue with a working project link and screenshots of the error. Thank you! :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants