feat(98_esmxport): add esm default export #2771

Merged
wkstudy merged 1 commits from feature-addesmdefaultexport into master 2022-08-17 18:04:21 +00:00
wkstudy commented 2022-08-17 13:19:10 +00:00 (Migrated from github.com)

Recently I upgraded the xlsx version of the project from 0.15.6=>0.18.5, which caused the project to report an error, and I found that the previous project used the following syntax

import xlsx from 'xlsx';
...
xlsx.read(...)
...

This upgrade causes the failure to feel still not very good, should you consider adding a default export?
Thanks for the answer

Recently I upgraded the xlsx version of the project from 0.15.6=>0.18.5, which caused the project to report an error, and I found that the previous project used the following syntax ``` import xlsx from 'xlsx'; ... xlsx.read(...) ... ``` This upgrade causes the failure to feel still not very good, should you consider adding a default export? Thanks for the answer
danger2520 (Migrated from github.com) approved these changes 2022-08-17 17:34:05 +00:00
SheetJSDev commented 2022-08-17 18:01:43 +00:00 (Migrated from github.com)

There's one upgrade caveat that needs to be noted: https://docs.sheetjs.com/docs/getting-started/installation/frameworks#xls-support

The CJS build includes the codepage dependency. This worked in the past when the library only shipped with the NodeJS and browser standalone builds. Webpack and other bundlers used the browser build without question.

ESM is a messy ecosystem. Thanks to incompatibilities between Node ESM / Browser ESM / Deno ESM / "Bundler" ESM, there was no universal way to import the codepage library from the main script.

The uniform solution is to invert the flow. The ESM builds do not import any dependencies by default, and you now must manually import the codepage tables for XLS support:

import * as xlsx from "xlsx";
import * as cptable from 'xlsx/dist/cpexcel.full.mjs';
xlsx.set_cptable(cptable);
There's one upgrade caveat that needs to be noted: https://docs.sheetjs.com/docs/getting-started/installation/frameworks#xls-support The CJS build includes the codepage dependency. This worked in the past when the library only shipped with the NodeJS and browser standalone builds. Webpack and other bundlers used the browser build without question. ESM is a messy ecosystem. Thanks to incompatibilities between Node ESM / Browser ESM / Deno ESM / "Bundler" ESM, there was no universal way to import the codepage library from the main script. The uniform solution is to invert the flow. The ESM builds do not import any dependencies by default, and you now must manually import the codepage tables for XLS support: ```js import * as xlsx from "xlsx"; import * as cptable from 'xlsx/dist/cpexcel.full.mjs'; xlsx.set_cptable(cptable); ```
Sign in to join this conversation.
No description provided.