Repository navigation
RDE-1.20: react-data-export/legacy, the 0.x components on 1.0 (deprecated) - #203
Merged
Merged
Conversation
A separate entry with <ExcelFile>, <ExcelSheet>, <ExcelColumn>, the 0.x
default export (ReactExport.ExcelFile.ExcelSheet ...), the dataSet shape
with xSteps/ySteps and xlsx-style styles. It is a thin layer: sheets come
from javascript-excel's fromDataset/fromDatasets, and writing and
downloading go through the 1.0 path (startExport, writeAndSave, the
shared runner), so StrictMode, abort and CSV behave as in 1.0.
Output reproduces 0.6.0: plain <ExcelColumn> headers, bold dataSet
headers replaced by a column style, { wpx: 80 } widths applied from
column A (last block wins), xSteps/ySteps placement, UTC dates with
format 14, 0.6's empty-value rules, "Download" and an always-appended
extension, and the <span> trigger wrapper. Golden tests compare each
scenario cell by cell with what the real react-data-export@0.6.0 built
(scripts/legacy-goldens.mjs). Fixed on purpose: one download under
StrictMode, real CSV for 'csv', xlsx with an .xlsx name and a warning
for xls/txt/html, string dataSet headers keep their text (a 0.6.0
regression), falsy children skipped, invalid sheet names sanitized.
Deprecated: one development warning pointing to docs/migration.md;
supported for all of 1.x, removed in 2.0. convertLegacyStyle moves from
the migration example into the entry. The smoke test checks that the
main entry and its chunks contain no legacy code; attw now checks the
node16 profile (node10 can't resolve subpath exports). Docs: README and
migration.md §1.1 "Quick path", api.md §2. Minor changeset.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
RDE-1.20:
react-data-export/legacy, a deprecated quick path that runs 0.x code on 1.0 with one import change:ExcelFile,ExcelSheet,ExcelColumn, the 0.x default export (withExcelFile.ExcelSheet/ExcelFile.ExcelColumn), the 0.x types (ExcelSheetData,ExcelCell,ExcelStyle, …) andconvertLegacyStyle. It accepts thedataSetshape (xSteps/ySteps,columns,data) and xlsx-style styles (font.sz,fill.fgColor.rgb, …).fromDataset/fromDatasets. Writing and downloading reuse the 1.0 path (startExport,writeAndSave, the shared export runner,runForTrigger), so StrictMode, abort and CSV behave exactly as in 1.0. No engine logic is duplicated.convertLegacyStylemoves from the migration example into the entry, so there's one implementation; the example now imports it.docs/migration.md. It's supported for all of 1.x and removed in 2.0. Types and"use client"are included.Output reproduces 0.6.0, checked against the real 0.6.0
scripts/legacy-goldens.mjsruns react-data-export@0.6.0's own sheet-building code (ExcelFile#createSheetData+excelSheetFromAoA/excelSheetFromDataSet, and its file-name logic, exactly asdownload()used them before tempa-xlsx) on the scenarios intest/legacy/scenarios.mjs. It writestest/legacy/goldens-0.6.json("generatedFrom": "react-data-export@0.6.0").test/legacy/goldens.test.tsexports each scenario through/legacy, reads the file back withjavascript-excel/read, and compares every 0.6 cell: position, type, value, date serial and format, and style. It checks that there are no extra cells, compares column widths and the file name, and lists the differences explicitly.Behaviours reproduced (the
docs/migration.md§4 list, each covered):/legacy<ExcelColumn>headers plain (not bold)columns-basic,columns-functions,sheets-mixeddataSetheaders bold; a column'sstylereplaces the bolddataset-stylesdataSetobject columns{ wpx: 80 }unless set;<ExcelColumn>no widthsdataset-styles,sheets-mixedcolProps)dataset-blocksxSteps/yStepsplacement (ySteps before the first block too); emptycolumns: []takes a header rowfromDatasetsoffsets)dataset-blocksdateZone: 'utc')Dategives 0.6's serial)undefined/NaN→ empty text cell,null→ no cell, numeric strings stay textcolumns-basicDownload, extension always appended (report.xlsx→report.xlsx.xlsx);fileExtension: ''takes it from the namecolumns-basic,columns-functions,filename-from-name<span onClick>aroundelement, default<button>Download</button>innerHTML)dataas a function; an emptydataSetfalls back todata+ columnscolumns-functions,sheets-mixedThe tests can fail. I mutation-checked them: bold
<ExcelColumn>headers fail 4 scenarios, and 81 px default widths fail 2. The tree-shaking guard (below) fails on a legacy export added to the main entry.0.6 bugs that stay fixed (deliberate differences)
hideElementdownloads once under StrictMode, after mount; 0.6 downloaded in the constructor. Tested for xlsx and CSV.fileExtension: 'csv'writes real CSV (UTF-8 BOM, CRLF, injection guard). With several sheets it writes the first one, with a dev warning.'xls','txt','html'write an xlsx file with an.xlsxname, plus a dev warning. 0.6 wrote xlsx bytes under the other extension.dataSetcolumns (columns: ['Name', 'Dept'], as in the 0.x README) keep their header text. 0.6.0 left them empty: a regression in its last release (commit 855d37a, "if the header has style then the style should be used"); 0.5 wrote the text. This is the one listed difference in the golden test.<ExcelSheet>/<ExcelColumn>children are skipped (conditionally hide a ExcelColumn from display #155, Unable to Add Condition on <ExcelSheet> for condition base export of sheet tab #160), and an invalid sheet name is sanitized with a dev warning instead of producing a broken file.{ value: Date }cell is written as a date. 0.6 wrote it as text.Packaging
./legacy(import→dist/legacy.js+.d.ts,require→dist/legacy.cjs+.d.cts), and a second tsdown entry.output.exports: 'named'is explicit: CJS gets{ default, ExcelFile, … }, which is what bundlers and esModuleInterop expect.dist/index.js/.cjsand every chunk they import. It fails if any containsExcelFile/ExcelSheet/ExcelColumn/xSteps/convertLegacyStyle, or reachesdist/legacy.*. Result:dist/index.js: 2 file(s), no legacy code."use client"is the first statement of all four entry files (smoke-checked).--profile node16: node16 CJS/ESM and bundler, all 🟢 for both entries. node10 (moduleResolution: node) can't resolve any subpath export and isn't a supported mode (TS 5.0+ with node16/nodenext/bundler). The same holds for javascript-excel's subpaths.Docs
docs/migration.md§1.1 "Quick path:react-data-export/legacy", with no renumbering:examples/migration/legacy-quick-path.tsx)convertLegacyStyle/legacykeepsapi.md§2 gets one row.Verification (local, Node 26.13.1 via nvm)
npm ci;docs:check(11 example blocks match); typecheck (library + playground + docs examples) passes.test:release53/53.directive okesm ok … export.xlsxdist/index.js: 2 file(s), no legacy codelegacy esm ok,legacy cjs oktypes ok@types/react18/19 × node16/nodenext/bundler). The fixture uses the 0.x default import, JSX withExcelFile/ExcelSheet/ExcelColumn/ExcelFile.ExcelSheet, typedExcelSheetData/LegacyStyleandconvertLegacyStyle(.tsxand.cts), plus a probe that<ExcelColumn>requireslabel.Regenerating the goldens