-
-
Notifications
You must be signed in to change notification settings - Fork 594
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
Vetur config file RFC #2378
Vetur config file RFC #2378
Conversation
This is really great! I have nothing to comment at the moment, everything seems ideal (I don't use monorepos thought so I can't debate on this) |
I'd exclude this alternative, as there are other CLIs (Nuxt, Quasar, etc) which needs Vetur Into "properties details > definition" you use Have you checked other frameworks config files for tasks similar to this? Angular/React/whatever? If yes, is it possible to have link to relevant resources/inspiration? |
5d1feb2
to
1bff568
Compare
Thanks. My first inspiration came from The React and Angular are all officially supported by TypeScript for monorepo support. |
I extend |
Grammar for |
I rename to |
|
rfcs/001-vetur-config-file.md
Outdated
|
||
export interface VeturConfig { | ||
settings?: { [key: string]: boolean | string | Enum }, | ||
repos?: Array<{ |
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.
repos
is more connected to git repositories, and I get it, it's coming from monorepos but I feel it's not conveying the purpose.
Suggestion: We can call it projects
. (typescript has project references and that makes it some what similar)
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.
Maybe workspaces?
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 agree. projects
is better.
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 like the "workspaces" name or maybe workingDirectories (stolen from eslint extension 😜)
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.
workspaces also sounds good as package managers have those.
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.
The workspaces
word is also used for multi roots in VSCode.
It's a bit confusing.
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.
As long as it's clear what it meant, it's ok, so +1 for projects.
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.
Probably also allow a shorthand form, so
Array<string | {
root: string,
package?: string,
tsconfig?: string,
globalComponents?: Array<Glob | { name: string, path: string }
>
Where string
value is root
.
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.
It's a good idea.
I changed the RFC.
root: string, | ||
package?: string, | ||
tsconfig?: string, | ||
globalComponents?: Array<Glob | { name: string, path: string }> |
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.
How about "extends"
option to share configurations?
e.g.
module.export = {
projects: [{
extends: ["vuetify"],
globalComponents: ["./src/components/**/*.vue"]
}]
}
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 understand what this setting means.
I think if we're going to share configurations, we can only use JS. Like require
.
PS. When you use vuetify
on package.json, we use component date to completion.
So you don't really need to define vuetify
here!
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.
Similar to tsconfig but it doesn't makes sense in cjs.
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.
@znck I don't feel we need this. When you have:
vuetify
listed in pointed package.json's dependenciesnode_modules/vuetify/package.json
hasvetur
key
Everything should work from there.
Unless you meant something else.
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.
We need to support opt-in for external global components. (user can register, only a few components)
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.
@znck What's a use case for that? If I understand you correctly, do you mean for the case when you have 2 UI lib and only want auto-completion for one of them (or only a few components out of a full library)? I feel there isn't much downside to just registering a whole library.
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.
Mainly for type checking global components. If it's opt-in you can control what components are allowed globally.
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 would prefer to use cjs directly.
module.export = {
projects: [{
globalComponents: [
...require('vuetify').components,
"./src/components/**/*.vue"
]
}]
}
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 also think there's no point in adding an external lib.
We don't know the details of external libs.
It may be difficult to get the correct TypeScript type when no correct tsconfig.json
.
I would be inclined to expand the support for component data.
Let it have a type of marker.
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.
In the TS plugin, I am using this to infer component meta. (It has a different structure compared to vetur's spec but includes verbose static information).
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, except 2 small things:
repos
->projects
- Allow
projects
to be an array of either the shortform (just a string pointing toroot
) or the longer form (root/package/tsconfig/globalComponents
).
rfcs/001-vetur-config-file.md
Outdated
|
||
export interface VeturConfig { | ||
settings?: { [key: string]: boolean | string | Enum }, | ||
repos?: Array<{ |
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.
Probably also allow a shorthand form, so
Array<string | {
root: string,
package?: string,
tsconfig?: string,
globalComponents?: Array<Glob | { name: string, path: string }
>
Where string
value is root
.
root: string, | ||
package?: string, | ||
tsconfig?: string, | ||
globalComponents?: Array<Glob | { name: string, path: string }> |
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.
@znck What's a use case for that? If I understand you correctly, do you mean for the case when you have 2 UI lib and only want auto-completion for one of them (or only a few components out of a full library)? I feel there isn't much downside to just registering a whole library.
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, thanks for addressing the feedback.
How would named component from external module work? import { Foo } from 'foo'
app.component('MyFoo', Foo) |
This RFC don't solves this problem. The main goal is to resolve the registration of global components in own project in this RFC. |
In the TS plugin, I am using the following data structure for the project config. export interface ImportSource {
moduleName: string
exportName?: string
}
export interface ProjectConfig {
root: string
package?: string
tsconfig?: string
globalComponents: Array<string | Record<string, string | ImportSource>>
} |
What is the purpose of |
I think we can keep it that way for now. |
The vetur will use this option to open the ts language service. |
TS Plugin can only use |
You may also want to refer to the |
fb6cf94
to
dbc38bf
Compare
Can you set the vetur version here, so that accidental upgrades don't cause problems? |
It's practically impossible. |
Vetur configuration file.
Rendered