Open amoshydra opened 6 months ago
With the new understanding that tests and examples are suppose to run on transpiled code. I have updated the approach to do thing differently.
output.preserveModules: true
Because the tests still imports round.mjs
and rational.mjs
, in the new commit, I have used the output.preserveModules
flag to keep the module structure.
Usage of preserveModules require us to output the build files into their own folder. In this PR, I have choose to output esm and cjs to their respective folder accordingly.
dist
├── common.d.mts
├── decimal128.cjs
├── decimal128.cjs.map
├── decimal128.d.mts
├── decimal128.mjs
├── decimal128.mjs.map
└── rational.d.mts
dist
├── cjs
│ ├── common.cjs
│ ├── common.cjs.map
│ ├── common.d.mts
│ ├── decimal128.cjs
│ ├── decimal128.cjs.map
│ ├── decimal128.d.mts
│ ├── rational.cjs
│ ├── rational.cjs.map
│ └── rational.d.mts
└── esm
├── common.d.mts
├── common.mjs
├── common.mjs.map
├── decimal128.d.mts
├── decimal128.mjs
├── decimal128.mjs.map
├── rational.d.mts
├── rational.mjs
└── rational.mjs.map
Notice rational
and common
are kept as its own module
Tests and coverage can now run like how it previously was
Workflow file has been update to include npm run build
command:
https://github.com/jessealama/decimal128/commit/759f5b7910d6d46982e1f8a329a2fd7ef9b91a1a#diff-1790f2f8b7123d50d46235053b54f1cc5996bc7388b803aad4233fd5582e0bad
- run: npx tsc
+ run: npm run build && npx tsc
Thanks so much for your interest in this!
Could you please rebase on the newly changed main branch?
sure! rebased onto cf135fdfe77ef7d61cbdbf846191f9ab826ddbc6 @ https://github.com/jessealama/decimal128/pull/93#event-12426158633
Edit 1: Updated base on commit 759f5b7
Summary
⚠ BREAKING CHANGE: distribution layout has been significantly changed
Support both
cjs
andmjs
output using rollup.The package.json now includes the modern
exports
field and the legacymain
,modules
andtypings
fields to ensure compatibiilty with older Node runtime / bundlerRelated to
Related to #61
Motivation
To resolve #61
How is this tested
Fixtures for the different environments
I have created a repository hosting the 4 test environments below here: https://github.com/amoshydra/repro-jessealama-decimal128/tree/ref-759f5b791
Layout change in npm package
This layout change does not really affect the consumer using a bundler, TypeScript or NodeJS as they will continue to import the package via one of the following ways:
Before
Files are exported from
src
After
Files are exported from
dist