Skip to content

Strict mode syntax error when running @angular/compiler 2.3.0 in PhantomJS #13301

@tsvetomir

Description

@tsvetomir

I'm submitting a ...

[x] bug report

Current behavior
Running @angular/compiler in PhantomJS results in an error:

Uncaught SyntaxError: In strict mode code, functions can only be declared at top level or immediately within another function.

The offending code can be found in @angular/compiler/bundles/compiler.umd.js:26587:

  JitCompiler.prototype._createCompiledHostTemplate = function (compType, ngModule) {
      if (!ngModule) {
          throw new Error("Component " + stringify(compType) + " is not part of any NgModule or the module has not been imported into your module.");
      }
      var /** @type {?} */ compiledTemplate = this._compiledHostTemplateCache.get(compType);
      if (!compiledTemplate) {
          var /** @type {?} */ compMeta = this._metadataResolver.getDirectiveMetadata(compType);
          assertComponent(compMeta);
          var HostClass_1 = (function () {
              function HostClass_1() {
              }
              HostClass_1.overriddenName = identifierName(compMeta.type) + "_Host";
              return HostClass_1;
          }());
          function HostClass_tsickle_Closure_declarations() {
//        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
              /** @type {?} */
              HostClass_1.overriddenName;
          }
          var /** @type {?} */ hostMeta = createHostComponentMeta(HostClass_1, compMeta);
          compiledTemplate = new CompiledTemplate(true, compMeta.selector, compMeta.type, hostMeta, ngModule, [compMeta.type]);
          this._compiledHostTemplateCache.set(compType, compiledTemplate);
      }
      return compiledTemplate;
  };

Expected behavior
The code should run in PhantomJS

Minimal reproduction of the problem with instructions
See tsvetomir/phantomjs-angular-2.3 for a runnable sample.

  1. git clone git@github.com:tsvetomir/phantomjs-angular-2.3.git
  2. cd phantomjs-angular-2.3
  3. npm install
  4. ./node_modules/.bin/phantomjs script.js

What is the motivation / use case for changing the behavior?
The shipped code shouldn't violate Strict Mode restrictions.

Please tell us about your environment:

  • Angular version: 2.3.0

  • Browser: PhantomJS 2.1.7

  • Language: TypeScript 2.1

  • Node (for AoT issues): 4.7

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions