-
Notifications
You must be signed in to change notification settings - Fork 8
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
chore: build project to emit cjs and esm using rollup #93
Conversation
aa01cb5
to
7feb5cd
Compare
rollup.config.mjs
Outdated
typescript({ | ||
tsconfig: "tsconfig.build.json", | ||
outDir: "dist", | ||
sourceMap: false, |
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.
Note to reviewer
Source map is still generated by using rollup's output.sourcemap: true
: https://github.com/jessealama/decimal128/pull/93/files/7feb5cd9d46d29115d1af57986e6a00ad23daeed#diff-47407fecafdf5f5cd55403c3de457833ddf9b6fab45253c04e1dc4c7cb4495b1R8.
This is turned off to prevent conflict with rollup's source map generation
See related stackoverflow post: https://stackoverflow.com/a/63235210
7feb5cd
to
e822f21
Compare
With the new understanding that tests and examples are suppose to run on transpiled code. I have updated the approach to do thing differently.
|
759f5b7
to
be2baa8
Compare
d4c8909
to
02ded6a
Compare
Thanks so much for your interest in this! Could you please rebase on the newly changed main branch? |
sure! rebased onto cf135fd @ #93 (comment) |
d8623a0
to
4cace43
Compare
BREAKING CHANGE: distribution layout has been significantly changed
4cace43
to
69d819d
Compare
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.
Overall it looks good, a few comments inline: also, you might've forgotten to update the .gitignore
"c8": "^9.1.0", | ||
"jest": "^29.5.0", | ||
"jest": "^29.7.0", |
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.
Was updating jest
and ts-jest
necessary in this PR?
"import": "./dist/esm/decimal128.mjs", | ||
"require": "./dist/cjs/decimal128.cjs", |
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.
check out nodejs/node#52174, this pattern is not ideal and we should use the alternative mentioned in the thread.
@@ -0,0 +1,4 @@ | |||
{ | |||
"extends": "./tsconfig.json", | |||
"include": ["./src"] |
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.
Apologies, but I don't quite get this: which files were included so far? And why not just add the include
statement to the original tsconfig?
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.
which files were included so far
In the original tsconfig
, I suppose, all files will be included.
I believe that is fine since the original tsconfig is mainly used by VS Code / ide.
why not just add the include statement to the original tsconfig?
Adding includes to the original tsconfig will prevent tsconfig from being applied to files outside of the src
folder.
My intention here with tsconfig.buid.json
include
is to restrict rollup's typescript compiler include
scope to files within src
folder only
"ts-jest": "^29.1.0", | ||
"rollup": "^4.14.1", | ||
"ts-jest": "^29.1.2", | ||
"tslib": "^2.6.2", |
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 don't see why we need tslib since importHelpers
aren't used?
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.
likely a mistake, PR raised by Jesse in #121 no longer has this
closed via #121 |
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