[0.18.2] Module not found: Error: Can't resolve './dist/cpexcel.js' #2530
Labels
No Label
DBF
Dates
Defined Names
Features
Formula
HTML
Images
Infrastructure
Integration
International
ODS
Operations
Performance
PivotTables
Pro
Protection
Read Bug
SSF
SYLK
Style
Write Bug
good first issue
No Milestone
No Assignees
1 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: sheetjs/sheetjs#2530
Loading…
Reference in New Issue
Block a user
No description provided.
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
I added alias in my webpack configuration to reduce bundle size.
After upgrade from 0.17 to 0.18.2, it shows the following error:
Module not found: Error: Can't resolve './dist/cpexcel.js' in 'D:\project\node_modules\xlsx\dist'
I've removed the alias to try tree shaking mentioned by docs. But it seems that the bundle size increases a lot.
Here is the bundle size when I use xlsx.mini.min v0.17:
After I upgrade to v0.18.2:
Here is how I import xlsx:
Then I tried the following alias:
The bundle becomes even larger:
What is the right way to reduce bundle size in current version? Many thanks for any help!
It seems that this package does not include the
sideEffects
property mentioned by webpack docs, which is required to enable tree shaking.The mini build is not exactly equivalent to the ESM build after tree-shaking.
For example, XLSB read support is always omitted in the mini build but will be included if you import
read
orreadFile
with the ESM build. In theory the parser could be split up into separate modules with dynamicimport
, but until then the ESM build pulls in all read codecs ifread
is imported.Note: For writing,
writeFileXLSX
andwriteXLSX
is specific to theXLSX
format, which helps avoid pulling in the other write codecs..
That said, we should update the docs for the other build systems. Are you using Webpack directly or through something like create-react-app?
I've tried
import { read, utils, writeFileXLSX } from 'xlsx'
then
import { read, utils, writeFile } from 'xlsx'
However, the bundle size did not change (which should augment if tree shaking works).
I'm using webpack5 through vue-cli5.
My bad, I've compared wrong report files. It does augment the parsed size by 50KB, which means tree shaking works. But still much larger than mini.min version. Hopes 'module not found' error of mini.min version can be fixed. Thanks for your reply.
The mini build issue is the same as #2526