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

After bundling application, webcomponents-loader.js is inlined to HTML and application doesn't work in older browsers #2546

Open
hinok opened this issue Oct 4, 2017 · 1 comment

Comments

@hinok
Copy link

hinok commented Oct 4, 2017

Description

Using { bundle: true } or --bundle breaks application in older browsers because code from <script src="/bower_components/webcomponentsjs/webcomponents-loader.js"></script> is inlined to html which results runtime error.
zrzut ekranu 2017-10-05 o 00 53 40

It's because code in webcomponents-loader.js

  // global for (1) existence means `WebComponentsReady` will file,
  // (2) WebComponents.ready == true means event has fired.
  window.WebComponents = window.WebComponents || {};
  var name = 'webcomponents-loader.js';
  
  // ...code

  if (polyfills.length) {
    var script = document.querySelector('script[src*="' + name +'"]'); // script = null
    // there is no such <script> tag because it has been inlined

It's clear that this file shouldn't be inlined.

Versions & Environment

  • Polymer CLI: 1.5.6
  • node: 6.11.3
  • Operating System: macOS 10.12.6

Steps to Reproduce

  1. polymer init
  2. Choose template polymer-2-application
  3. Build application by using command
polymer build --js-compile --js-minify --css-minify --bundle

or use this polymer.json

{
  "entrypoint": "index.html",
  "builds": [
    {
      "bundle": true,
      "js": { "minify": true, "compile": true },
      "css": { "minify": true },
      "html": { "minify": true }
    }
  ],
  "lint": {
    "rules": ["polymer-2"]
  }
}

then

polymer build
  1. Serve built app
polymer serve build/default
  1. Open application http://127.0.0.1:8081

Expected Results

Hello __YOUR__APP__NAME! should be visible.

Actual Results

Blank page and in the console reported errors below

Uncaught TypeError: Cannot read property 'src' of null
(index):309 Uncaught TypeError: Cannot read property 'polyfillWrapFlushCallback' of undefined
(index):426 Uncaught ReferenceError: customElements is not defined
(index):1201 Uncaught TypeError: Cannot read property 'define' of undefined

I've tried to use excludes for bundle but still this file is always bundled (inlined) to HTML.

polymer.json

{
  "entrypoint": "index.html",
  "builds": [
    {
      "bundle": {
        "excludes": ["/bower_components/webcomponentsjs/webcomponents-loader.js"]
      },
      "js": { "minify": true, "compile": true },
      "css": { "minify": true },
      "html": { "minify": true }
    }
  ],
  "lint": {
    "rules": ["polymer-2"]
  }
}

Edit: Ahhhh, it seems that files in excludes should NOT have beginning slash...

Probably related:

@hinok hinok changed the title After bundling application, webcomponents-loader.js is inlined to HTML After bundling application, webcomponents-loader.js is inlined to HTML and application doesn't work in older browsers Oct 4, 2017
@aomarks aomarks transferred this issue from Polymer/polymer-cli Jan 3, 2019
@stale
Copy link

stale bot commented Mar 3, 2020

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the wontfix label Mar 3, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants