Skip to content

Commit de3fbd6

Browse files
committed
Fix local building for module extraction
1 parent 73d6b77 commit de3fbd6

1 file changed

Lines changed: 2 additions & 6 deletions

File tree

packages/server/src/modules.ts

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,6 @@ declare var __non_webpack_require__: typeof require;
88
* Handling of native modules within the CLI
99
*/
1010
export const setup = (dataDirectory: string): void => {
11-
if (!isCli) {
12-
return;
13-
}
14-
1511
try {
1612
fs.mkdirSync(path.join(dataDirectory, "modules"));
1713
} catch (ex) {
@@ -21,7 +17,7 @@ export const setup = (dataDirectory: string): void => {
2117
}
2218

2319
const unpackModule = (moduleName: string): void => {
24-
const memFile = path.join(buildDir!, "build/modules", moduleName + ".node");
20+
const memFile = path.join(isCli ? buildDir! : path.join(__dirname, ".."), "build/modules", moduleName + ".node");
2521
const diskFile = path.join(dataDirectory, "modules", moduleName + ".node");
2622
if (!fs.existsSync(diskFile)) {
2723
fs.writeFileSync(diskFile, fs.readFileSync(memFile));
@@ -38,7 +34,7 @@ export const setup = (dataDirectory: string): void => {
3834
const nodePtyUtils = require("../../protocol/node_modules/node-pty/lib/utils") as typeof import("../../protocol/node_modules/node-pty/src/utils");
3935
// tslint:disable-next-line:no-any
4036
nodePtyUtils.loadNative = (modName: string): any => {
41-
return __non_webpack_require__(path.join(dataDirectory, "modules", modName + ".node"));
37+
return (typeof __non_webpack_require__ !== "undefined" ? __non_webpack_require__ : require)(path.join(dataDirectory, "modules", modName + ".node"));
4238
};
4339
// tslint:disable-next-line:no-any
4440
(<any>global).SPDLOG_LOCATION = path.join(dataDirectory, "modules", "spdlog.node");

0 commit comments

Comments
 (0)