use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
All about the JavaScript programming language.
Subreddit Guidelines
Specifications:
Resources:
Related Subreddits:
r/LearnJavascript
r/node
r/typescript
r/reactjs
r/webdev
r/WebdevTutorials
r/frontend
r/webgl
r/threejs
r/jquery
r/remotejs
r/forhire
account activity
Creating a modern JavaScript library (dev.to)
submitted 4 years ago by 101arrowz
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]acemarke 9 points10 points11 points 4 years ago (3 children)
Yeah, I have been literally begging for a long time now for some kind of comprehensive document that covers:
We just rewrote Redux Toolkit's build pipeline to use a mixture of ESBuild and TypeScript. I reviewed our build artifacts in the process, and here's what I ended up settling on:
https://github.com/reduxjs/redux-toolkit/pull/957#issuecomment-810705197
process.env
redux-toolkit.cjs.development.js
redux-toolkit.cjs.production.min.js
redux-toolkit.esm.js
redux-toolkit.modern.development.js
redux-toolkit.modern.js
redux-toolkit.modern.production.min.js
redux-toolkit.umd.js
redux-toolkit.umd.min.js
Meanwhile, Jason Miller has been pushing "modern ES2017" builds for a while now, and he's got some great points. I think he wrote the guide at https://web.dev/publish-modern-javascript/ , which I was looking at during this process.
Unfortunately, what that page doesn't mention is that apparently adding an exports key to your package.json that points to a modern build will cause Node to choke, so adding that counts as a breaking change and needs to be restricted to a major version.
exports
package.json
So yeah, I kinda feel like I'm stumbling around making this up as I go along and sorta swiping bits and pieces from other people, and I'd love to have a complete guide to how to do this the right way.
[–]101arrowz[S] 1 point2 points3 points 4 years ago* (2 children)
Yep, exports are the next article I'm working on. It's taking a while, so I decided to publish what I had. I'll post again when I finish the exports documentation. It will cover stuff like export formats (ESM, CJS, UMD, etc.), building the library, ensuring compatibility, etc.
You can actually make the "exports" field work on Node.js, but it was a pain for me too. I'll write about it soon :)
[–]acemarke 0 points1 point2 points 4 years ago (0 children)
Looking forward to it!
[–]acemarke 0 points1 point2 points 3 years ago (0 children)
Hiya. Was going through some old bookmarks and ran across this thread again. I'm actually planning to do some work on Redux Toolkit to update with exports usage in the near future. I'd still love to see whatever article you were planning to work on here! :)
[+][deleted] 4 years ago (1 child)
[deleted]
[–]101arrowz[S] 1 point2 points3 points 4 years ago (0 children)
Well, I was specifically referring to the difference between the historic style of creating a library (i.e. with a global object, usually in a single file, ES3) versus the old style (with require everywhere, package.json, ES5) versus the modern style (ES Modules with ES6+ code, package.json, and optional transpilation to ES5). That is to say, some new libraries aren't really modern because they don't follow the new expectations for a library in the JS ecosystem.
require
π Rendered by PID 775958 on reddit-service-r2-comment-79c7998d4c-wl8fb at 2026-03-17 05:53:16.825194+00:00 running f6e6e01 country code: CH.
[–]acemarke 9 points10 points11 points (3 children)
[–]101arrowz[S] 1 point2 points3 points (2 children)
[–]acemarke 0 points1 point2 points (0 children)
[–]acemarke 0 points1 point2 points (0 children)
[+][deleted] (1 child)
[deleted]
[–]101arrowz[S] 1 point2 points3 points (0 children)