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

bug: Cannot find module '@yeger/vue-masonry-wall' or its corresponding type declarations #270

Closed
1 of 5 tasks
MartinX3 opened this issue Mar 31, 2024 · 6 comments
Closed
1 of 5 tasks
Labels
invalid This doesn't seem right

Comments

@MartinX3
Copy link

MartinX3 commented Mar 31, 2024

Affected Packages

  • @yeger/eslint-config
  • @yeger/vue-masonry-wall 5.0.8
  • @yeger/vue2-masonry-wall
  • vecti

Description

After using "module": "NodeNext", in the tsconfig.ts and "type": "module" in the package.json using vue-tsc to check my code I get the error:

> vue-tsc --noEmit

src/boot/vue-masonry-wall.ts:2:25 - error TS2307: Cannot find module '@yeger/vue-masonry-wall' or its corresponding type declarations.

2 import MasonryWall from '@yeger/vue-masonry-wall'

Any other 3rd party library I use is working.

Reproduction

https://stackblitz.com/edit/vitejs-vite-martix3-yeger-masonry-bug-270

Additional context

No response

Preferences

  • I want to be assigned to and work on this issue myself
@MartinX3 MartinX3 added the bug Something isn't working label Mar 31, 2024
@DerYeger
Copy link
Owner

Which version is affected? Please provide a minimal reproduction.
I cannot reproduce this issue in any of my projects.

@MartinX3
Copy link
Author

Thank you for your response.
I added the needed information.

@DerYeger
Copy link
Owner

Thanks for the report!

As far as I can tell, vue-tsc is the issue.

  1. exports in package.json are valid, as checked by publint.
  2. Adding an identical import to main.ts and running tsc --noEmit reports no errors.
  3. "module": "NodeNext" is not the trigger, but the implicit "moduleResolution": "NodeNext" it results in.

If you're using Vite anyway, why not switch to

  "module": "ESNext",
  "moduleResolution": "bundler",

in the first place?

@MartinX3
Copy link
Author

MartinX3 commented Mar 31, 2024

Thank you for the answer!

Oh, that means vue-tsc has a bug or that this project violates what NodeNext wants?

I did choose NodeNext because of this:

In addition to adopting the following settings, it’s also recommended not to set { "type": "module" } or use .mts files in bundler projects for now. Some bundlers adopt different ESM/CJS interop behavior under these circumstances, which TypeScript cannot currently analyze with "moduleResolution": "bundler". See issue #54102 for more information.

(Quasar wants "type": "module" soon)

In short, "moduleResolution": "bundler" is infectious, allowing code that only works in bundlers to be produced. Likewise, "moduleResolution": "nodenext" is only checking that the output works in Node.js, but in most cases, module code that works in Node.js will work in other runtimes and in bundlers.

https://www.typescriptlang.org/docs/handbook/modules/guides/choosing-compiler-options.html

@DerYeger
Copy link
Owner

I don't think my library violates the NodeNext spec, since it works fine with tsc, just not vue-tsc.

I also don't think the "infectious" nature of "moduleResolution": "bundler" applies to my library, because it's built using a custom Vite plugin that adds missing file types to imports and exports (see https://www.npmjs.com/package/@yeger/vue-masonry-wall?activeTab=code).

@DerYeger DerYeger added invalid This doesn't seem right and removed bug Something isn't working labels Apr 1, 2024
@MartinX3
Copy link
Author

MartinX3 commented Apr 1, 2024

Thank you.
I switch to ESNext and Bundler to use your plugin.
Then also vue-tsc doesn't complain and I can continue to use it.
At least I don't need to use node / node10 anymore.

I just wondered why I only get the error message with your plugin. :D

@MartinX3 MartinX3 closed this as completed Apr 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
invalid This doesn't seem right
Projects
None yet
Development

No branches or pull requests

2 participants