-
Notifications
You must be signed in to change notification settings - Fork 944
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
Use ESModules instead of module.exports (#786) #852
Conversation
This package is going to be rewritten in the next version, so there's not much I can do with this PR as it stands. Thank you for taking the time, however! |
Cool, I hope it will be released soon! |
@Konakona-chan thanks for your work <3
in node.js line 118 export const inspectOpts = Object.keys(process.env).filter(key => { this happens in browser, so node.js should not be loaded ... debug is used here
possible solutions nope-import createDebug from 'debug'
+import createDebug from 'debug/src/browser.js' ... or -import createDebug from 'debug'
+import createDebug from 'debug/browser' ... or in debug/index.js, use dynamic import like const createDebug = isBrowser
? (await import('./browser.js'))
: (await import('./node.js'))
;
export default createDebug; debug/package.json "exports": {
".": {
"import": {
"browser": "./src/browser.js",
"default": "./src/index.js"
}
},
"./package.json": "./package.json"
}, per npm docs should be "exports": {
".": {
"import": {
"node": "./src/node.js",
"default": "./src/browser.js"
}
},
"./package.json": "./package.json"
}, works with rollup : ) fixed in https://github.com/milahu/debug/commits/patch-1 install with
to clarify, this is an actual working ESM version of the NPM → no need to wait for
|
@milahu , I was able to overcome the issue with Svelte+Vite and unified (esm-only) -> markdown -> debug (cjs-only) with |
Please resubmit this. Deno and UNPKG with ?module are broken because of this. |
Hello there.
As for 2021, NodeJS versions <12 without ESM support (are deprecated)[https://nodejs.org/en/about/releases/].
This PR switches
debug
package from CJS to ESM version, so it can be used in modern applications based on asynchronous execution.Resolves #786.
Implementation notes:
debug.destroy()
function according to deprecation notice (notably, it updatesms
to canary version from ESM version vercel/ms#159)import
statement; howeverrequire(...)
should be replaced toimport
as described inREADME.md