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

Can't get __dirname to work #23

Open
schadenn opened this issue Feb 8, 2019 · 5 comments
Open

Can't get __dirname to work #23

schadenn opened this issue Feb 8, 2019 · 5 comments

Comments

@schadenn
Copy link

schadenn commented Feb 8, 2019

Hi,

I'm trying to use the plugin to use __dirname in my component src somewhere. I already dug quite deep into your code and found that the plugin looks for __dirname in my code and if it's there it puts a import __dirname from 'node-globals:dirname' at the top of the file.

Just how is this import from 'node-globals:dirname supposed to work (maybe if you explain, I can find the solution)?
There is no npm module called node-globals being installed.
So everytime I'm trying to use __dirname rollup just fails with:

"Could not load  node-globals:dirname (imported by
           [...]/DevPage.js): The argument 'path' must be a string
           or Uint8Array without null bytes. Received '\u0000node-globals:dirname'"

Also not quite sure why there is a \0 character in front of the DIRNAME path in your code.

Thanks in advance.

@ca-miked
Copy link

I'm having the same exact issue

@kuraga
Copy link

kuraga commented May 25, 2019

Null byte (\0) is really in these lines. It was introduced in #3 .

@schadenn
Copy link
Author

@kuraga See: rollup/rollup#2881
It doesn't polyfill __dirname though currently.

I'm not sure what your usecase is. Mine was to do some node fs operations during runtime which turned out to not being a very good idea in the first place. If you've got a valid use-case maybe raise an issue over at rollup-plugin-node-polyfills.

@kuraga
Copy link

kuraga commented Nov 15, 2019

@schadenn , thanks!

It supports, doesn't it?

My usecase is using _dirname by a (development) dependency of my project.

@schadenn
Copy link
Author

@kuraga Oh okay, yeah might be that it supports it. I didn't see it being listed in the Readme and did no further investigation.
In that case I wish you good luck trying that plugin :)

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

3 participants