Commit 2f93b1a 1 parent 0144fb3 commit 2f93b1a Copy full SHA for 2f93b1a
File tree 1 file changed +13
-1
lines changed
1 file changed +13
-1
lines changed Original file line number Diff line number Diff line change @@ -39,7 +39,19 @@ module.exports.setup = function (build) {
39
39
40
40
if ( args . namespace === 'file' && packagesOfInterest . has ( packageName ) ) {
41
41
// The file namespace is used when requiring files from disk in userland
42
- const pathToPackageJson = require . resolve ( `${ packageName } /package.json` , { paths : [ args . resolveDir ] } )
42
+
43
+ let pathToPackageJson
44
+ try {
45
+ pathToPackageJson = require . resolve ( `${ packageName } /package.json` , { paths : [ args . resolveDir ] } )
46
+ } catch ( err ) {
47
+ if ( err . code === 'MODULE_NOT_FOUND' ) {
48
+ console . warn ( `Unable to open "${ packageName } /package.json". Is the "${ packageName } " package dead code?` )
49
+ return
50
+ } else {
51
+ throw err
52
+ }
53
+ }
54
+
43
55
const pkg = require ( pathToPackageJson )
44
56
45
57
if ( DEBUG ) {
You can’t perform that action at this time.
0 commit comments