momocow / webpack-userscript

A Webpack plugin for userscript projects. 🙈
https://cow.moe/webpack-userscript/
MIT License
200 stars 21 forks source link

Plugin throws error when package.json is not in context directory #47

Closed StrikeAgainst closed 3 years ago

StrikeAgainst commented 3 years ago

I'm having a case where I'm running webpack in a context directory descendant to my project directory, i.e. the package.json is not in the same directory. This leads to an error, where the process is not able to read a package.json from the same directory.

Would it be viable to implement that you can register the package.json path for the plugin explicitly in an option field, and/or, if the file can't be found, have the package data values default to empty as it already does with missing package properties?

momocow commented 3 years ago

Hi, thanks for reporting the issue.

Since the package.json is required only for default values of headers, you are right that empty values should be provided if the file cannot be found.

The fix will be included in the next patch version.