Closed romainmenke closed 1 year ago
Also I think we can avoid using util-deprecate
, it is just small ternary, less deps = less size
I was able to create a minimal repro of what was changed in nodejs for util.deprecate
.
import util from 'util';
process.throwDeprecation = true;
const obsoleteFunction = util.deprecate(() => {
// Do something here.
}, 'obsoleteFunction() is deprecated. Use newShinyFunction() instead.');
try {
obsoleteFunction();
} catch (err) {
// node12
console.log('caught');
}
In node12 the try / catch
just works.
In later versions it doesn't.
I was able to work around this by not throwing on deprecations and listening via another method :
function waitForWarning() {
return new Promise((resolve) => {
process.once('warning', (err) => {
resolve(err);
});
});
}
Also I think we can avoid using util-deprecate, it is just small ternary, less deps = less size
Is it possible this was added for when the package is used in browsers? Removing it might be a breaking change.
Is it possible this was added for when the package is used in browsers? Removing it might be a breaking change.
I mean we can copy/paste this code, because it is very simple package
Is it possible this was added for when the package is used in browsers? Removing it might be a breaking change.
I mean we can copy/paste this code, because it is very simple package
Maybe best to do this in a follow up PR?
I would have to figure out how to conditionally do require('util')
only in nodejs environments and no idea how to do that (yet).
Maybe best to do this in a follow up PR?
:+1:
Thank you