bcrypt.js icon indicating copy to clipboard operation
bcrypt.js copied to clipboard

module and process variables

Open mdhishaamakhtar opened this issue 4 years ago • 14 comments

The variables module and process in the file minimal-env.js is overriding the definition of module and process in Node.js

mdhishaamakhtar avatar Sep 22 '20 10:09 mdhishaamakhtar

minimal-env.js isn't actual code, that's a closure compiler externs file. Can you explain the problem you are facing in more detail?

dcodeIO avatar Sep 22 '20 10:09 dcodeIO

When I am using any sort of IDE, its taking minimal-env.js as the global declarations for module and process. Hence, resulting in errors when I do module.exports or process.env.PORT for example.

mdhishaamakhtar avatar Sep 22 '20 23:09 mdhishaamakhtar

That's strange, I've never seen a problem like this using any sort of IDE I use. Given that it's not feasible to delete the file as long as we want to use it with closure compiler, I'm also not sure what to do here.

dcodeIO avatar Sep 23 '20 08:09 dcodeIO

I have not been through the codebase entirely and I intend to do that, but is it necessary to name those variables as process and module?

mdhishaamakhtar avatar Sep 23 '20 21:09 mdhishaamakhtar

Yeah, that's necessary, since the file indicates the expected environment when compiling with closure compiler, to make it aware of it, so it doesn't rename the wrong things during optimizations. More information about externs: https://developers.google.com/closure/compiler/docs/externs-and-exports

dcodeIO avatar Sep 23 '20 21:09 dcodeIO

Alright then should I put it in .npmignore and make a PR because we dont need the npm package to have that since its only needed for the closure compiler?

mdhishaamakhtar avatar Oct 01 '20 23:10 mdhishaamakhtar

Alright I have opened a PR for the same.

mdhishaamakhtar avatar Oct 01 '20 23:10 mdhishaamakhtar

Is there any update @dcodeIO

mdhishaamakhtar avatar Oct 12 '20 15:10 mdhishaamakhtar

@dcodeIO Thank you for your great efforts on creating and supporting this awesome package, but this minimal-env.js problem is really annoying and breaks IDE things after installing bcryptjs (in my case any IDEA-family IDE, like WebStorm, PhpStorm, PyCharm and so on).

Any chances to have an update?

As a workaround for people coming here from Google search: right click on [project root]/node_modules/bcryptjs/externs/minimal-env.js => "Mark as Plain Text". See also a discussion in #109.

nowm avatar Nov 05 '20 03:11 nowm

I think with #124 merged into master, we can close this issue now

mdhishaamakhtar avatar Dec 04 '20 13:12 mdhishaamakhtar

@mdhishaamakhtar and @dcodeIO, thank you so very much for this fix! Hope to see updates in NPM soon.

nowm avatar Dec 04 '20 13:12 nowm

Since #124 is still not added in the latest release, I'll let this stay open until there is a new release for npm

mdhishaamakhtar avatar Dec 04 '20 13:12 mdhishaamakhtar

@dcodeIO If you could publish a new release to npm, then we could close this issue.

mdhishaamakhtar avatar Dec 04 '20 13:12 mdhishaamakhtar

@dcodeIO any updates about release?

VladStepanov avatar Dec 30 '20 10:12 VladStepanov