Skip to content

Commit 23dcb79

Browse files
committed
Stub conpty.node import on linux and macos
Signed-off-by: Parisa Betel Miri <parisa.betelmiri@microchip.com>
1 parent 484d2f5 commit 23dcb79

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

dev-packages/native-webpack-plugin/src/native-webpack-plugin.ts

+10
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ const REQUIRE_VSCODE_WINDOWS_CA_CERTS = '@vscode/windows-ca-certs';
2525
const REQUIRE_BINDINGS = 'bindings';
2626
const REQUIRE_KEYMAPPING = './build/Release/keymapping';
2727
const REQUIRE_PARCEL_WATCHER = './build/Release/watcher.node';
28+
const REQUIRE_NODE_PTY_CONPTY = '../build/Release/conpty.node';
2829

2930
export interface NativeWebpackPluginOptions {
3031
out: string;
@@ -71,6 +72,11 @@ export class NativeWebpackPlugin {
7172
[REQUIRE_VSCODE_WINDOWS_CA_CERTS]: windowsCaCertsFile,
7273
[REQUIRE_PARCEL_WATCHER]: issuer => Promise.resolve(findNativeWatcherFile(issuer))
7374
};
75+
if (process.platform !== 'win32') {
76+
// The expected conpty.node file is not available on non-windows platforms during build.
77+
// We need to provide a stub that will be replaced by the real file at runtime.
78+
replacements[REQUIRE_NODE_PTY_CONPTY] = () => buildFile(directory, 'conpty.js', conhostWindowsReplacement());
79+
}
7480
});
7581
compiler.hooks.normalModuleFactory.tap(
7682
NativeWebpackPlugin.name,
@@ -208,3 +214,7 @@ ${cases.join(os.EOL)}
208214
throw new Error(\`unhandled module: "\${jsModule}"\`);
209215
}`.trim();
210216
};
217+
218+
const conhostWindowsReplacement = (nativePath: string = '.'): string => `
219+
module.exports = __non_webpack_require__('${nativePath}/native/conpty.node');
220+
`;

0 commit comments

Comments
 (0)