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

Support for cnpm and use electron as devDependence instead of electro… #183

Merged
merged 3 commits into from
Jun 16, 2017

Conversation

wenshiqi0
Copy link

@wenshiqi0 wenshiqi0 commented Jun 14, 2017

I am using cnpm instead of npm or yarn to install my node modules, and I find out that electron-rebuild does not support for cnpm. 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.

@fengmk2
Copy link

fengmk2 commented Jun 14, 2017

pnpm is using link too https://github.com/pnpm/pnpm

@fengmk2
Copy link

fengmk2 commented Jun 14, 2017

@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 = [];
Copy link

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.

Copy link
Member

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 = [];
Copy link
Member

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 {
Copy link
Member

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 {
Copy link
Member

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

@MarshallOfSound
Copy link
Member

Also if you pull in latest master the travis builds should go green 👍

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

Successfully merging this pull request may close these issues.

3 participants