Open sam-goodwin opened 4 years ago
IMHO, that's abusing the language features 😆 https://github.com/tj/callsite/blob/4882cd047cbc234df1d07cfe26f618ecb1a45e5e/index.js#L2-L10
Oh, absolutely! That's why it's so enticing, haha! Maybe not this particular use-case, but it might be useful for grabbing things like __dirname
from the caller's context.
Oh I see, you were referring to their implementation. I think it's brilliant :P.
Might break in webpack, though.
yeah, rewriting the global error class static method then rewriting it back, reminds me of DOJO/mootools era, long time ago 😄
Could we use https://www.npmjs.com/package/callsite to do some tricky stuff like auto-generating CDK construct IDs from the assign variable name?
Could even store the current "scope" globally to remove the boilerplate entirely: