Skip to content

Require Node.js 12.20 and move to ESM#181

Merged
sindresorhus merged 4 commits intosindresorhus:mainfrom
antongolub-forks:move-to-esm
Jul 22, 2021
Merged

Require Node.js 12.20 and move to ESM#181
sindresorhus merged 4 commits intosindresorhus:mainfrom
antongolub-forks:move-to-esm

Conversation

@antongolub
Copy link
Copy Markdown
Contributor

@antongolub antongolub commented Jul 16, 2021

  • add named exports
  • update all deps to the latest versions
  • add Node.js v16 to test matrix
  • apply xo --fix
  • BREAKING CHANGE: require Node.js >= 12.20
  • BREAKING CHANGE: drop default exports, remove all globby.* methods

BREAKING CHANGE: require Node.js >= 12.20
@sindresorhus
Copy link
Copy Markdown
Owner

sindresorhus commented Jul 17, 2021

Thanks for working on this.

You need to update index.d.ts (https://github.com/sindresorhus/typescript-definition-style-guide) and the readme for ESM too.

Comment thread gitignore.js Outdated
Comment thread gitignore.js Outdated
Comment thread index.js
};

module.exports = async (patterns, options) => {
export const globby = async (patterns, options) => {
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think there should be the following named exports:

  • globbyAsync
  • globbySync
  • globbyStream

Copy link
Copy Markdown
Contributor Author

@antongolub antongolub Jul 17, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok. But let's save globby as globbyAsync alias.

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I disagree. Aliases cause confusion.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe just globby and globbySync?

Comment thread index.js Outdated
Comment thread index.js Outdated
Comment thread index.js Outdated
Comment thread index.js Outdated
BREAKING CHANGES: legacy cjs API was completely removed
Comment thread bench.js Outdated
@antongolub
Copy link
Copy Markdown
Contributor Author

rfr

@sindresorhus
Copy link
Copy Markdown
Owner

I can never decide how to handle named exports with async and sync methods:

  • globby and globbySync
  • globbyAsync and globbySync

The former looks nicer, but the latter is clearer. Any opinion?

@antongolub
Copy link
Copy Markdown
Contributor Author

My guess is that for most users, the migration will look like this:
const globby = require('globby') → import {globbyAsync as globby} from 'globby'.
Well... I'd prefer just import {globby} from 'globby' instead.

@sindresorhus
Copy link
Copy Markdown
Owner

Alright. Let's go with globby for async and drop globbyAsync.

@antongolub
Copy link
Copy Markdown
Contributor Author

@sindresorhus, your turn

@sindresorhus sindresorhus changed the title feat: move to esm Require Node.js 12.20 and move to ESM Jul 22, 2021
@sindresorhus sindresorhus merged commit 5c32b4a into sindresorhus:main Jul 22, 2021
@antongolub antongolub deleted the move-to-esm branch July 22, 2021 10:12
@zloirock
Copy link
Copy Markdown

@sindresorhus sorry, why do you avoid the default export here?

@fisker
Copy link
Copy Markdown
Collaborator

fisker commented Jul 23, 2021

I guess for consistency import? But I think maybe we can export both named and default? export {globby as default, globby}

@sindresorhus
Copy link
Copy Markdown
Owner

It's weird to have one default and one named when there are two main exports. I only do default and named export mix when there's only one main export and some secondary exports (like error, or helper utilities).

@sindresorhus
Copy link
Copy Markdown
Owner

But I think maybe we can export both named and default? export {globby as default, globby}

No, there should be only one way to import the thing. Aliases create confusion and inconsistency.

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.

4 participants