Skip to content

feat: esm and cjs builds for node and browser#81

Merged
diegomura merged 11 commits intomasterfrom
dm/browser-bundle
Apr 14, 2026
Merged

feat: esm and cjs builds for node and browser#81
diegomura merged 11 commits intomasterfrom
dm/browser-bundle

Conversation

@diegomura
Copy link
Copy Markdown
Contributor

Hi @devongovett ! Hope you are doing good.

I'd like to start using foliojs packages again in react-pdf. I gradually moved away from them due to several reasons, among them because node deps in foliojs repos. This includes pdfkit and png-js.

Here's my fork. This is the same node entrypoint here but bundled with rollup to generate node and browser entrypoints. Node ones are just like the existing ones. For browser though, we remove fs dependency and ignore methods that use it, and replace zlib with browserify-zlib.

Not sure who's responsible of reviewing and publishing (I have merge rights here, but not publishing to npm) but this first step would be very helpful towards start unifying foliojs with react-pdf 😄

@diegomura diegomura self-assigned this Feb 7, 2024
Comment thread package.json
@diegomura diegomura changed the title feat: move node file to src dir feat: esm and cjs builds for node and browser Feb 9, 2024
Comment thread package.json Outdated
"import": "./lib/png-js.js",
"require": "./lib/png-js.cjs"
},
"default": "./lib/png-js.browser.js"
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will this need a "browser" path? If I understood node docs correctly node takes precedence over default, but it also mentions community conditions definitions which I guess are supported but not part of the standard

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No. Browser takes the default

@diegomura diegomura requested a review from blikblum February 16, 2024 10:15
@diegomura
Copy link
Copy Markdown
Contributor Author

Thanks for the review @blikblum ! when can we expect to have this merged?

@blikblum
Copy link
Copy Markdown
Member

Need one more review

@diegomura
Copy link
Copy Markdown
Contributor Author

diegomura commented Feb 5, 2025

@devongovett @blikblum do you think we can move forward with this? I'd love to remove react-pdf's fork. Would be beneficial for everyone.

@diegomura
Copy link
Copy Markdown
Contributor Author

@blikblum @devongovett who has npm rights for this lib? Can I become a maintainer?

@blikblum
Copy link
Copy Markdown
Member

npm rights for this lib

devongovet

@diegomura
Copy link
Copy Markdown
Contributor Author

@devongovett would be possible to merge and release this please?

Comment thread test/pixels.spec.js Outdated
@@ -1,5 +1,5 @@
const PNGNode = require('../png-node');
const fs = require('fs');
const { default: PNGNode } = require('../lib/png-js.cjs');
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Breaking change?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed cjs build so it's not breaking anymore

@diegomura diegomura requested a review from devongovett April 10, 2026 09:28
@diegomura
Copy link
Copy Markdown
Contributor Author

@devongovett kind ping here :)

@devongovett
Copy link
Copy Markdown
Member

@diegomura I invited you as a maintainer on npm

@diegomura
Copy link
Copy Markdown
Contributor Author

Thanks a lot!

@diegomura diegomura merged commit 0e93aa9 into master Apr 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants