Does anyone have an example of webpack working with running GridExcelExporter to export a grid? I'm running into all sorts of webpack'ish issues when trying to do so.
Hi Stephen,
Currently we are not aware of such issues, but we don't have an example either. I will work to prepare one and see if what we can do if/when any troubles occur. I will keep you updated.
Hello Stephen,
Thank you for your patience and understanding while I'm going though this. I will update you again once I have more significant progress on the task.
Thanks for quick response. I will go for the latest version as well. First intl issues is resolved by referencing Intl explicitly, but then it throws "No locale data has been provided for this object yet", which indicates that Intl locales are not accessible. I am currently working onto it. Please let me know what formatting issues you have, so that if it shows on my side I know if it is the same.
I am continuing work and will update you in the end of the working day.
Hristo
I am still hitting the "No locale data has been provided for this object yet". If you are able to get around this, but then getting the following error:
Uncaught Class {__message: null, __innerException: null}
please let me know, we have a solution fort the last one. Anyway, tell me what is the exact error you get in formatting after you "hack the Intl stuff".
I did get that Uncaught class error once I believe. It'll take a bit to get back to that point, I can try later this week to get there and see if we can match up on where we're still struggling to get through this.
Thanks.
Meanwhile could you update me if you did worked around the "No locale data has been loaded" error and how, and what is the latest issue you are running into.
I investigated further and found out we need to pass this.IntlPollyFill.__addLocaleData to resolve the No Locale Data error (this is done in the Infragistics.documents.core.js). Then a saveAs is not defined error will occur, so we will need to put saveAs on the global scope as well:
global.saveAs = require('./ignite/filesaver').saveAs;
I am attaching the sample I worked with.
Please let me know if you have further questions on the matter, I will be glad to help.
Thanks for summarizing all of this so that other community members benefit as well!
So I hope you guys (infragistics) go through and update your source for all this to better handle the references and update your dependencies because I think that'd help with the webpack'ing.
Here's the bare minimum I think I've found to accomplish exporting in webpack:
webpack.config.js
module: { rules: [
{ test: require.resolve("intl"), loader: "imports-loader?this=>window&define=>false" }, { test: require.resolve("./app/scripts/vendor/infragistics.util"), loader: "imports-loader?this=>window&define=>false" }, { test: require.resolve("./app/scripts/vendor/infragistics.documents.core"), loader: "imports-loader?this=>window&define=>false" }
]}
These are the imports in my TS file that does exporting:
import * as filesaver from "file-saver";
import "./vendor/infragistics.util";import "./vendor/infragistics.documents.core";import "./vendor/infragistics.excel";import "./vendor/infragistics.gridexcelexporter";
and in the constructor of my TS class I have:
window.saveAs = filesaver.saveAs;
where I have a type definition file that declares on the window object the saveAs function:
interface Window{
saveAs: Function;
}
And of course don't forget about directly including the jszip.js file in your html.
I am glad this finally worked !
I also had the issue with saveAs not defined, so as mentioned on my previous posts another resolution is to put saveAs on the global scope as well:
I think the information here is enough for other members of our community to benefit from, since I have attached the sample I worked with and as it turned out we have been facing the same exact issues that will most probably everyone will face when implementing similar webpack scenario.
Thank you for your cooperation and let me know If you have any other questions, I will be glad to help.
Finally! with loading that JSzip directly, I then had an issue where saveAs wasn't able to be put into global scope right on the window object, so i had to update the excel exporter js file to call saveAs like 'filesaver.saveAs', and then it all worked. I'll see if I can clean up my webpack/ts files and post them here as an example too.
The "Uncaught Class {__message: null, __innerException: null}" error is a result of the JSZip library (which is embedded in our source) to not be available in the global scope. You should be able to resolve this by explicitly referencing JSZIp either as I did the conventional way: <script src="jszip.js"></script> or using import: import 'JSZip'.
Apart from this the snippet you send seems correct and I am expecting it to work. Please try to explicitly reference JSZip, so that is available and let me know if this resolved your issues.
I am looking forward to hearing from you.