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

@progress/kendo-angular-excel-export and specially @progress/kendo-ooxml breaks my build #489

Closed
EricSch opened this issue Apr 24, 2017 · 17 comments

Comments

@EricSch
Copy link

EricSch commented Apr 24, 2017

By using jszip, this breaks our AOT build. jszip has dependencies to nodejs modules, like buffer and streams.

In jszip there was an issue for webpack support. Stuk/jszip#333.

I don't know how your build process is working, but could you make sure this configuration is applied?

Thank you

@tsvetomir
Copy link
Member

What project template are you using?

I've tried this with Angular CLI and AoT seems to work. See the test project in this repo.

@EricSch
Copy link
Author

EricSch commented Apr 24, 2017

We are using Rollup for AoT, not webpack. Could be a problem, how rollup is handling those node modules.

But like i said, problem seems to be that jszip is using internal nodes modules. And I have to be sure that you have configured jszip with those options mentioned in the jszip issue. I'm not sure if I can change that in our build config.
I downgraded the grid version (without Excel support), and our build works again.

@tsvetomir
Copy link
Member

I've managed to get this working by aliasing JSZip in the Rollup configuration:

const alias = require('rollup-plugin-alias');
const path = require('path');
const process = require('process');

const config = {
...
  plugins: [
    alias({
      jszip: path.join(process.cwd(), './node_modules/jszip/dist/jszip.min.js')
    })
  ]
}

Will investigate if there's something else we can do.

@EricSch
Copy link
Author

EricSch commented Apr 24, 2017

Thank you, I will try it with our build too.

@tsvetomir
Copy link
Member

tsvetomir commented Apr 24, 2017

I've set-up a project with Angular Seed to test this.
You can check it out in the telerik/kendo-angular-quickstart-seed repo.

Tested by running the application with npm run serve.prod.rollup.aot

@EricSch
Copy link
Author

EricSch commented Apr 25, 2017

Yes, our app is running again, thank you. but didn't test the Excel export.

And why did the aliasing help? That I don't get :)

@tsvetomir
Copy link
Member

The main entry in the JSZip package points to its Node.js version. What we need is to take the browser-friendly version from dist. This is solved with the alias.

@rohit-b
Copy link

rohit-b commented Apr 27, 2017

i tried the aliasing step but not working

@tsvetomir
Copy link
Member

We fixed this in the latest release of the kendo-ooxml package. Note that the alias must be removed.

See telerik/kendo-angular-quickstart-seed@c3c59db and telerik/kendo-angular-quickstart-seed@70ec11d

@rohit-b
Copy link

rohit-b commented May 4, 2017

still aot build gives this error
node_modules@progress\kendo-ooxml\dist\es\ooxml.js (1:7)
1: import JSZip from 'jszip/dist/jszip';
^
2: import map from './utils/map';

anything missing?

tsvetomir added a commit to telerik/kendo-angular-quickstart-cli that referenced this issue May 4, 2017
@tsvetomir
Copy link
Member

tsvetomir commented May 4, 2017

I've tested this in the test-489 branch of our Angular CLI sample.
Running ng serve --aot=true seems to work fine.

Can you please compare with your project?

@EricSch
Copy link
Author

EricSch commented May 4, 2017

i have no errors, it works for me

@tsvetomir
Copy link
Member

Closing this, but feel free to reopen if more details become available.

@plcart
Copy link

plcart commented May 18, 2017

what is the purpose to this change?
0.1.0
import JSZip from "jszip"; <-Working
0.1.1 and 1.00
import JSZip from 'jszip/dist/jszip';

i'm using browserify with ts plugin to generate my bundle file so this still breaks the build for not founding the JSZip files

so why not leave packages Json in charge of the entry point

please let me know if you need any more info to reproduce the error

@tsvetomir
Copy link
Member

Are you using any specific project template?

We only test against Webpack 1/2, Rollup and SystemJS based project at the moment.

@plcart
Copy link

plcart commented May 21, 2017

I'm not using any of your templates

i was able to do a workaround with this line of code for who is using browserify to do the bundle

var browserify = require("browserify");
var nodeResolve = require('resolve');
let browserifyProcesor = browserify({...});
browserifyProcesor.require(nodeResolve.sync('jszip'), { expose: 'jszip/dist/jszip' })

and this can be done also at karma with karma-browserify

browserify: { configure: function (bundle) { bundle.once('prebundle', function () { bundle.require(nodeResolve.sync('jszip'), { expose: 'jszip/dist/jszip' }); }); }, plugin: ['tsify'] }

@tsvetomir
Copy link
Member

@plcart you might need the same mapping for the Pako library (used for PDF compression) in the latest version of the Grid:

bundle.require(nodeResolve.sync('pako'), { expose: 'pako/dist/pako_deflate' });

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

No branches or pull requests

4 participants