codymikol / karma-webpack

Karma webpack Middleware
MIT License
830 stars 221 forks source link

fix(webpack): use path.resolve to create file path #512

Closed Feiyang1 closed 3 years ago

Feiyang1 commented 3 years ago

This PR contains a:

Motivation / Use-Case

I'm getting no such file or directory error from karma-webpack:

ERROR [karma-server]: Error: ENOENT: no such file or directory, open 13 07 2021 21:35:45.728:ERROR [karma-server]: Error: ENOENT: no such file or directory, open '/var/folders/fd/17654frj3379vn3wr07k_s_000jyn1/T/_karma_webpack_209189/../../../../../../Users/feiyangc/Projects/firebase-js-sdk/packages/logger/dist/src/logger.d.ts'
    at Object.openSync (fs.js:476:3)
    at Object.readFileSync (fs.js:377:35)
    at /Users/feiyangc/Projects/firebase-js-sdk/node_modules/karma-webpack/lib/webpack/plugin.js:24:66
    at Array.forEach (<anonymous>)
    at /Users/feiyangc/Projects/firebase-js-sdk/node_modules/karma-webpack/lib/webpack/plugin.js:17:29
    at Hook.eval [as callAsync] (eval at create (/Users/feiyangc/Projects/firebase-js-sdk/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:18:1)
    at Hook.CALL_ASYNC_DELEGATE [as _callAsync] (/Users/feiyangc/Projects/firebase-js-sdk/node_modules/tapable/lib/Hook.js:18:14)
    at /Users/feiyangc/Projects/firebase-js-sdk/node_modules/webpack/lib/Compiler.js:482:23
    at Compiler.emitRecords (/Users/feiyangc/Projects/firebase-js-sdk/node_modules/webpack/lib/Compiler.js:874:39)
    at /Users/feiyangc/Projects/firebase-js-sdk/node_modules/webpack/lib/Compiler.js:474:11 {
  errno: -2,
  syscall: 'open',
  code: 'ENOENT',
  path: '/var/folders/fd/17654frj3379vn3wr07k_s_000jyn1/T/_karma_webpack_209189/../../../../../../Users/feiyangc/Projects/firebase-js-sdk/packages/logger/dist/src/logger.d.ts'
}

I think the issue is that /var is a symlink to /private/var, and readFileSync incorrectly (or correctly?) resolve the path to /private/Users/feiyangc/Projects/firebase-js-sdk/packages/logger/dist/src/logger.d.ts while the correct path should be without /private.

Using path.resolve creates the correct file path.

Breaking Changes

Additional Info

codymikol commented 3 years ago

Thanks for the PR! I'll try and take a look at this tonight.

Feiyang1 commented 3 years ago

@codymikol any chance you have taken a look at it?

codymikol commented 3 years ago

Sorry, just closed on a house last week and life has been a bit crazy 😅

codymikol commented 3 years ago

@ryanclark any chance you'd have a moment to help me put out a hotfix release for this?

Feiyang1 commented 3 years ago

@ryanclark any update on a new release?

amad commented 2 years ago

Any ETA for releasing this bugfix?