New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[DO NOT MERGE!] Fix language files for Node+ESM #1377
base: develop
Are you sure you want to change the base?
Conversation
Performance comparison of head (0cd4e05) vs base (e32e132)
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tested the dist files in some more popular bundlers and here are the results:
- Vite ^5.1.4 - OK
- Parcel2 ^2.0.0 - Does not support "exports" so the language file has to be imported with
/es/
or/commonjs/
prefixes; - Webpack5 ^5.8.0 - OK
- Webpack4 ^4.42.0 - I getting an error. Seems the webpack has the problem with importing values from "chevrotain".
// /node_modules/hyperformula/es/parser/FormulaParser.mjs
import { EmbeddedActionsParser, EMPTY_ALT, Lexer, tokenMatcher } from 'chevrotain';
// EmbeddedActionsParser, EMPTY_ALT and others are missing
ERROR in ./node_modules/hyperformula/es/parser/FormulaParser.mjs 689:125-137
Can't import the named export 'tokenMatcher' from non EcmaScript module (only default export is available)
@ ./node_modules/hyperformula/es/parser/index.mjs
@ ./node_modules/hyperformula/es/ArraySize.mjs
@ ./node_modules/hyperformula/es/index.mjs
@ ./src/index.js
ERROR in ./node_modules/hyperformula/es/parser/FormulaParser.mjs 708:29-41
Can't import the named export 'tokenMatcher' from non EcmaScript module (only default export is available)
@ ./node_modules/hyperformula/es/parser/index.mjs
@ ./node_modules/hyperformula/es/ArraySize.mjs
@ ./node_modules/hyperformula/es/index.mjs
@ ./src/index.js
I found out that webpack 4 does not support exports, and there seems to be no easy workaround for that. By tweaking the webpack configuration, I managed to make the project import HyperFormula correctly using the legacy paths. Working demo. |
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## develop #1377 +/- ##
========================================
Coverage 97.36% 97.36%
========================================
Files 169 169
Lines 14421 14421
Branches 3021 3021
========================================
Hits 14041 14041
Misses 380 380 |
I have retested all the demos available on https://github.com/handsontable/hyperformula-demos/tree/import-demos plus the bundlers mentioned by @budnix getting the same results. On top of the above I have tested:
|
TODO: verify it with the code example in issue #1143 |
It works correctly. The issue you reported was caused by running the setup code twice. I created a demo for svelte: https://github.com/handsontable/hyperformula-demos/tree/import-demos/import-demo-esm-svelte Angular case is still to be verified. |
Context
.mjs
extensions and adjust the import and export statements in the output (custom babel plugin)exports
property topackage.json
that lists all valid ways of importing HyperFormulaBreaking change
This will be a breaking change for devs that use Webpack 3 or Parcel. They need to adjust their config and/or update the bundler.
TODO
How did you test your changes?
Tested importing HF in scenarios:
mjs
files"moduleResolution": "node16"
intsconfig
)Demo projects are available in the hyperformula-demos repo.
Tested by @budnix:
Types of changes
Related issues:
Fixes #1344
Checklist: