aws / aws-cdk

The AWS Cloud Development Kit is a framework for defining cloud infrastructure in code
https://aws.amazon.com/cdk
Apache License 2.0
11.33k stars 3.76k forks source link

aws-cdk: Replace `__dirname` #26054

Open cyntheticfox opened 1 year ago

cyntheticfox commented 1 year ago

Describe the feature

Replace the global variable __dirname used with an alternative that properly handles special characters and is more widely supported

Use Case

I've seen issues in #21161, and #18470, and may be running into issues myself due to path resolution shenanigans on my system with the __dirname global variable.

Proposed Solution

It seems feasible from my limited knowledge of Node.js to use path.dirname(url.fileURLToPath(import.meta.url)) instead, given its introduction back in Node.js 10.12.

Other Information

No response

Acknowledgements

CDK version used

2.80.0

Environment details (OS name and version, etc.)

NixOS 23.05

pahud commented 1 year ago

Can you elaborate more about this issue? What is the current behavior and what is the expected behavior? A small code snippet provided would be highly appreciated as well.