Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: main field in package.json should correspond to cjs artifacts #5756

Open
wants to merge 1 commit into
base: v1.x
Choose a base branch
from

Commits on Oct 5, 2023

  1. fix: main field in package.json should correspond to cjs artifacts

    When axios#4787 was implemented, the project was switched to `"type": "module"` and "./index.js" became an esm file instead of commonjs, however, the "main" entry in package.json still points to "index.js". As a result, consumers using this field may get unexpected behavior since the main field is supposed to be commonjs if the entry is provided.
    
    Many consumers won't run into this as a practical problem (for example when just doing `const axios = require('axios').default` from inside of a cjs file in node) because the "exports" map takes precedence over the main/module fields, but tools that don't parse the object map when resolving still run into problems here.
    
    The fix for this is to just point the "main" entry-point to the commonjs artifacts located at "./dist/node/index.cjs".
    
    I also added a module entrypoint to improve compatability for the cases where the export map is not used (webpack 4 for example) since that would likely be reading the cjs "main" entrypoint now that main has switched back to cjs.
    thebanjomatic committed Oct 5, 2023
    Configuration menu
    Copy the full SHA
    7a60e50 View commit details
    Browse the repository at this point in the history