Skip to content

Commit

Permalink
fixup: conditional require for webpack
Browse files Browse the repository at this point in the history
  • Loading branch information
addaleax committed Apr 10, 2024
1 parent bc7fe16 commit d2ebf6e
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
1 change: 1 addition & 0 deletions packages/service-provider-server/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
"url": "git://github.com/mongodb-js/mongosh.git"
},
"scripts": {
"precompile": "rm -rf lib/",
"compile": "tsc -p tsconfig.json && webpack --mode production && node scripts/wrap-pack.js",
"test": "cross-env TS_NODE_PROJECT=../../configs/tsconfig-mongosh/tsconfig.test.json mocha -r \"../../scripts/import-expansions.js\" --timeout 60000 -r ts-node/register \"./src/**/*.spec.ts\"",
"test-ci": "node ../../scripts/run-if-package-requested.js npm test",
Expand Down
10 changes: 9 additions & 1 deletion packages/service-provider-server/src/cli-service-provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -231,9 +231,17 @@ export class SynchronousCliServiceProvider
this.remotePort = channel.port2;

this.bus = bus;
let source: string;
try {
source = require('./wrapped.js');
} catch (err: any) {
throw new Error(
`Could not get Worker thread source code: ${err.message}`
);
}
this.worker = new Worker(
// eslint-disable-next-line @typescript-eslint/restrict-template-expressions
`${require('./wrapped.js')}; SynchronousCliServiceProvider.runWorker();`,
`${source}; SynchronousCliServiceProvider.runWorker();`,
{ eval: true, workerData: { flag: this.flag } }
);
const origEmit: any = this.bus.emit;
Expand Down

0 comments on commit d2ebf6e

Please sign in to comment.