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

DO NOT MERGE: Lit components test #6807

Draft
wants to merge 7 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 48 additions & 2 deletions shared/web-components-vite-plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,52 @@ export function useLocalWebComponents(webComponentsNodeModulesPath: string): Plu
if (/^(@polymer|@vaadin)/.test(id)) {
return this.resolve(path.join(webComponentsNodeModulesPath, id));
}
},
}
}
};
}

/**
* Vite plugin that resolves Vaadin web components to Lit versions
*/
export function useLitWebComponents(): PluginOption {
return {
name: 'use-lit-web-components',
config() {
return {
resolve: {
alias: [
'accordion',
'accordion-panel',
'app-layout',
'drawer-toggle',
'avatar',
'avatar-group',
'context-menu',
'custom-field',
'details',
'dialog',
'horizontal-layout',
'list-box',
'item',
'notification',
'radio-button',
'radio-button-group',
'scroller',
'split-layout',
'tabs',
'tab',
'tabsheet',
'vertical-layout'
].flatMap((component) => {
return [
{
find: new RegExp(`^@vaadin/[^\/]+\/(src\/)?vaadin-${component}.js`),
replacement: `@vaadin/[^\/]+/$1vaadin-lit-${component}.js`
}
];
})
}
};
}
};
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { UserConfigFn } from 'vite';
// @ts-ignore can not be resolved until Flow generates base Vite config
import { overrideVaadinConfig } from './vite.generated';
// import { useLocalWebComponents } from '../../shared/web-components-vite-plugin';
import { useLitWebComponents } from '../../shared/web-components-vite-plugin';

const customConfig: UserConfigFn = (env) => ({
// Here you can add custom Vite parameters
Expand All @@ -18,6 +19,9 @@ const customConfig: UserConfigFn = (env) => ({
useLocalWebComponents('/path/to/web-components/node_modules')
]
*/
plugins: [
useLitWebComponents()
]
});

export default overrideVaadinConfig(customConfig);
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { UserConfigFn } from 'vite';
// @ts-ignore can not be resolved until Flow generates base Vite config
import { overrideVaadinConfig } from './vite.generated';
// import { useLocalWebComponents } from '../../shared/web-components-vite-plugin';
import { useLitWebComponents } from '../../shared/web-components-vite-plugin';

const customConfig: UserConfigFn = (env) => ({
// Here you can add custom Vite parameters
Expand All @@ -18,6 +19,9 @@ const customConfig: UserConfigFn = (env) => ({
useLocalWebComponents('/path/to/web-components/node_modules')
]
*/
plugins: [
useLitWebComponents()
]
});

export default overrideVaadinConfig(customConfig);
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { UserConfigFn } from 'vite';
// @ts-ignore can not be resolved until Flow generates base Vite config
import { overrideVaadinConfig } from './vite.generated';
// import { useLocalWebComponents } from '../../shared/web-components-vite-plugin';
import { useLitWebComponents } from '../../shared/web-components-vite-plugin';

const customConfig: UserConfigFn = (env) => ({
// Here you can add custom Vite parameters
Expand All @@ -18,6 +19,9 @@ const customConfig: UserConfigFn = (env) => ({
useLocalWebComponents('/path/to/web-components/node_modules')
]
*/
plugins: [
useLitWebComponents()
]
});

export default overrideVaadinConfig(customConfig);
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { UserConfigFn } from 'vite';
// @ts-ignore can not be resolved until Flow generates base Vite config
import { overrideVaadinConfig } from './vite.generated';
// import { useLocalWebComponents } from '../../shared/web-components-vite-plugin';
import { useLitWebComponents } from '../../shared/web-components-vite-plugin';

const customConfig: UserConfigFn = (env) => ({
// Here you can add custom Vite parameters
Expand All @@ -18,6 +19,9 @@ const customConfig: UserConfigFn = (env) => ({
useLocalWebComponents('/path/to/web-components/node_modules')
]
*/
plugins: [
useLitWebComponents()
]
});

export default overrideVaadinConfig(customConfig);
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { UserConfigFn } from 'vite';
// @ts-ignore can not be resolved until Flow generates base Vite config
import { overrideVaadinConfig } from './vite.generated';
// import { useLocalWebComponents } from '../../shared/web-components-vite-plugin';
import { useLitWebComponents } from '../../shared/web-components-vite-plugin';

const customConfig: UserConfigFn = (env) => ({
// Here you can add custom Vite parameters
Expand All @@ -18,6 +19,9 @@ const customConfig: UserConfigFn = (env) => ({
useLocalWebComponents('/path/to/web-components/node_modules')
]
*/
plugins: [
useLitWebComponents()
]
});

export default overrideVaadinConfig(customConfig);
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { UserConfigFn } from 'vite';
// @ts-ignore can not be resolved until Flow generates base Vite config
import { overrideVaadinConfig } from './vite.generated';
// import { useLocalWebComponents } from '../../shared/web-components-vite-plugin';
import { useLitWebComponents } from '../../shared/web-components-vite-plugin';

const customConfig: UserConfigFn = (env) => ({
// Here you can add custom Vite parameters
Expand All @@ -18,6 +19,7 @@ const customConfig: UserConfigFn = (env) => ({
useLocalWebComponents('/path/to/web-components/node_modules')
]
*/
plugins: [useLitWebComponents()]
});

export default overrideVaadinConfig(customConfig);
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { UserConfigFn } from 'vite';
// @ts-ignore can not be resolved until Flow generates base Vite config
import { overrideVaadinConfig } from './vite.generated';
// import { useLocalWebComponents } from '../../shared/web-components-vite-plugin';
import { useLitWebComponents } from '../../shared/web-components-vite-plugin';

const customConfig: UserConfigFn = (env) => ({
// Here you can add custom Vite parameters
Expand All @@ -18,6 +19,9 @@ const customConfig: UserConfigFn = (env) => ({
useLocalWebComponents('/path/to/web-components/node_modules')
]
*/
plugins: [
useLitWebComponents()
]
});

export default overrideVaadinConfig(customConfig);
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { UserConfigFn } from 'vite';
// @ts-ignore can not be resolved until Flow generates base Vite config
import { overrideVaadinConfig } from './vite.generated';
// import { useLocalWebComponents } from '../../shared/web-components-vite-plugin';
import { useLitWebComponents } from '../../shared/web-components-vite-plugin';

const customConfig: UserConfigFn = (env) => ({
// Here you can add custom Vite parameters
Expand All @@ -18,6 +19,9 @@ const customConfig: UserConfigFn = (env) => ({
useLocalWebComponents('/path/to/web-components/node_modules')
]
*/
plugins: [
useLitWebComponents()
]
});

export default overrideVaadinConfig(customConfig);
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { UserConfigFn } from 'vite';
// @ts-ignore can not be resolved until Flow generates base Vite config
import { overrideVaadinConfig } from './vite.generated';
// import { useLocalWebComponents } from '../../shared/web-components-vite-plugin';
import { useLitWebComponents } from '../../shared/web-components-vite-plugin';

const customConfig: UserConfigFn = (env) => ({
// Here you can add custom Vite parameters
Expand All @@ -18,6 +19,9 @@ const customConfig: UserConfigFn = (env) => ({
useLocalWebComponents('/path/to/web-components/node_modules')
]
*/
plugins: [
useLitWebComponents()
]
});

export default overrideVaadinConfig(customConfig);
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { UserConfigFn } from 'vite';
// @ts-ignore can not be resolved until Flow generates base Vite config
import { overrideVaadinConfig } from './vite.generated';
// import { useLocalWebComponents } from '../../shared/web-components-vite-plugin';
import { useLitWebComponents } from '../../shared/web-components-vite-plugin';

const customConfig: UserConfigFn = (env) => ({
// Here you can add custom Vite parameters
Expand All @@ -18,6 +19,9 @@ const customConfig: UserConfigFn = (env) => ({
useLocalWebComponents('/path/to/web-components/node_modules')
]
*/
plugins: [
useLitWebComponents()
]
});

export default overrideVaadinConfig(customConfig);
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { UserConfigFn } from 'vite';
// @ts-ignore can not be resolved until Flow generates base Vite config
import { overrideVaadinConfig } from './vite.generated';
// import { useLocalWebComponents } from '../../shared/web-components-vite-plugin';
import { useLitWebComponents } from '../../shared/web-components-vite-plugin';

const customConfig: UserConfigFn = (env) => ({
// Here you can add custom Vite parameters
Expand All @@ -18,6 +19,9 @@ const customConfig: UserConfigFn = (env) => ({
useLocalWebComponents('/path/to/web-components/node_modules')
]
*/
plugins: [
useLitWebComponents()
]
});

export default overrideVaadinConfig(customConfig);
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { UserConfigFn } from 'vite';
// @ts-ignore can not be resolved until Flow generates base Vite config
import { overrideVaadinConfig } from './vite.generated';
// import { useLocalWebComponents } from '../../shared/web-components-vite-plugin';
import { useLitWebComponents } from '../../shared/web-components-vite-plugin';

const customConfig: UserConfigFn = (env) => ({
// Here you can add custom Vite parameters
Expand All @@ -18,6 +19,9 @@ const customConfig: UserConfigFn = (env) => ({
useLocalWebComponents('/path/to/web-components/node_modules')
]
*/
plugins: [
useLitWebComponents()
]
});

export default overrideVaadinConfig(customConfig);
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { UserConfigFn } from 'vite';
// @ts-ignore can not be resolved until Flow generates base Vite config
import { overrideVaadinConfig } from './vite.generated';
// import { useLocalWebComponents } from '../../shared/web-components-vite-plugin';
import { useLitWebComponents } from '../../shared/web-components-vite-plugin';

const customConfig: UserConfigFn = (env) => ({
// Here you can add custom Vite parameters
Expand All @@ -18,6 +19,9 @@ const customConfig: UserConfigFn = (env) => ({
useLocalWebComponents('/path/to/web-components/node_modules')
]
*/
plugins: [
useLitWebComponents()
]
});

export default overrideVaadinConfig(customConfig);
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { UserConfigFn } from 'vite';
// @ts-ignore can not be resolved until Flow generates base Vite config
import { overrideVaadinConfig } from './vite.generated';
// import { useLocalWebComponents } from '../../shared/web-components-vite-plugin';
import { useLitWebComponents } from '../../shared/web-components-vite-plugin';

const customConfig: UserConfigFn = (env) => ({
// Here you can add custom Vite parameters
Expand All @@ -18,6 +19,9 @@ const customConfig: UserConfigFn = (env) => ({
useLocalWebComponents('/path/to/web-components/node_modules')
]
*/
plugins: [
useLitWebComponents()
]
});

export default overrideVaadinConfig(customConfig);
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { UserConfigFn } from 'vite';
// @ts-ignore can not be resolved until Flow generates base Vite config
import { overrideVaadinConfig } from './vite.generated';
// import { useLocalWebComponents } from '../../shared/web-components-vite-plugin';
import { useLitWebComponents } from '../../shared/web-components-vite-plugin';

const customConfig: UserConfigFn = (env) => ({
// Here you can add custom Vite parameters
Expand All @@ -18,6 +19,9 @@ const customConfig: UserConfigFn = (env) => ({
useLocalWebComponents('/path/to/web-components/node_modules')
]
*/
plugins: [
useLitWebComponents()
]
});

export default overrideVaadinConfig(customConfig);
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { UserConfigFn } from 'vite';
// @ts-ignore can not be resolved until Flow generates base Vite config
import { overrideVaadinConfig } from './vite.generated';
// import { useLocalWebComponents } from '../../shared/web-components-vite-plugin';
import { useLitWebComponents } from '../../shared/web-components-vite-plugin';

const customConfig: UserConfigFn = (env) => ({
// Here you can add custom Vite parameters
Expand All @@ -18,6 +19,9 @@ const customConfig: UserConfigFn = (env) => ({
useLocalWebComponents('/path/to/web-components/node_modules')
]
*/
plugins: [
useLitWebComponents()
]
});

export default overrideVaadinConfig(customConfig);
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { UserConfigFn } from 'vite';
// @ts-ignore can not be resolved until Flow generates base Vite config
import { overrideVaadinConfig } from './vite.generated';
// import { useLocalWebComponents } from '../../shared/web-components-vite-plugin';
import { useLitWebComponents } from '../../shared/web-components-vite-plugin';

const customConfig: UserConfigFn = (env) => ({
// Here you can add custom Vite parameters
Expand All @@ -18,6 +19,9 @@ const customConfig: UserConfigFn = (env) => ({
useLocalWebComponents('/path/to/web-components/node_modules')
]
*/
plugins: [
useLitWebComponents()
]
});

export default overrideVaadinConfig(customConfig);
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { UserConfigFn } from 'vite';
// @ts-ignore can not be resolved until Flow generates base Vite config
import { overrideVaadinConfig } from './vite.generated';
// import { useLocalWebComponents } from '../../shared/web-components-vite-plugin';
import { useLitWebComponents } from '../../shared/web-components-vite-plugin';

const customConfig: UserConfigFn = (env) => ({
// Here you can add custom Vite parameters
Expand All @@ -18,6 +19,9 @@ const customConfig: UserConfigFn = (env) => ({
useLocalWebComponents('/path/to/web-components/node_modules')
]
*/
plugins: [
useLitWebComponents()
]
});

export default overrideVaadinConfig(customConfig);
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { UserConfigFn } from 'vite';
// @ts-ignore can not be resolved until Flow generates base Vite config
import { overrideVaadinConfig } from './vite.generated';
// import { useLocalWebComponents } from '../../shared/web-components-vite-plugin';
import { useLitWebComponents } from '../../shared/web-components-vite-plugin';

const customConfig: UserConfigFn = (env) => ({
// Here you can add custom Vite parameters
Expand All @@ -18,6 +19,9 @@ const customConfig: UserConfigFn = (env) => ({
useLocalWebComponents('/path/to/web-components/node_modules')
]
*/
plugins: [
useLitWebComponents()
]
});

export default overrideVaadinConfig(customConfig);
Loading