This can be avoided with the following Parcel config in package.json:
"alias": {
"process": false
}
but this shouldn't be necessary.
Expected behavior
Tracker should be as lightweight as possible and not pull in unnecessary shims. Since the code causing this issue is only for testing, it shouldn't exist at all in the production build of the library. Potentially this code could be implemented using a mock in the test, rather than modifying the library itself to perform differently under test.
Steps to reproduce
Steps:
Create analytics.js, for example:
import Plausible from 'plausible-tracker';
const {trackPageview, enableAutoOutboundTracking} = new Plausible({
apiHost: 'https://example.com',
trackLocalhost: true,
});
trackPageview();
enableAutoOutboundTracking();
Versions
Describe the bug
I'm using Parcel to build the JS for one of my sites. This code in the Plausible tracker: https://github.com/plausible/plausible-tracker/blob/c0b87d997d839938c23023d35bac0d6683635bbc/src/lib/tracker.ts#L285-L296
Causes Parcel to pull in a ~3KB (minified) shim for the Node.js
process
module. This is the code that gets bundled: https://github.com/defunctzombie/node-process/blob/master/browser.jsThis can be avoided with the following Parcel config in
package.json
:but this shouldn't be necessary.
Expected behavior
Tracker should be as lightweight as possible and not pull in unnecessary shims. Since the code causing this issue is only for testing, it shouldn't exist at all in the production build of the library. Potentially this code could be implemented using a mock in the test, rather than modifying the library itself to perform differently under test.
Steps to reproduce
Steps: Create
analytics.js
, for example:Run
parcel
on it, e.g.Observe the resulting
dist/analytics.js
file.Your Environment
N/A