codymikol / karma-webpack

Karma webpack Middleware
MIT License
830 stars 221 forks source link

5.0 crashes on MacOS (Preprocessor, Plugin), fixed on master -> Release 5.1? #518

Open sschmidTU opened 2 years ago

sschmidTU commented 2 years ago

Expected Behavior

Karma-webpack doesn't crash on MacOS

Actual Behavior

Karma-webpack 5.0 throws errors and crashes on MacOS, in karma-webpack/preprocessor.js and webpack/plugin.js. Both these errors are fixed on master, but not released yet, so you'd have to patch your npm release manually to make it work on MacOS.

If you're not ready to release 5.1 yet, instead releasing an alpha/dev version on npm with the current master would be great. Otherwise, I would have to create a prebuild script that patches in these 2 files from the master version into the node_modules/karma-webpack folders. Since I migrated to webpack 5, I also can't use karma-webpack 4.x for now, as far as I'm aware.


You can also fix these files in 5.0 with oneliners:

In node_modules/karma-webpack/lib/karma-webpack/preprocessor.js, I had to replace line 96 with this: return bundleContent;

And in node_modules/karma-webpack/lib/webpack/plugin.js, I had to replace line 18 with this: webpackFileObj.name.replace("../", "../../") There is a ../ missing from the path to make it valid, the chain of ../ stops one folder before the root node/folder.

How Do We Reproduce?

Probably just have a preprocessor file with 5.0 on MacOS.

Full repro: Check out this branch: https://github.com/rvilarl/opensheetmusicdisplay/tree/npm-upgrade Specifically this commit: https://github.com/rvilarl/opensheetmusicdisplay/commit/df20f00a9176c6821d19a05491908267687dd28a

Run npm install and npm test, which will crash.

ERROR [karma-server]: Error during file loading or preprocessing
TypeError [ERR_INVALID_ARG_TYPE]: The "data" argument must be of type string or an instance of Buffer, TypedArray, or DataView. Received undefined
    at Hash.update (internal/crypto/hash.js:82:11)
    at Object.sha1 (/Users/simon/OSMD/opensheetmusicdisplay-working-copy/node_modules/karma/lib/utils/crypto-utils.js:9:8)
    at runProcessors (/Users/simon/OSMD/opensheetmusicdisplay-working-copy/node_modules/karma/lib/preprocessor.js:70:26)
ERROR [karma-server]: UnhandledRejection: Error: ENOENT: no such file or directory, open '/var/folders/zn/tspvl1cj6d305kvg4r8c894c0000gp/T/_karma_webpack_341844/../../../../../../Users/simon/OSMD/opensheetmusicdisplay-working-copy/dist/src/MusicalScore/Graphical/MusicSheetCalculator.d.ts'
    at Object.openSync (fs.js:458:3)
    at Object.readFileSync (fs.js:360:35)
    at /Users/simon/OSMD/opensheetmusicdisplay-working-copy/node_modules/karma-webpack/lib/webpack/plugin.js:20:66
    at Array.forEach (<anonymous>)
rvilarl commented 2 years ago

@ryanclark @codymikol when it is planned to make the next release? The problems we have in OSMD are already resolved in the current code base.

codymikol commented 2 years ago

I know Ryan's been pretty occupied with his own obligations. When he has some time, I'm hoping to get our process for cutting releases streamlined so that we can quickly and easily cut new versions.

sschmidTU commented 2 years ago

By the way, paths are still broken for Windows with the current master build: Error: EINVAL: invalid argument, mkdir 'C:\Users\Simon\AppData\Local\Temp\_karma_webpack_82360\D:\code\osmd\opensheetmusicdisplay\dist\src'

Maybe something like PR #433 is still needed, even though the statement was made that relative paths were supposed to be eliminated.

Hinton commented 2 years ago

We've also experienced this issue while trying to bump webpack to v5 for our test suite, anything we can assist with to get a new release cut?

Macinto5h commented 11 months ago

Any update on a release that has the fix for this issue?

codymikol commented 11 months ago

Nope

codymikol commented 10 months ago

The repository was transferred to me, I'm preparing to make a 6.0.0 release that targets node 18+

ryangrunest commented 2 months ago

Any updates on this issue?

sschmidTU commented 2 weeks ago

@codymikol Is there still a new release planned? Just a friendly nudge, thanks :)