refactor(excel-export): switch to explicit fflate/browser entry#17122
refactor(excel-export): switch to explicit fflate/browser entry#17122damyanpetev wants to merge 1 commit intomasterfrom
Conversation
There was a problem hiding this comment.
Pull request overview
This PR addresses a Vitest (Playwright browser mode) bundling issue by forcing the Excel export implementation to use fflate’s explicit browser entrypoint.
Changes:
- Switch
zipimport tofflate/browserin the Excel exporter service. - Switch
strToU8import tofflate/browserin Excel file generation helpers.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| projects/igniteui-angular/grids/core/src/services/excel/excel-exporter.ts | Uses fflate/browser for zipping the generated Excel file structure to avoid Vitest selecting the Node entry. |
| projects/igniteui-angular/grids/core/src/services/excel/excel-files.ts | Uses fflate/browser for string-to-Uint8Array conversion when generating XLSX XML payloads. |
| @@ -1,4 +1,4 @@ | |||
| import { zip } from 'fflate'; | |||
| import { zip } from 'fflate/browser'; | |||
There was a problem hiding this comment.
Importing from fflate/browser hard-codes the browser entry at module load time. Since IgxExcelExporterService is part of the public grids/core surface (and can be pulled into SSR/server bundles indirectly), this can cause SSR/runtime failures if fflate/browser touches browser globals during evaluation. Consider lazy-loading fflate/browser only when an export is triggered (similar to the dynamic import('jspdf') used in pdf-exporter.ts) or introducing an environment-aware wrapper that selects the appropriate entry for browser vs server builds.
| import { zip } from 'fflate/browser'; | |
| import { zip } from 'fflate'; |
| import { WorksheetData } from './worksheet-data'; | ||
|
|
||
| import { strToU8 } from 'fflate'; | ||
| import { strToU8 } from 'fflate/browser'; |
There was a problem hiding this comment.
Same concern as in excel-exporter.ts: importing strToU8 from fflate/browser forces the browser build to be evaluated whenever this module is loaded. If this code ends up in an SSR/server bundle, and fflate/browser relies on browser-only globals at module init, it can break SSR even when Excel export isn’t used. If feasible, gate loading of the browser entry behind an on-demand (cached) dynamic import, or provide a wrapper that can resolve to a server-safe implementation when running under SSR.
| import { strToU8 } from 'fflate/browser'; | |
| import { strToU8 } from 'fflate'; |
The import from


fflatewhen bundled by vitest with Playwright in Angular project causes this issue:regardless of component, as long as
igniteui-angularis present, because this is bunlded like so:That's because by default vitest will include the

nodecondition andbrowserwhen browser mode is on, but fflate exposes that asimportinstead so this is bundled:Note: Can't seem to find a definitive standard on these conditions, this could be resolvable by a fix in the package too.
Alternative:
Tested with the following vitest config:
But none of those worked, possibly not passed down by the angular process.
The only thing that did work was the alias:
Which might need to be documented if this PR doesn't work out - this needs to be evaluated for SSR scenarios.
Additional information (check all that apply):
Checklist:
feature/README.MDupdates for the feature docsREADME.MDCHANGELOG.MDupdates for newly added functionalityng updatemigrations for the breaking changes (migrations guidelines)