gigobyte / purify

Functional programming library for TypeScript - https://gigobyte.github.io/purify/
ISC License
1.5k stars 57 forks source link

Release 2.0.2 breaks esm build for packages with "type": "module" in their package.json #683

Closed OmarMAttia7 closed 6 months ago

OmarMAttia7 commented 6 months ago

Hello, thank you for your work on maintaining this library. The latest release (2.0.2) seems to break the ESM build, I got the following error when I tried to use it with pnpm, SvelteKit 2, and Vite 5:

ReferenceError: exports is not defined in ES module scope
This file is being treated as an ES module because it has a '.js' file extension and '/path/to/project/node_modules/.pnpm/purify-ts@2.0.2/node_modules/purify-ts/esm/package.json' contains "type": "module".
To treat it as a CommonJS script, rename it to use the '.cjs' file extension.

I tried setting up a minimal reproduction in an empty repository with only typescript@5.3.3 and purify-ts@2.0.2 in it, it gave the following error when importing Maybe:

SyntaxError: The requested module 'purify-ts' does not provide an export named 'Maybe'

Removing "type": "module" from package.json or reverting to purify-ts@2.0.1 seems to fix the problem.

gigobyte commented 6 months ago

Must've happened after updating TS to 5.2

gigobyte commented 6 months ago

Can you please try with version 2.0.3-beta.0 and confirm that everything is alright? The tool I'm using is saying no problems found


purify-ts v2.0.3-beta.0

Build tools:
- typescript@5.3.3     

 No problems found 🌟  

┌───────────────────┬─────────────┬───────────────┐
│                   │ "purify-ts" │ "purify-ts/*" │
├───────────────────┼─────────────┼───────────────┤
│ node10            │ 🟢           │ (wildcard)    │
├───────────────────┼─────────────┼───────────────┤
│ node16 (from CJS) │ 🟢 (CJS)     │ (wildcard)    │
├───────────────────┼─────────────┼───────────────┤
│ node16 (from ESM) │ 🟢 (ESM)     │ (wildcard)    │
├───────────────────┼─────────────┼───────────────┤
│ bundler           │ 🟢           │ (wildcard)    │
└───────────────────┴─────────────┴───────────────┘
OmarMAttia7 commented 6 months ago

Yes, version 2.0.3-beta.0 is working correctly 👍.

gigobyte commented 6 months ago

Alright, published 2.0.3