-
Notifications
You must be signed in to change notification settings - Fork 901
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
Specify namespace with url in ESM #948
Labels
change-minor
This proposes or provides a change that requires a minor release
feature
This proposes or provides a feature or enhancement
Milestone
Comments
A workaround you can use is createRequire import { createRequire } from 'node:module';
const newRequire = createRequire(import.meta.url);
const debug('namespace'); |
This actually isn't the worst idea. To be completely honest I didn't know this was possible. Right now the V5 roadmap is blocked (still) on some Node things, but it'd be nice to have this eventually. |
Qix-
added
feature
This proposes or provides a feature or enhancement
change-minor
This proposes or provides a change that requires a minor release
labels
Nov 1, 2023
@Qix- Cool, I'll try to file a PR for this soon |
@sebamarynissen you could do this in one line: const debug = (await import("debug")).default("namespace"); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
change-minor
This proposes or provides a change that requires a minor release
feature
This proposes or provides a feature or enhancement
When using native esm in Node, it's not possible anymore to use the pattern
and we have to do
instead. In one of my projects, I've found myself to use an alternative approach though, where I do something like
so that it becomes possible to do stuff like
I was wondering whether it would be useful to have this functionality in the library itself. I'd be happy to clean my code up a bit and file a PR for this. An alternative approach would be to create my own npm module on top of the debug module if it's not desirable to have this in the library itself.
For the syntax, I was thinking about something like
where
debug/url
can become an exports in the package.json.The url approach can be used to add more functionality as well, for example to force a specific color or something:
I'd love to hear some thoughts about this from the maintainers.
The text was updated successfully, but these errors were encountered: