Skip to content

axios.min.js includes unnecessary package.json since 0.21.2 #4028

@kawanet

Description

@kawanet

Describe the bug

dist/axios.min.js of version 0.21.2 to 0.21.4 contains its package.json which is never required for usages on browser.
Version 0.21.1 and before did not. This gave extra 2KB fat for the minified build.

To Reproduce

$ curl -s https://cdnjs.cloudflare.com/ajax/libs/axios/0.21.4/axios.min.js | wc -c
   19157
$ curl -s https://cdnjs.cloudflare.com/ajax/libs/axios/0.21.2/axios.min.js | wc -c
   19025
$ curl -s https://cdnjs.cloudflare.com/ajax/libs/axios/0.21.1/axios.min.js | wc -c
   14355

$ curl -s https://cdnjs.cloudflare.com/ajax/libs/axios/0.21.4/axios.min.js | grep -c '"name":"axios","version":"0.21'
1
$ curl -s https://cdnjs.cloudflare.com/ajax/libs/axios/0.21.2/axios.min.js | grep -c '"name":"axios","version":"0.21'
1
$ curl -s https://cdnjs.cloudflare.com/ajax/libs/axios/0.21.1/axios.min.js | grep -c '"name":"axios","version":"0.21'
0

Expected behavior

Please keep dist/axios.min.js weight healthy. 💪

Environment

  • Axios Version 0.21.2 to 0.21.4

Additional context/Screenshots

This happens because lib/helpers/validator.js loads package.json even for dist/axios.min.js build. @DigitalBrainJS

var pkg = require('./../../package.json');
var currentVerArr = pkg.version.split('.');

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions