Aurelia Typescript project only working on Chrome

2019-06-27 10:14发布

问题:

Does anyone know why Aurelia-Typescript projects listed in this git repository only functions on Chrome browser?

Are there ES6 features that are only currently supported on Chrome and not on IE or FireFox?

EDIT - below are the error messages from Firefox 34.0.5

mutating the [[Prototype]] of an object will cause your code to run very slowly; instead create the object with the correct initial [[Prototype]] value using Object.create core.js:130

The character encoding of the HTML document was not declared. The document will render with garbled text in some browser configurations if the document contains characters from outside the US-ASCII range. The character encoding of the page must be declared in the document or in the transfer protocol. index.html

"DEBUG [bootstrapper] loading the HTMLImports polyfill" core.js:2518

The Web Console logging API (console.log, console.info, console.warn, console.error) has been disabled by a script on this page.

Error: Script error for: webcomponentsjs/HTMLImports.min http://requirejs.org/docs/errors.html#scripterror require.js:166

回答1:

In aurelia-bundle.js at line 15346 (bootstrapper part) it checks whether HTML import is supported:

      if (!("import" in document.createElement("link"))) {
        logger.debug("loading the HTMLImports polyfill");
        toLoad.push(System.normalize("webcomponentsjs/HTMLImports.min", loaderName).then(function (name) {
          return System["import"](name);
        }));
      }

The only browser that supports it out-of-the-box is still Chrome. For the other browsers HTMLImports polyfill loading fails because:

  1. HTMLImports.min.js is missing from webcomponentsjs directory
  2. The path should be "aurelia/webcomponentsjs/HTMLImports.min". It might be better to move webcomponentsjs to the root path (I don't know how this can be handled through bundling)
  3. Follow @Chi Row's answer below for HTML Template Element polyfill (IE 11 seems supporting them, so it worked without).


回答2:

@T Sol's answer above solved the problem for Firefox.

For IE, I downloaded HTMLTemplateElements.js from this git repository and placed the file in the root directory. Then renamed the file to aurelia-html-template-elements.js.

That solved the problem for IE.