pidusage icon indicating copy to clipboard operation
pidusage copied to clipboard

[BUG] pidusage not compatible with bundling due to dynamic requires in stats.js

Open tabarra opened this issue 3 years ago • 0 comments

API Platform version(s) affected: 3.0.0

Description
If bundled, it will not be able to detect which platform the lib is running, which will throw xxx is not supported yet error even for supported platforms like win32 and linux.
This issue has also been reported in #152 and #144 , but I decided to create a new issue with the correct title.

How to reproduce
Just try to bundle it with esbuild, webpack, or whatever.

Possible Solution
Replace the dynamic import below with static ones that bundlers can resolve.

let stat
try {
  stat = require('./' + platformToMethod[platform])
} catch (err) {}

Additional Context
PR incoming.

tabarra avatar Sep 15 '22 19:09 tabarra