Wednesday, 26 April 2017

webpack to resolve a fork path if bundled

We have class A which depends on a js file tProcess.js which suppose to run in the node server. When we bundle it using webpack it stops working as the path can not be resolved and we use webpack-node-externals as we creating a node package. How do we need configure webpack to resolve the path (something like requirejs.toUrl as in requireJS) so it only resolves to the path even after the bundle?

   this._process = cp.fork(require.resolve('./tProcess'), [], {
        env,
        cwd: URI.parse(path.dirname('./lib/tProcess')).fsPath,
    });

After webpack run, it converts to

this._process = cp.fork(/*require.resolve*/(10), [], {
    env,
    cwd: uri_1.default.parse(path.dirname('./lib/terminalProcess')).fsPath,
});



via user1595858

No comments:

Post a Comment