question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Prod build error with 3rd party lib (tinymce): Error: Invalid IIFE Structure

See original GitHub issue

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.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:18
  • Comments:24

github_iconTop GitHub Comments

6reactions
johandrottcommented, Jun 1, 2018

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

4reactions
PTC-JoshuaMatthewscommented, Mar 19, 2019

@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

I looked into the angular-cli issue more and it appears to be an issue in their logic. The cause appears to be that they are using metaprogramming to parse the imported modules (not entirely sure why, but it looks to be for processing enums), however their logic seems to be incorrect because as @TheSpyder said it’s perfectly valid to have an iife inside another iife in JS (even though it is probably an edge case).

As such, I’d suggest logging an issue with the Angular team so that they can investigate/fix their processing logic.

To add a little bit more detail, when TypeScript compiles an enum it ends up as JS something like this:

export var Direction; (function (Direction) { Direction[Direction[“Up”] = 0] = “Up”; })(Direction || (Direction = {})); So what appears to be happening, is that the angular logic is incorrectly detecting the iife JS produced by TinyMCE to be an Enum and therefore saying it’s invalid because it’s not an enum.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Most common plugin errors in TinyMCE and how to fix them
Ways to fix the most common plugin errors in TinyMCE and why those happen, including “TinyMCE failed to load plugin” error.
Read more >
TinyMCE not working: possible causes and fixes
There are a couple of possible reasons of TinyMCE not working - you can fix those easily and we prepared detailed instructions for...
Read more >
How to fix uncaught reference error: TinyMCE is not defined
Have you ever experienced the uncaught reference error: package is not defined? This means that as requests were sent by different packages ...
Read more >
Troubleshoot server-side components | Docs - TinyMCE
Reload the browser page and all should work well. Out of memory errors. The Java application server throws “Out of Memory” errors. Even...
Read more >
TinyMCE integration not working with angular 8 - Stack Overflow
I am getting following error in VS Code console: ERROR in node_modules/@tinymce/tinymce-angular/editor/editor.component.d.ts ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found