Provide an option to preserve the state of the node_modules when packaging #1684
Closed
3 tasks done
Labels
enhancement
Feature request
Preflight Checklist
Problem Description
Our observation indicates that during packaging, electron-packager will check the state of "node_modules/" with the "dependencies" field in the package.json. If the "node_modules/" directory doesn't have a module listed in the dependencies, electron-packager will report an error and fail the packaging. If the "node_modules/" directory contains a module that is not listed in the dependencies, electron-packager will not copy that module to the packaged app. And it seems like electron-packager only checks the top-level dependencies. It doesn't care about sub-dependencies.
Proposed Solution
Add an option in electron-packager to skip checking the dependencies in the package.json and preserve the state of the "node_modules/" directory when packaging the app.
Alternatives Considered
We currently workaround the issue by modifying the dependencies field in package.json prior to packaging, adding the missing ones and removing the bundled ones.
Additional Information
My team ships an electron app that includes a mixture of JavaScript and node native modules. We want to minimize the binary footage of the artifacts we ship so we decided to bundle our JavaScript. We have an algorithm that parses our dependency graph to decide which files are necessary at runtime so we can delete the rest. This results in a mismatch of the state of the "node_modules/" directory and the package.json. We don't want to simply put these packages in devDependencies because we still want to use the two fields to separate packages that are shipped vs. packages that ara only used for development. Allowing the electron-packager to skip the dependency check will save us from doing the package.json manipulation.
The text was updated successfully, but these errors were encountered: