Skip to content

Commit 0278efb

Browse files
committed
fix: removing devDependencies from package.json breaks levelup in electron
Close #1408
1 parent 77558e6 commit 0278efb

File tree

2 files changed

+45
-47
lines changed

2 files changed

+45
-47
lines changed

packages/electron-builder/src/fileTransformer.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ export async function createTransformer(srcDir: string, extraMetadata: any): Pro
2525
}
2626
else if (file.endsWith("/package.json") && file.includes("/node_modules/")) {
2727
return readJson(file)
28-
.then(it => cleanupPackageJson(it))
28+
.then(it => cleanupPackageJson(it, false))
2929
.catch(e => warn(e))
3030
}
3131
else {
@@ -45,11 +45,11 @@ export function createElectronCompilerHost(projectDir: string, cacheDir: string)
4545
return require(path.join(electronCompilePath, "config-parser")).createCompilerHostFromProjectRoot(projectDir, cacheDir)
4646
}
4747

48-
function cleanupPackageJson(data: any): any {
48+
function cleanupPackageJson(data: any, isMain: boolean): any {
4949
try {
5050
let changed = false
5151
for (const prop of Object.getOwnPropertyNames(data)) {
52-
if (prop[0] === "_" || prop === "dist" || prop === "gitHead" || prop === "keywords" || prop === "build" || prop === "devDependencies" || prop === "scripts") {
52+
if (prop[0] === "_" || prop === "dist" || prop === "gitHead" || prop === "keywords" || prop === "build" || (isMain && prop === "devDependencies") || prop === "scripts") {
5353
delete data[prop]
5454
changed = true
5555
}
@@ -73,7 +73,7 @@ async function modifyMainPackageJson(file: string, extraMetadata: any) {
7373
}
7474

7575
// https://github.com/electron-userland/electron-builder/issues/1212
76-
const serializedDataIfChanged = cleanupPackageJson(mainPackageData)
76+
const serializedDataIfChanged = cleanupPackageJson(mainPackageData, true)
7777
if (serializedDataIfChanged != null) {
7878
return serializedDataIfChanged
7979
}

yarn.lock

Lines changed: 41 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -98,8 +98,8 @@ ajv@^4.9.1:
9898
json-stable-stringify "^1.0.1"
9999

100100
ajv@^5.0.4-beta.0:
101-
version "5.0.4-beta.1"
102-
resolved "https://registry.yarnpkg.com/ajv/-/ajv-5.0.4-beta.1.tgz#a4bcf1c8654005fa97ec18bf794784224ca4c72a"
101+
version "5.0.4-beta.2"
102+
resolved "https://registry.yarnpkg.com/ajv/-/ajv-5.0.4-beta.2.tgz#2b1dbc09cbd69ee0797489894ab38d12c914e121"
103103
dependencies:
104104
co "^4.6.0"
105105
json-stable-stringify "^1.0.1"
@@ -253,13 +253,13 @@ assert-plus@^0.2.0:
253253
version "0.2.0"
254254
resolved "https://registry.yarnpkg.com/assert-plus/-/assert-plus-0.2.0.tgz#d74e1b87e7affc0db8aadb7021f3fe48101ab234"
255255

256-
async@^1.4.0, async@^1.4.2:
256+
async@^1.4.0:
257257
version "1.5.2"
258258
resolved "https://registry.yarnpkg.com/async/-/async-1.5.2.tgz#ec6a61ae56480c0c3cb241c95618e20892f9672a"
259259

260260
async@^2.0.0, async@^2.1.4:
261-
version "2.1.5"
262-
resolved "https://registry.yarnpkg.com/async/-/async-2.1.5.tgz#e587c68580994ac67fc56ff86d3ac56bdbe810bc"
261+
version "2.2.0"
262+
resolved "https://registry.yarnpkg.com/async/-/async-2.2.0.tgz#c324eba010a237e4fbd55a12dee86367d5c0ef32"
263263
dependencies:
264264
lodash "^4.14.0"
265265

@@ -1641,66 +1641,64 @@ isstream@~0.1.2:
16411641
resolved "https://registry.yarnpkg.com/isstream/-/isstream-0.1.2.tgz#47e63f7af55afa6f92e1500e690eb8b8529c099a"
16421642

16431643
istanbul-api@^1.1.0-alpha.1:
1644-
version "1.1.6"
1645-
resolved "https://registry.yarnpkg.com/istanbul-api/-/istanbul-api-1.1.6.tgz#23aa5b5b9b1b3bdbb786f039160e91acbe495433"
1644+
version "1.1.7"
1645+
resolved "https://registry.yarnpkg.com/istanbul-api/-/istanbul-api-1.1.7.tgz#f6f37f09f8002b130f891c646b70ee4a8e7345ae"
16461646
dependencies:
16471647
async "^2.1.4"
16481648
fileset "^2.0.2"
1649-
istanbul-lib-coverage "^1.0.0"
1650-
istanbul-lib-hook "^1.0.4"
1651-
istanbul-lib-instrument "^1.6.2"
1652-
istanbul-lib-report "^1.0.0-alpha.3"
1653-
istanbul-lib-source-maps "^1.1.0"
1654-
istanbul-reports "^1.0.0"
1649+
istanbul-lib-coverage "^1.0.2"
1650+
istanbul-lib-hook "^1.0.5"
1651+
istanbul-lib-instrument "^1.7.0"
1652+
istanbul-lib-report "^1.0.0"
1653+
istanbul-lib-source-maps "^1.1.1"
1654+
istanbul-reports "^1.0.2"
16551655
js-yaml "^3.7.0"
16561656
mkdirp "^0.5.1"
16571657
once "^1.4.0"
16581658

1659-
istanbul-lib-coverage@^1.0.0, istanbul-lib-coverage@^1.0.0-alpha, istanbul-lib-coverage@^1.0.0-alpha.0:
1660-
version "1.0.1"
1661-
resolved "https://registry.yarnpkg.com/istanbul-lib-coverage/-/istanbul-lib-coverage-1.0.1.tgz#f263efb519c051c5f1f3343034fc40e7b43ff212"
1659+
istanbul-lib-coverage@^1.0.0, istanbul-lib-coverage@^1.0.2:
1660+
version "1.0.2"
1661+
resolved "https://registry.yarnpkg.com/istanbul-lib-coverage/-/istanbul-lib-coverage-1.0.2.tgz#87a0c015b6910651cb3b184814dfb339337e25e1"
16621662

1663-
istanbul-lib-hook@^1.0.4:
1664-
version "1.0.4"
1665-
resolved "https://registry.yarnpkg.com/istanbul-lib-hook/-/istanbul-lib-hook-1.0.4.tgz#1919debbc195807880041971caf9c7e2be2144d6"
1663+
istanbul-lib-hook@^1.0.5:
1664+
version "1.0.5"
1665+
resolved "https://registry.yarnpkg.com/istanbul-lib-hook/-/istanbul-lib-hook-1.0.5.tgz#6ca3d16d60c5f4082da39f7c5cd38ea8a772b88e"
16661666
dependencies:
16671667
append-transform "^0.4.0"
16681668

1669-
istanbul-lib-instrument@^1.1.1, istanbul-lib-instrument@^1.6.2:
1670-
version "1.6.2"
1671-
resolved "https://registry.yarnpkg.com/istanbul-lib-instrument/-/istanbul-lib-instrument-1.6.2.tgz#dac644f358f51efd6113536d7070959a0111f73b"
1669+
istanbul-lib-instrument@^1.1.1, istanbul-lib-instrument@^1.6.2, istanbul-lib-instrument@^1.7.0:
1670+
version "1.7.0"
1671+
resolved "https://registry.yarnpkg.com/istanbul-lib-instrument/-/istanbul-lib-instrument-1.7.0.tgz#b8e0dc25709bb44e17336ab47b7bb5c97c23f659"
16721672
dependencies:
16731673
babel-generator "^6.18.0"
16741674
babel-template "^6.16.0"
16751675
babel-traverse "^6.18.0"
16761676
babel-types "^6.18.0"
16771677
babylon "^6.13.0"
1678-
istanbul-lib-coverage "^1.0.0"
1678+
istanbul-lib-coverage "^1.0.2"
16791679
semver "^5.3.0"
16801680

1681-
istanbul-lib-report@^1.0.0-alpha.3:
1682-
version "1.0.0-alpha.3"
1683-
resolved "https://registry.yarnpkg.com/istanbul-lib-report/-/istanbul-lib-report-1.0.0-alpha.3.tgz#32d5f6ec7f33ca3a602209e278b2e6ff143498af"
1681+
istanbul-lib-report@^1.0.0:
1682+
version "1.0.0"
1683+
resolved "https://registry.yarnpkg.com/istanbul-lib-report/-/istanbul-lib-report-1.0.0.tgz#d83dac7f26566b521585569367fe84ccfc7aaecb"
16841684
dependencies:
1685-
async "^1.4.2"
1686-
istanbul-lib-coverage "^1.0.0-alpha"
1685+
istanbul-lib-coverage "^1.0.2"
16871686
mkdirp "^0.5.1"
16881687
path-parse "^1.0.5"
1689-
rimraf "^2.4.3"
16901688
supports-color "^3.1.2"
16911689

1692-
istanbul-lib-source-maps@^1.1.0:
1693-
version "1.1.0"
1694-
resolved "https://registry.yarnpkg.com/istanbul-lib-source-maps/-/istanbul-lib-source-maps-1.1.0.tgz#9d429218f35b823560ea300a96ff0c3bbdab785f"
1690+
istanbul-lib-source-maps@^1.1.1:
1691+
version "1.1.1"
1692+
resolved "https://registry.yarnpkg.com/istanbul-lib-source-maps/-/istanbul-lib-source-maps-1.1.1.tgz#f8c8c2e8f2160d1d91526d97e5bd63b2079af71c"
16951693
dependencies:
1696-
istanbul-lib-coverage "^1.0.0-alpha.0"
1694+
istanbul-lib-coverage "^1.0.2"
16971695
mkdirp "^0.5.1"
16981696
rimraf "^2.4.4"
16991697
source-map "^0.5.3"
17001698

1701-
istanbul-reports@^1.0.0:
1702-
version "1.0.1"
1703-
resolved "https://registry.yarnpkg.com/istanbul-reports/-/istanbul-reports-1.0.1.tgz#9a17176bc4a6cbebdae52b2f15961d52fa623fbc"
1699+
istanbul-reports@^1.0.2:
1700+
version "1.0.2"
1701+
resolved "https://registry.yarnpkg.com/istanbul-reports/-/istanbul-reports-1.0.2.tgz#4e8366abe6fa746cc1cd6633f108de12cc6ac6fa"
17041702
dependencies:
17051703
handlebars "^4.0.3"
17061704

@@ -2079,10 +2077,10 @@ klaw@~1.3.0:
20792077
graceful-fs "^4.1.9"
20802078

20812079
latest-version@^3.0.0:
2082-
version "3.0.0"
2083-
resolved "https://registry.yarnpkg.com/latest-version/-/latest-version-3.0.0.tgz#3104f008c0c391084107f85a344bc61e38970649"
2080+
version "3.1.0"
2081+
resolved "https://registry.yarnpkg.com/latest-version/-/latest-version-3.1.0.tgz#a205383fea322b33b5ae3b18abee0dc2f356ee15"
20842082
dependencies:
2085-
package-json "^3.0.0"
2083+
package-json "^4.0.0"
20862084

20872085
lazy-cache@^1.0.3:
20882086
version "1.0.4"
@@ -2436,9 +2434,9 @@ p-locate@^2.0.0:
24362434
dependencies:
24372435
p-limit "^1.1.0"
24382436

2439-
package-json@^3.0.0:
2440-
version "3.1.0"
2441-
resolved "https://registry.yarnpkg.com/package-json/-/package-json-3.1.0.tgz#ce281900fe8052150cc6709c6c006c18fdb2f379"
2437+
package-json@^4.0.0:
2438+
version "4.0.0"
2439+
resolved "https://registry.yarnpkg.com/package-json/-/package-json-4.0.0.tgz#f3c9dc8738f5b59304d54d2cfb3f91d08fdd7998"
24422440
dependencies:
24432441
got "^6.7.1"
24442442
registry-auth-token "^3.0.1"
@@ -2789,7 +2787,7 @@ right-align@^0.1.1:
27892787
dependencies:
27902788
align-text "^0.1.1"
27912789

2792-
rimraf@^2.4.3, rimraf@^2.4.4:
2790+
rimraf@^2.4.4:
27932791
version "2.6.1"
27942792
resolved "https://registry.yarnpkg.com/rimraf/-/rimraf-2.6.1.tgz#c2338ec643df7a1b7fe5c54fa86f57428a55f33d"
27952793
dependencies:

0 commit comments

Comments
 (0)