Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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: component exports #166
fix: component exports #166
Changes from 4 commits
d043cd4
49bd123
2fe0cc7
0829928
d3108ec
b6f0e11
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's add
components
directory inexports
and not justMDCRenderer
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't believe this is possible with the current state of the repo and exported types.
There is no generated
runtime/components/index.mjs
so we can't import directly from there. Also, theMDC.vue
component and none of theruntime/components/prose/*.vue
files are generating types in the build.If we created a
runtime/components/index.ts
file that exported all of the components (a barrel file) it would then trigger the proper exports, but could have an impact on tree-shaking; however, the other components likeMDC.vue
utilize Nuxt-specific imports, meaning it would actually break using in a non-Nuxt project.Since only the
MDCRenderer.vue
component was "cleaned" of Nuxt imports, exporting anything else as-is would break 😬Good with this for now, or any ideas?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@farnabaz here's the updated info.
As for the tests, if I was going to write something I'd likely just want to use
vitest
along with@vue/test-utils
so that I can ensure nothing from the Nuxt app is required. I'd need to add that package as adevDependency
; any issues there?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not just use
"./runtime/components/*": "./dist/runtime/components/*",
in package exports? Then we can import likeimport MDCRenderer from '@nuxtjs/mdc/runtime/components/MDCRenderer.vue';
Vitest and Vue test-utils seems fine for me 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@farnabaz I adjusted the exports in d3108ec to this:
For the
types
property, I had to add*.d.ts
in order to properly resolve the component types.Technically this doesn't allow for importing types from the nested
/runtime/components/prose/*
components, but thebuild
command doesn't generate declaration files for these components anyway, so I think it's fine?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 👍
We can update those components later to generate ts file