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

Replace __dirname with the actual value #5090

Open
aminya opened this issue Sep 2, 2020 · 2 comments
Open

Replace __dirname with the actual value #5090

aminya opened this issue Sep 2, 2020 · 2 comments

Comments

@aminya
Copy link
Contributor

aminya commented Sep 2, 2020

🙋 feature request

When I use Parcel to bundle something, if the files use __dirname somewhere (like for passing to a function) this will not work as soon as Parcel writes the bundle to some other folder.

🤔 Expected Behavior

Replace __dirname with the actual value

😯 Current Behavior

Keeps __dirname

💁 Possible Solution

  1. replace __dirname with the actual value
  2. Have a replace or path-resolve plugin like this to allow changing the string manually. This would be a more general solution for the cases that __dirname is not used (e.g. ./)

🔦 Context

prebuild/node-gyp-build#22

💻 Examples

For example, node-gyp-rebuild needs the folder name to be able to include native modules. Using __dirname results in the wrong behavior.
atom-community/zadeh#13

@aminya aminya changed the title Replace __dirname with the actual path Replace __dirname with the actual value Sep 2, 2020
@mischnic
Copy link
Member

mischnic commented Sep 2, 2020

"context": "node", should preserve __dirname.

@aminya
Copy link
Contributor Author

aminya commented Sep 3, 2020

But this is incorrect. __dirname value is only correct when it is in the original file.

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

No branches or pull requests

2 participants