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: resolve imports manually #23

Merged
merged 8 commits into from
Jul 15, 2024
Merged

Conversation

wellwelwel
Copy link
Collaborator

@wellwelwel wellwelwel commented Jul 15, 2024

Resolves a common conflict when the same file has multiple import types for both ESM and CJS.

@wellwelwel wellwelwel marked this pull request as ready for review July 15, 2024 03:45
@wellwelwel wellwelwel marked this pull request as draft July 15, 2024 03:52
@wellwelwel wellwelwel marked this pull request as ready for review July 15, 2024 04:41
@wellwelwel wellwelwel merged commit e1b0ae7 into mysqljs:main Jul 15, 2024
4 checks passed
@wellwelwel wellwelwel deleted the import-default branch July 15, 2024 05:45
@HappyZombies
Copy link
Contributor

@wellwelwel this ended up being a breaking change for how I was using the module.

version 1.0.0, I had this

const { ca: awsCa } = require('aws-ssl-profiles').default;

With version 1.1.1, I get this error now.

const { ca: awsCa } = require('aws-ssl-profiles').default; 
const {ca: awsCaBundle} = require('aws-ssl-profiles').default;
           ^

TypeError: Cannot destructure property 'ca' of 'require(...).default' as it is undefined.

@wellwelwel
Copy link
Collaborator Author

wellwelwel commented Jul 16, 2024

Hi @HappyZombies, thanks for the report. I'll take a look at it.

In theory, this should work:

exports.default = profiles;

But unfortunately, there are several bugs when using both CSJ and ESM with different export forms in the same file.

If this can't be resolved, I think it would be better to release a v2 using only named exports.

@HappyZombies
Copy link
Contributor

Ah I see, I think simply adding:

module.exports.default = profiles;

Should fix this for it to be non breaking change, no?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants