Urigo / angular-meteor

Angular and Meteor - The perfect stack

Home Page:https://www.angular-meteor.com/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Typescript compiler adds arrow function in web.browser.legacy js file causing error on IE11

araad opened this issue · comments

commented

Issue description

Running an app using angular-compilers in production mode with AOT=1 and ROLLUP=1 causes a syntax error on Internet Explorer 11 preventing the app from loading. The error is related to system.js import function in the section below in the following file (line 276) https://github.com/Urigo/angular-meteor/blob/master/atmosphere-packages/angular-typescript-compiler/index.js

if (this.isRollup) {
      const inputFile = inputFiles.find(file => {
        const filePath = file.getPathInPackage();
        return filePath.startsWith(prefix) &&
          filePath.indexOf('imports') === -1;
      });
      if (inputFile) {
        inputFile.addJavaScript({
          path: 'system.js',
         //
         // Problematic line below
         //
          data: `System = { import(path) { return module.dynamicImport(path) } }`
        });
      }
    }

Steps to reproduce

  1. git clone https://github.com/Urigo/angular-meteor-base myApp
  2. cd myApp
  3. meteor npm install
  4. AOT=1 ROLLUP=1 meteor --production

Expected result

The compiled code in web.browser.legacy should be compatible on older browsers replacing all arrow functions with regular functions

Actual result

One arrow function remains in the js file under .meteor/local/build/programs/web.browser.legacy/:

"system.js":function(t,e,n){System={import:t=>n.dynamicImport(t)}}

NOTE: The issue seems to be fixed when line 276 in file https://github.com/Urigo/angular-meteor/blob/master/atmosphere-packages/angular-typescript-compiler/index.js is replaced with the following:

data: `System = { import: function(path) { return module.dynamicImport(path) } }

Environment

OS: Ubuntu 16.04
Meteor version: 1.8.0.1

installed packages

allow-deny@1.1.0
angular-compilers@0.3.2
angular-html-compiler@0.3.2
angular-scss-compiler@0.3.2
angular-typescript-compiler@0.3.2
autoupdate@1.5.0
babel-compiler@7.2.3
babel-runtime@1.3.0
base64@1.0.11
binary-heap@1.0.11
boilerplate-generator@1.6.0
callback-hook@1.1.0
check@1.3.1
ddp@1.4.0
ddp-client@2.3.3
ddp-common@1.4.0
ddp-server@2.2.0
diff-sequence@1.1.1
dynamic-import@0.5.1
ecmascript@0.12.3
ecmascript-runtime@0.7.0
ecmascript-runtime-client@0.8.0
ecmascript-runtime-server@0.7.1
ejson@1.1.0
es5-shim@4.8.0
fetch@0.1.0
geojson-utils@1.0.10
hot-code-push@1.0.4
id-map@1.1.0
inter-process-messaging@0.1.0
launch-screen@1.1.1
livedata@1.0.18
logging@1.1.20
meteor@1.9.2
meteor-base@1.4.0
minifier-css@1.4.1
minifier-js@2.4.0
minimongo@1.4.5
mobile-experience@1.0.5
mobile-status-bar@1.0.14
modern-browsers@0.1.3
modules@0.13.0
modules-runtime@0.10.3
mongo@1.6.0
mongo-decimal@0.1.0
mongo-dev-server@1.1.0
mongo-id@1.0.7
npm-mongo@3.1.1
ordered-dict@1.1.0
promise@0.11.1
random@1.1.0
reactive-var@1.0.11
reload@1.2.0
retry@1.1.0
routepolicy@1.1.0
shell-server@0.4.0
socket-stream-client@0.2.2
standard-minifier-css@1.5.2
standard-minifier-js@2.4.0
tracker@1.2.0
underscore@1.0.10
webapp@1.7.2
webapp-hashing@1.0.9

tsconfig.json

{
  "compilerOptions": {
    "allowSyntheticDefaultImports": true,
    "baseUrl": ".",
    "declaration": false,
    "emitDecoratorMetadata": true,
    "importHelpers": true,
    "experimentalDecorators": true,
    "lib": [
      "dom",
      "es2015"
    ],
    "module": "commonjs",
    "moduleResolution": "node",
    "sourceMap": true,
    "target": "es5",
    "skipLibCheck": true,
    "stripInternal": true,
    "noImplicitAny": false,
    "types": [
      "@types/meteor",
      "@types/mocha",
      "@types/chai",
      "@types/sinon"
    ]
  },
  "include": [
    "imports/**/*.ts",
    "client/**/*.ts",
    "server/**/*.ts"
  ],
  "exclude": [
    "node_modules"
  ],
  "compileOnSave": false,
  "atom": {
    "rewriteTsconfig": false
  }
}