-
Notifications
You must be signed in to change notification settings - Fork 77
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: use named "default" export option for CJS build (BREAKING CHANGE) #40
Conversation
Thoughts @TrySound? |
@wmhilton @alexreardon I would move typescript state to less noisy for non-ts projects and just use esModuleInterop flag which fixes the problem perfectly and do not create issues like this one. Sticking on TS legacy makes community very isolated. They had a chance to make |
@TrySound This isn't a TypeScript problem. This is a "your CJS module implements a totally different API than your ES module". |
It makes it very difficult to write isomorphic code that works seamlessly in both Node and Webpack and Jest. |
esModuleInterop simplifies everything. |
Rollup is semantically right here. TypeScript forces doubtful decision by default. |
Eh. Then let's close this PR and add update the README with TypeScript instructions so fools like me don't keep making the same mistakes that drive everyone towards #37 Because it does appear that this magic |
I am happy to defer to @TrySound here. I think the best path forward for now is to add the |
@TrySound are we merging this one, or just updating the docs? |
I'm all for docs. We should enforce community with safer usage. Not necessary config less. |
Given your familiarity with the problem space, could you create a PR @TrySound with a short note about |
This PR bring the CJS and ESM modules into alignment, so that
import memoize from 'memoize'
works correctly whether in TypeScript, Jest, or Webpack. It does this by modifying the CJS module to have an export named "default", which is literally how ESM default exports work.Fixes #37
BREAKING CHANGE: Node users will have to use
var memoize = require('memoize').default
from now on.