Skip to content

Commit b622b6a

Browse files
committed
Fix windows packaging by making native modules external
1 parent d7b947f commit b622b6a

File tree

5 files changed

+11
-40
lines changed

5 files changed

+11
-40
lines changed

build-release.sh

+2-2
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ case "$TARGET_PLATFORM" in
6363
linux)
6464
EXPECTED_BIN_STRING="ELF"
6565
# Builds raw on non-Windows, but never used
66-
PACKAGE_WHITELIST="registry.node"
66+
PACKAGE_WHITELIST="registry-js"
6767
;;
6868
win32)
6969
EXPECTED_BIN_STRING="MS Windows"
@@ -72,7 +72,7 @@ case "$TARGET_PLATFORM" in
7272
darwin)
7373
EXPECTED_BIN_STRING="Mach-O"
7474
# Builds raw on non-Windows, but never used
75-
PACKAGE_WHITELIST="registry.node"
75+
PACKAGE_WHITELIST="registry-js"
7676
;;
7777
*)
7878
echo "Unknown platform $TARGET_PLATFORM"

pack.ts

-23
Original file line numberDiff line numberDiff line change
@@ -19,26 +19,6 @@ const spawn = (command: string, args: string[] = [], options?: SpawnOptions) =>
1919
});
2020
}
2121

22-
const updateRegistryJs = async (platform: string) => {
23-
// Install registry JS for a given target platform, and copy its native
24-
// module into our bundle.
25-
const registryJsDir = path.join(OUTPUT_DIR, 'node_modules', 'registry-js');
26-
await fs.rmdir(registryJsDir).catch(() => {});
27-
await spawn('npm', [
28-
'install',
29-
'registry-js',
30-
'--no-save'
31-
], {
32-
cwd: OUTPUT_DIR,
33-
stdio: 'inherit',
34-
env: Object.assign({}, process.env, { 'npm_config_platform': platform })
35-
});
36-
await fs.copyFile(
37-
path.join(registryJsDir, 'build', 'Release', 'registry.node'),
38-
path.join(OUTPUT_DIR, 'bundle', 'registry.node'),
39-
);
40-
};
41-
4222
const packageApp = async () => {
4323
console.log('Preparing packaging directory');
4424
await fs.emptyDir(OUTPUT_DIR);
@@ -75,15 +55,12 @@ const packageApp = async () => {
7555

7656
// Run build-release in this folder, for each platform:
7757
console.log('Building for Linux');
78-
await updateRegistryJs('linux');
7958
await spawn(buildScript, ['linux'], { cwd: OUTPUT_DIR, stdio: 'inherit' });
8059

8160
console.log('Building for Darwin');
82-
await updateRegistryJs('darwin');
8361
await spawn(buildScript, ['darwin'], { cwd: OUTPUT_DIR, stdio: 'inherit' });
8462

8563
console.log('Building for Win32');
86-
await updateRegistryJs('win32');
8764
await spawn(buildScript, ['win32'], { cwd: OUTPUT_DIR, stdio: 'inherit' });
8865
}
8966

package-lock.json

-6
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+6-3
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,10 @@
4444
"lodash": "^4.17.13",
4545
"mockttp": "^0.18.0",
4646
"node-gsettings-wrapper": "^0.5.0",
47+
"registry-js": "^1.4.0",
4748
"rimraf": "^2.6.2",
48-
"tslib": "^1.9.3"
49+
"tslib": "^1.9.3",
50+
"win-version-info": "^3.0.1"
4951
},
5052
"devDependencies": {
5153
"@oclif/dev-cli": "^1.19.4",
@@ -70,7 +72,6 @@
7072
"got": "^9.6.0",
7173
"graphql.js": "^0.6.1",
7274
"mocha": "^5.2.0",
73-
"native-ext-loader": "^2.3.0",
7475
"needle": "^2.4.0",
7576
"node-dev": "^3.1.3",
7677
"node-fetch": "^2.6.0",
@@ -115,7 +116,9 @@
115116
"@oclif/command",
116117
"@oclif/config",
117118
"@oclif/plugin-help",
118-
"@oclif/plugin-update"
119+
"@oclif/plugin-update",
120+
"registry-js",
121+
"win-version-info"
119122
],
120123
"update": {
121124
"s3": {

webpack.config.js

+3-6
Original file line numberDiff line numberDiff line change
@@ -35,16 +35,13 @@ module.exports = {
3535
test: /\.mjs$/,
3636
include: /node_modules/,
3737
type: "javascript/auto",
38-
},
39-
{
40-
// Allows us to require native modules
41-
test: /\.node$/,
42-
loader: "native-ext-loader"
4338
}
4439
]
4540
},
4641
externals: [
47-
'@oclif/plugin-update/lib/commands/update'
42+
'@oclif/plugin-update/lib/commands/update', // Lots of complicated dynamic requires in @oclif
43+
'registry-js', // Native module
44+
'win-version-info' // Native module
4845
],
4946
plugins: [
5047
// Optimistic require for 'iconv' in 'encoding', falls back to 'iconv-lite'

0 commit comments

Comments
 (0)