perry-mitchell / ulidx

ULID generator for NodeJS and the browser
MIT License
281 stars 17 forks source link

ESM #18

Closed perry-mitchell closed 1 year ago

perry-mitchell commented 1 year ago

Upgrades the library to ESM.

Closes #7

bluet commented 1 year ago

I'm not sure if this info helps:

I use rollup in some of my projects for building to both cjs and esm. Some sample code in package.json

    "rollup-node": "rollup handler.js --format cjs --file bundle.cjs --environment NODE_ENV:production",
    "rollup:cjs": "rollup -c --environment FORMAT:cjs",
    "rollup:esm": "rollup -c --environment FORMAT:esm",
perry-mitchell commented 1 year ago

I've built a few ESM+CJS projects recently and they just never seem to work properly from the CJS side. Named imports via Typescript builds done in Webpack etc. don't seem to work properly after switching the base to ESM.

That, and you only really have one type in the package JSON definition: CJS or ESM (module). I don't think dual build libraries are a clean solution and would prefer to just publish ESM, as this is where the community is heading anyhow.

perry-mitchell commented 1 year ago

Thanks @bluet - I used your rollup suggestion and it helped a lot. Merging now.

perry-mitchell commented 1 year ago

Released 1.0.0-r1 pre-release.