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: include .d.mts file for bundler compatibility #786

Merged
merged 6 commits into from
Apr 12, 2024

Conversation

aussieboi
Copy link
Contributor

@aussieboi aussieboi commented Feb 12, 2024

As mentioned in #785 this is PR that fixes exports for compatibility with moduleResolution: bundeler.

Let me know if there is anything to add.

closes #785

danielroe
danielroe previously approved these changes Feb 12, 2024
@BryceBarbara
Copy link

@danielroe Do you know what the status of this is? I'm facing this issue right now with "moduleResolution": "Node16", and "moduleResolution": "NodeNext",

@BryceBarbara
Copy link

I can confirm that your latest changes do solve my issues. :)

When you know, can you tell me know which version this'll be going into?

@danielroe danielroe changed the title fix: fixes module resolution build: include .d.mts file for bundler compatibility Apr 12, 2024
@danielroe danielroe changed the title build: include .d.mts file for bundler compatibility fix: include .d.mts file for bundler compatibility Apr 12, 2024
@danielroe danielroe merged commit fe769c7 into nuxt-community:main Apr 12, 2024
5 of 14 checks passed
@danielroe
Copy link
Member

Fix released in v0.34.0.

@BryceBarbara
Copy link

Hmm, @danielroe are you sure the change went out?

Looks like the change may have got lost in the merge. This is what I was expecting to see:
image
And this is what I see:
image

@danielroe
Copy link
Member

In the end we create an extra declaration file owing to an issue with siroc. Does it not work?

@BryceBarbara
Copy link

Nope, I get the following error when using "moduleResolution": "Node16":

The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("@nuxtjs/composition-api")' call instead.
  To convert this file to an ECMAScript module, change its file extension to '.mts', or add the field `"type": "module"` to 'c:/<some path>/package.json'.ts(1479)

But we're planning on starting the migration to Vue 3/Nuxt 3 in a few weeks so I don't think it's a high priority issue for us.

@danielroe
Copy link
Member

@BryceBarbara Can you provide a reproduction? I can easily revert to a previous version of this PR if I can confirm the issue.

This looks right to me:

https://arethetypeswrong.github.io/?p=@nuxtjs/[email protected]

@BryceBarbara
Copy link

I can't recreate any more due to losing access to the source code in question but I appreciate your follow up! My guess is that the warning the types tool is referring to ⚠️ ESM (dynamic import only) is probably what was causing me grief.

Also, I love that arethetypeswrong tool! I wish I knew about it sooner!

Copy link
Member

Let me know if you or anyone else still has a problem (with a minimal reproduction) and I will very happily iterate on this.

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.

Extend package.json to be compatible with moduleResolution: bundler
3 participants