1

I followed https://angular.io/docs/ts/latest/guide/upgrade.html# to use UpgradeModule from '@angular/upgrade/static'.

Grunt-ts is used to transpile the TypeScript files. The app also uses grunt-browserify for compilation. When grunt is run, it throws errors at grunt-browserify with the following message:

>> export { downgradeComponent } from './src/aot/downgrade_component';
>> ^ ParseError: 'import' and 'export' may appear only with 'sourceType: module'

I added babelify in grunt-browserify options:

"transform": [["browserify-shim"], ["babelify", {"presets": ["es2015"]}]]

But I'm still getting the same error which is pointing to @angular/upgrade/static.js

Thanks!

othanda
  • 51
  • 1
  • 3
  • What files are being fed into `babelify`? Unless you are feeding JavaScript files that have already compiled from TypeScript, it won't work. If that is the case, you'll need to make some changes to your build process or look at using the [`tsify`](https://github.com/TypeStrong/tsify) plugin for Browserify instead of `babelify`. – cartant Jan 03 '17 at 03:46
  • Babelify is consuming JavaScript files. I tried to replace Grunt-ts with Tsify + Babelify previously and it failed with an error message saying no compiled module was created for the .ts file. – othanda Jan 03 '17 at 21:37
  • The `'import' and 'export' may appear only with 'sourceType: module'` is what's effected if Browserify see an ES6 module. I guess the it could also be coming from `browserify-shim` (I've neither used nor looked at that transform). Try putting `browserify-shim` after `babelify`. – cartant Jan 03 '17 at 21:42

0 Answers0