angular-cli: Prod build error with 3rd party lib (tinymce): Error: Invalid IIFE Structure
Versions
Angular CLI: 6.0.5
Node: 10.0.0
OS: darwin x64
Angular: 6.0.3
... animations, common, compiler, compiler-cli, core, forms
... http, language-service, platform-browser
... platform-browser-dynamic, router
Package Version
-----------------------------------------------------------
@angular-devkit/architect 0.6.5
@angular-devkit/build-angular 0.6.5
@angular-devkit/build-optimizer 0.6.5
@angular-devkit/core 0.6.5
@angular-devkit/schematics 0.6.5
@angular/cli 6.0.5
@ngtools/webpack 6.0.5
@schematics/angular 0.6.5
@schematics/update 0.6.5
rxjs 6.2.0
typescript 2.7.2
webpack 4.8.3
Repro steps
ng new kvak
cd kvak
npm install --save tinymce
nano src/app/app.component.ts
- add
import { tinymce } from 'tinymce/tinymce';
- add
dummy = tinymce;
inside the AppComponent ng build --prod
Observed behavior
ERROR in ./node_modules/tinymce/tinymce.js
Module build failed: Error: Invalid IIFE Structure
at updateEnumIife (/Users/kolik/Workspaces/Test/kvak/node_modules/@angular-devkit/build-optimizer/src/transforms/wrap-enums.js:298:15)
at visitBlockStatements (/Users/kolik/Workspaces/Test/kvak/node_modules/@angular-devkit/build-optimizer/src/transforms/wrap-enums.js:82:61)
at visitor (/Users/kolik/Workspaces/Test/kvak/node_modules/@angular-devkit/build-optimizer/src/transforms/wrap-enums.js:33:26)
at visitNode (/Users/kolik/Workspaces/Test/kvak/node_modules/typescript/lib/typescript.js:52795:23)
at visitFunctionBody (/Users/kolik/Workspaces/Test/kvak/node_modules/typescript/lib/typescript.js:52901:23)
at Object.visitEachChild (/Users/kolik/Workspaces/Test/kvak/node_modules/typescript/lib/typescript.js:53015:407)
at visitor (/Users/kolik/Workspaces/Test/kvak/node_modules/@angular-devkit/build-optimizer/src/transforms/wrap-enums.js:53:23)
at visitNode (/Users/kolik/Workspaces/Test/kvak/node_modules/typescript/lib/typescript.js:52795:23)
at Object.visitEachChild (/Users/kolik/Workspaces/Test/kvak/node_modules/typescript/lib/typescript.js:53005:44)
at visitor (/Users/kolik/Workspaces/Test/kvak/node_modules/@angular-devkit/build-optimizer/src/transforms/wrap-enums.js:53:23)
at visitNode (/Users/kolik/Workspaces/Test/kvak/node_modules/typescript/lib/typescript.js:52795:23)
at Object.visitEachChild (/Users/kolik/Workspaces/Test/kvak/node_modules/typescript/lib/typescript.js:53013:45)
at visitor (/Users/kolik/Workspaces/Test/kvak/node_modules/@angular-devkit/build-optimizer/src/transforms/wrap-enums.js:53:23)
at visitNode (/Users/kolik/Workspaces/Test/kvak/node_modules/typescript/lib/typescript.js:52795:23)
at Object.visitEachChild (/Users/kolik/Workspaces/Test/kvak/node_modules/typescript/lib/typescript.js:53059:49)
at visitor (/Users/kolik/Workspaces/Test/kvak/node_modules/@angular-devkit/build-optimizer/src/transforms/wrap-enums.js:53:23)
Desired behavior
Build success.
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Reactions: 18
- Comments: 24
I’ve also got the same error. I have temporarily solved the problem by downgrading tinymce to version 4.7.4. This issue might give some additional information: https://github.com/tinymce/tinymce/issues/4165
@ttrevorr Also just got some updates on the tinymce side and they are confident that the issue is with angular cli. See the latest comments. https://github.com/tinymce/tinymce/issues/4165
make sure to uninstall the previous tinymce first and then install the 4.7.4 build. it worked for me.
Any progress with this issue? Would be nice to be able to get the latest version and not having to do any special handling. Seems like TinyMCE has closed the issue on their end: https://github.com/tinymce/tinymce/issues/4165 https://github.com/tinymce/tinymce/issues/4483
Fixed
ng build --prod
succeeded! I had an unnecessary import in my AppComponent.Still broken with tinymce 4.9.2 and @angular/cli 7.2.2 but works fine with tinymce 4.7.4
TinyMCE 5.0.8 should resolve this issue.
I used dynamic import
This really seems like an issue with TinyMCE and not angular cli. It looks like a breaking change was introduced after 4.7.4 build and it has yet to be fixed. https://github.com/tinymce/tinymce/issues/4165