feat: support web-native streams for read/write methods#2849
feat: support web-native streams for read/write methods#2849lionel-rowe wants to merge 3 commits into
Conversation
| import _ExcelJS from '../../index'; | ||
| import type * as ExcelJSModule from '../../exceljs'; | ||
|
|
||
| const ExcelJS = _ExcelJS as unknown as typeof ExcelJSModule; |
There was a problem hiding this comment.
Type checking wasn't currently being picked up by ts-node due to ../../index resolving to the untyped index files rather than ../../index.d.ts.
It looks like you have a collision in your module resolution.
If you have a file called index.ts, then index.d.ts won't be automatically imported.
TypeScript will automatically import .d.ts files, UNLESS their name collides with other files, where the rules for what files will collide are somewhat described here: https://www.typescriptlang.org/docs/handbook/module-resolution.html .
For that reason, I've renamed index.d.ts to exceljs.d.ts (and updated the corresponding package.json fields etc).
It still needs to be imported in this weird way for the test though. Possibly there's a better fix, but I couldn't figure one out.
| ws.getCell('A1').value = 7; | ||
|
|
||
| const wb2 = new ExcelJS.Workbook(); | ||
| const stream = wb2.xlsx.createInputStream(); |
There was a problem hiding this comment.
This test was previously failing due to removal of createInputStream, so I've overwritten the existing test case rather than adding a new one.
| "test": "npm run test:full", | ||
| "test:es5": "export EXCEL_BUILD=es5 && npm run test:full", | ||
| "test:full": "npm run build && npm run test:unit && npm run test:integration && npm run test:end-to-end && npm run test:jasmine", | ||
| "test:full": "npm run build && npm run test:unit && npm run test:integration && npm run test:end-to-end && npm run test:jasmine && npm run test:typescript", |
There was a problem hiding this comment.
Added TS tests to test:full, which should now work as they no longer contain a failing test case.
Fixes #1228
Fixes #2753
Summary
Add support for
read(<web-native ReadableStream instance>)andwrite(<web-native WritableStream instance>). Both have excellent support in modern browsers and are also implemented in NodeJS, Deno, and Bun.Test plan
See
spec/unit/xlsx/write-writable-stream.spec.jsand changes tospec/typescript/exceljs.spec.ts.Related to source code (for typings update)
N/A (updated typings are reflected in diffs to runtime code + tests).