Skip to content
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 call-site to do some hacky/awesome simplifications? #101

Open
sam-goodwin opened this issue Jan 19, 2020 · 5 comments
Open

Use call-site to do some hacky/awesome simplifications? #101

sam-goodwin opened this issue Jan 19, 2020 · 5 comments

Comments

@sam-goodwin
Copy link
Owner

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?

const myConstruct = new Construct(stack, 'myConstruct');
// simplify to
const myConstruct = new Construct(stack)

Could even store the current "scope" globally to remove the boilerplate entirely:

const stack = new cdk.Stack(app, 'my-stack'); // pushes scope onto a global stack
const myConstruct = new Construct(); // no boiler-plate
@pocesar
Copy link
Contributor

pocesar commented Jan 19, 2020

@sam-goodwin
Copy link
Owner Author

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.

@sam-goodwin
Copy link
Owner Author

Oh I see, you were referring to their implementation. I think it's brilliant :P.

@sam-goodwin
Copy link
Owner Author

sam-goodwin commented Jan 19, 2020

Might break in webpack, though.

@pocesar
Copy link
Contributor

pocesar commented Jan 19, 2020

yeah, rewriting the global error class static method then rewriting it back, reminds me of DOJO/mootools era, long time ago 😄

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants