dominictarr/rc

rc does not work well with webpack

Closed this issue · 2 comments

I am working on packing up a project that references RC in electron & vue using webpack, and I've found that rc does not play nicely with webpack.

I'm getting the following error:

A JavaScript error occurred in the main process
Uncaught Exception:
Error: rc(name): name must be string

The offending lines in rc:

if(!module.parent) {
console.log(
JSON.stringify(module.exports(process.argv[2]), false, 2)
)
}

module.parent is not respected by webpack (nor will it be webpack/webpack#1569)

!module.parent is a very common convention for detecting if you are in the main file. webpack needs to have something for this. rc is a very popular and stable module, if webpack doesn't work well with it, the problem is that webpack doesn't work well with node modules.

I just saw your comment here: webpack/webpack#20 I agree that webpack should at least support this case.

Meanwhile there is also this method:
require.main === module
which is supported by webpack
webpack/webpack#64