Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

remove core-js/ import #1030

Merged
merged 1 commit into from
Dec 12, 2019
Merged

remove core-js/ import #1030

merged 1 commit into from
Dec 12, 2019

Conversation

bleuscyther
Copy link
Contributor

This affects angular. Because core-js is imported inside the library , the Promise polyfill is in conflict with zone.js. Since Excel.js puts browsers compatibility on the hands of the devs. (link) , we can add it manually in a way that does not conflict with Angular.

this PR should fix : #1008

This was fixe din many other package and is referenced here:
angular/zone.js#783

@guyonroche
Copy link
Collaborator

@bleuscyther - I'm tending to agree - though I might go one step further and remove the regenerator-runtime/runtime require as well, leaving the whole task of polyfill support to the app in question. What do you think?

@bleuscyther
Copy link
Contributor Author

that would be perfect.

@guyonroche guyonroche merged commit 50d02ef into exceljs:master Dec 12, 2019
@guyonroche
Copy link
Collaborator

@bleuscyther I've just merged - I'm going to make one further change... In order to avoid breaking changes, I'm going to copy exceljs.browser.js to exceljs.bare.js that removes all polyfills and restore exceljs.browser.js to keep them. To include the exceljs bundle without pollys, just change the import from dist/exceljs.min.js to dist/exceljs.bare.min.js

@bleuscyther
Copy link
Contributor Author

Nice i am going to test this week

@bleuscyther
Copy link
Contributor Author

bleuscyther commented Dec 13, 2019

There was a new error:

Uncaught ReferenceError: regeneratorRuntime is not defined

from what i see this is a babel issue related to how the file was built. babel/babel#9849

As a quick fix, I installed the missing package :

npm install regenerator-runtime

and put the import in the polyfill for now:

// ./src/polyfill.ts
import "regenerator-runtime/runtime";

Using angular i had to do the usual additional changes (tested on version 8), it works fine after that

// ./tsconfig.json
...
  "module": "esnext",
    "moduleResolution": "node",
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "importHelpers": true,
    "allowSyntheticDefaultImports": true,
    "target": "es2015",
   "paths": {
        "exceljs": [
          "../node_modules/exceljs/dist/exceljs.bare"
      ],
..

Check this (link) for additional configs and updated values/fields.

...
// ./angular.json
...
"architect": {
        "build": {
          "builder": "@angular-devkit/build-angular:browser",
          "options": {
                ...
               "scripts": [
                  ...
                  "./node_modules/exceljs/dist/exceljs.bare.js"
               ]
               ...
//my .component.ts

import * as ExcelJS from 'exceljs/dist/exceljs.bare.js';
import {Row, Workbook, Worksheet} from 'exceljs';
...
    const workbook: Workbook = new ExcelJS.Workbook(); // Important don' t use Class directly the wrong module will be loaded

@guyonroche
Copy link
Collaborator

@bleuscyther
Great you got it working - does this leave any changes required for ExcelJS?
My thoughts are that the 'bare' option leaves all the polyfill dependencies for the app to fetch - including "regenerator-runtime/runtime" - though I should probably add this to the readme

@bleuscyther
Copy link
Contributor Author

Probably add it on the Readme. Thank you for your help.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

"Zone.js has detected that ZoneAwarePromise (window|global).Promise has been overwritten
3 participants