Skip to content
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

Convert to named export and add native esm support #86

Closed
wants to merge 1 commit into from

Conversation

TrySound
Copy link
Contributor

@TrySound TrySound commented Apr 7, 2020

References
#37
https://github.com/rollup/rollup/blob/master/build-plugins/emit-module-package-file.js
https://unpkg.com/nanoevents@5.1.5/package.json

Node supports unflagged esm since v13. In this diff I changed default
import to memoizeOne named one.

import { memoizeOne } from 'memoize-one';
const { memoizeOne } = require('memoize-one');
const { memoizeOne } = window.memoizeOne;

The main reason is TS support without fighting with default commonjs/esm
interop which forces to import a function as a namespace.

import * as memoizeOne from 'memoize-one';

This is incorrect. Module namespace is an object due spec.

Libraries like nanoevents and nanoid ended with named export aswell.
See details here ai/nanoid#128

Also I simplified generated bundles to one umd and one esm because project does not have dependencies and process.env.NODE_ENV usages.

References
alexreardon#37
https://github.com/rollup/rollup/blob/master/build-plugins/emit-module-package-file.js
https://unpkg.com/nanoevents@5.1.5/package.json

Node supports unflagged esm since v13. In this diff I changed default
import to memoizeOne named one.

```
import { memoizeOne } from 'memoize-one';
const { memoizeOne } = require('memoize-one');
const { memoizeOne } = window.memoizeOne;
```

The main reason is TS support without fighting with default commonjs/esm
interop which forces to import a function as a namespace.

```
import * as memoizeOne from 'memoize-one';
```

This is incorrect. Module namespace is an object due spec.

Libraries like nanoevents and nanoid ended with named export aswell.
See details here ai/nanoid#128
@theKashey
Copy link
Contributor

A breaking change :(

@TrySound
Copy link
Contributor Author

TrySound commented Apr 8, 2020

Or inconsistent usage

@alexreardon
Copy link
Owner

I am not sure what to do with this one. Open to advice!

@TrySound
Copy link
Contributor Author

Major release won't break anybody. See here's big migration guide
https://github.com/ai/nanoid/releases/tag/3.0.0

@theKashey
Copy link
Contributor

Well, @alexreardon, what about bumping major version and realising a simple codeshift(or what we are using nowadays) to make migration a joy?

@alexreardon
Copy link
Owner

Is this still needed @TrySound ?

@TrySound
Copy link
Contributor Author

Maybe node es modules support but it will require major bump.

@alexreardon
Copy link
Owner

Named import is now supported

// default export
export default memoizeOne;
// named export
export { memoizeOne };

Any esm support stuff still needed?

(i'll reopen if so)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants