Comments (8)
There is an UMD fallback now. Let me know if there are any issues :)
from long.js.
That's why it was a major version bump.
Because it has breaking behavior.
from long.js.
I can relate to the frustration surrounding ESM and am open to hear this argument out, though I have to admit that so far I cannot quite follow the reasoning in the OP.
from long.js.
i agree its exactly how semver is supposed to work - major version bump for breaking change
for browsers, esm is definitely the way to go - no doubt
(also for nodejs
typescript projects as tsc will do resolving)
however, i dont see a benefit of esm
for off-the-shelf nodejs
user
(yes, amd
/umd
are old, but need a working alternative, not just deal-with-it)
how to consume esm
in nodejs
?
- standard import require that package is marked as
type=module
which is not always the case - dynamic imports are horrible at best and at worst they completely break type defs and intellicode
- support for
nodejs
below 14 is what? and how many users are still onnodejs
12?
i have 1k users, not 1m and i still get those questions often
perhaps if nodejs
adopted import syntax as standard so we can get away from require completely, i'd be completely for it. but nodejs
is what it is - and we're likely looking at distant future for this
what i do for my library is package both esm
and cjs
versions (and iife
, but thats another story)
- in browser
import * from ...
resolves toesm
version - in nodejs,
const x = require('..')
resolves tocjs
version
also, rules are slightly different when library has small number of users vs +1m like this one has
how many people run npm update --latest
? i know i do. and every time i run into problems because of that, i fix it. but if only esm
is packaged, there is no solution without modifying 3rd party libraries which is not an option
from long.js.
One challenge I am seeing btw. is where the CommonJS module just exports a single class, here Long
. What one basically wants for backwards-compatibility is to retain
const Long = require("long");
with an upgrade path of
import Long from "long";
which isn't exactly compatible, also when it comes to typings. What's the typical attack angle there?
For instance, for the former, typings are export = Long
while for the latter it's export default Long
.
from long.js.
yes, its a challenge, but:
- having both
cjs
andesm
at least gives user options and having justesm
is bad fornodejs
users
e.g. i could handle difference in import signature with packager preprocessing. not ideal, but workable. - old signature for backward compatibility can be achieved by having a separate js file that serves as re-export and is used as entry point when compiling for
cjs
target only
from long.js.
I might me overlooking something, but it seems that if the package is ESM first, then having a CJS re-export is off the table due to the lack of top-level await. Or is there a way?
For reference, here is what I have so far.
from long.js.
Thanks! I agree the Node.js 12 support (EOL May 2022) is the compelling reason to add this; that's how I cam across this.
from long.js.
Related Issues (20)
- Migrate to ESM HOT 1
- Using symbol for isLong HOT 2
- Add default value of unsigned in Long.fromInt to docs
- How to return a uint64? HOT 4
- isPositive returns true for zero
- Is the heigh argument in Long constructor required? HOT 2
- [BUG] this.isZero is not function
- WASM check causes Node 16.1+ crash on ARMv6 HOT 3
- Unable import in TypeScript since v5+ HOT 10
- Add copyright line to licence
- protobuf fromNumber encoding error HOT 2
- Cannot import package using ES modules HOT 1
- Please available on module commonjs
- fromString with a string that isn't an integer behaves weird
- TypeScript errors with moduleResolution nodenext HOT 16
- "./package.json" is not defined by "exports" warning in React Native HOT 2
- For packaging for debian => need source information HOT 6
- Issue when running build on a NodeJS app HOT 4
- Patch
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from long.js.