Comments (9)
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.
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.
I need to bundle this package, and I only want use clearScreen
.
from ansi-escapes.
I don't see how that matters in this case as it's for Node.js, not browsers.
from ansi-escapes.
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.
@Qix- It's not just image()
. It applies to most of the exports.
from ansi-escapes.
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.
@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.
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)
- Make cursor position a little more cross platform HOT 17
- More escapes! fun! HOT 1
- checksum error at yarn install HOT 1
- Save/Restore cursor position not working on macOS Terminal.app
- link error HOT 1
- Support tmux passing escapes through tmux HOT 2
- `clearTerminal` not working on Windows 10 w/ GitBash HOT 2
- Get x, y from the result of cursorGetPosition HOT 7
- clearScreen performs a full reset on some terminals HOT 7
- V5 Update error HOT 1
- Type-fest TS errors when updating to tsc 4.8 HOT 3
- require() of ES modules is not supported. HOT 1
- Escapes for entering/exiting alternate screen HOT 1
- Exports CJS
- Failing to compile correctly when built under Vite?
- Add ConEmu-specific escape codes HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ansi-escapes.