-
Notifications
You must be signed in to change notification settings - Fork 175
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
Support for cnpm and use electron as devDependence instead of electro… #183
Conversation
pnpm is using link too https://github.com/pnpm/pnpm |
@zcbenz we find the root cause finally. |
src/rebuild.ts
Outdated
@@ -42,6 +44,8 @@ class Rebuilder { | |||
this.ABI = nodeAbi.getAbi(electronVersion, 'electron'); | |||
this.prodDeps = extraModules.reduce((acc, x) => acc.add(x), new Set()); | |||
this.rebuilds = []; | |||
this.realModulePaths = []; | |||
this.realNodeModulesPaths = []; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use Map
instead Array
will be more faster.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See my comment below about using sets, all we need is a concept of "has been used before", we don't need to store a value with the path so maps will be less efficient than using a raw set
src/rebuild.ts
Outdated
@@ -42,6 +44,8 @@ class Rebuilder { | |||
this.ABI = nodeAbi.getAbi(electronVersion, 'electron'); | |||
this.prodDeps = extraModules.reduce((acc, x) => acc.add(x), new Set()); | |||
this.rebuilds = []; | |||
this.realModulePaths = []; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For performance reasons these two path arrays should be sets
src/rebuild.ts
Outdated
const realNodeModulesPath = fs.realpathSync(nodeModulesPath); | ||
if (this.realNodeModulesPaths.indexOf(realNodeModulesPath) > -1) { | ||
return; | ||
} else { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No need for this else statement as their is a return
in the main if condition
src/rebuild.ts
Outdated
|
||
if (this.realModulePaths.indexOf(realPath) > -1) { | ||
continue; | ||
} else { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Again no need for the else block as their is a continue
statement in the main if block
Also if you pull in latest master the travis builds should go green 👍 |
I am using
cnpm
instead ofnpm
oryarn
to install my node modules, and I find out that electron-rebuild does not support forcnpm
.cnpm
use link to handle the dependencies, as I can see electron-rebuild may make circles while scanning the dependencies tree and will rebuild a module twice and this will make node-gyp throw errors.