GithubHelp home page GithubHelp logo

Comments (9)

Qix- avatar Qix- commented on May 5, 2024 2

Bundling for the desktop is valid, especially in end-user applications. I'd be 👍 for this if @sindresorhus also agreed and if someone did a PR.

from ansi-escapes.

Qix- avatar Qix- commented on May 5, 2024 2

For those users we'd just rec using import * as ansiEscapes from 'ansi-escapes'. I would imagine in some cases the bundler would still be able to do DCR even then.

from ansi-escapes.

fisker avatar fisker commented on May 5, 2024 1

I need to bundle this package, and I only want use clearScreen.

from ansi-escapes.

sindresorhus avatar sindresorhus commented on May 5, 2024

I don't see how that matters in this case as it's for Node.js, not browsers.

from ansi-escapes.

sindresorhus avatar sindresorhus commented on May 5, 2024

I'm neutral about it. Many of the exports have too general names when imported without the namespace though. ansiEscapes.image() makes it clear what it is, but image() could be anything.

from ansi-escapes.

sindresorhus avatar sindresorhus commented on May 5, 2024

@Qix- It's not just image(). It applies to most of the exports.

from ansi-escapes.

Qix- avatar Qix- commented on May 5, 2024

I don't see how that negates what I said though. You can still import as a namespace. It's up to users to use proper naming. If they just want to import image then they should import { image as ansiImage } from 'ansi-escapes' if they want it to be clean.

My point was more that even using a wildcard import (import * as ansiEscapes) might still allow the bundlers/compilers to do dead code removal ("tree shaking" as the JS community seems to call it) even though it's done via indirection.

from ansi-escapes.

privatenumber avatar privatenumber commented on May 5, 2024

@sindresorhus Would you be open to a PR?

I think the argument for export names not being self-descriptive without the context of the package name applies to most ESM packages, including native ones:

// both `access` and `constants` are very vague without knowing it comes from `fs`
import { access, constants } from 'node:fs/promises';

from ansi-escapes.

sindresorhus avatar sindresorhus commented on May 5, 2024

Would you be open to a PR?

Yes, but it should preserve the default export too (can be done with re-exporting). Most users don't care about tree-shaking this, so the main docs should remain the default export too. It can be a tip mention in the docs that this can also be imported using named imports.

I think the argument for export names not being self-descriptive without the context of the package name applies to most ESM packages, including native ones:

Node.js APIs are not very good, so I wouldn't use that as an example of great API design.

from ansi-escapes.

Related Issues (17)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.