Skip to content

Commit 760461d

Browse files
authored
Merge pull request #90 from cloudblue/feature/LITE-29730-migrate-to-esm-and-from-webpack-to-vite
Feature/lite 29730 migrate to esm and from webpack to vite
2 parents f74f5d6 + cf7b391 commit 760461d

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

60 files changed

+9005
-20944
lines changed

.eslintrc.js renamed to .eslintrc.cjs

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ module.exports = {
1717
'plugin:storybook/recommended',
1818
'prettier',
1919
'@vue/eslint-config-prettier/skip-formatting',
20+
'plugin:vitest-globals/recommended',
2021
],
2122

2223
plugins: ['vue'],
@@ -34,21 +35,15 @@ module.exports = {
3435
'vue/attribute-hyphenation': ['error', 'never'],
3536
},
3637

37-
overrides: [
38-
// Config for unit tests
39-
{
40-
files: ['*.spec.js'],
41-
plugins: ['jest'],
42-
extends: ['plugin:jest/recommended', 'plugin:jest-formatting/strict'],
43-
env: {
44-
jest: true,
45-
'jest/globals': true,
46-
},
47-
globals: {
48-
global: 'writable',
49-
},
50-
},
38+
env: {
39+
'vitest-globals/env': true,
40+
},
5141

42+
parserOptions: {
43+
ecmaVersion: 'latest',
44+
},
45+
46+
overrides: [
5247
// Config for files that run in node env (config files, etc)
5348
{
5449
files: ['*.config.js', '.eslintrc.js'],

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ dist-ssr
1313
coverage
1414
*.local
1515

16+
/test/report.json
17+
1618
/cypress/videos/
1719
/cypress/screenshots/
1820

.storybook/main.js

Lines changed: 8 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
const path = require('node:path');
2-
3-
module.exports = {
1+
export default {
42
stories: [
53
'../components/src/**/*.stories.@(js|jsx|ts|tsx|vue)',
64
'../components/src/stories/**/*.mdx',
@@ -12,56 +10,22 @@ module.exports = {
1210
'@storybook/addon-links',
1311
'@storybook/addon-essentials',
1412
'@storybook/addon-interactions',
15-
'@storybook/addon-designs',
16-
'storybook-vue-addon',
17-
'storybook-addon-vue-mdx',
13+
{ name: '@storybook/addon-designs', options: { renderTarget: 'tab' } },
1814
],
1915

2016
framework: {
21-
name: '@storybook/vue3-webpack5',
22-
options: {},
17+
name: '@storybook/vue3-vite',
18+
options: {
19+
builder: {
20+
viteConfigPath: './components/vite.config.js',
21+
},
22+
},
2323
},
2424

2525
features: {
2626
interactionsDebugger: true,
2727
},
2828

29-
webpackFinal: async (config) => {
30-
config.module.rules.push({
31-
test: /\.svg/,
32-
type: 'asset/source',
33-
loader: 'svgo-loader',
34-
options: {
35-
configFile: require.resolve('../components/svgo.config.js'),
36-
},
37-
});
38-
39-
// Find Vue webpack rule and update its options to work with custom elements
40-
const vueRule = config.module.rules.find((rule) => rule.test?.toString() === '/\\.vue$/');
41-
vueRule.options = {
42-
...vueRule.options,
43-
customElement: true,
44-
compilerOptions: {
45-
isCustomElement: (tag) => tag.startsWith('ui-'),
46-
},
47-
};
48-
49-
config.module.rules.push({
50-
test: /\.styl(us)$/,
51-
use: ['vue-style-loader', 'css-loader', 'stylus-loader'],
52-
});
53-
54-
config.resolve.alias = {
55-
vue: path.resolve(__dirname, '../node_modules/vue/dist/vue.esm-bundler.js'),
56-
'~core': path.resolve(__dirname, '../components/src/core'),
57-
'~widgets': path.resolve(__dirname, '../components/src/widgets'),
58-
'~constants': path.resolve(__dirname, '../components/src/constants'),
59-
'~composables': path.resolve(__dirname, '../components/src/composables'),
60-
};
61-
62-
return config;
63-
},
64-
6529
docs: {
6630
autodocs: true,
6731
},

.storybook/manager.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
import { addons } from '@storybook/addons';
2-
import { themes } from '@storybook/theming';
1+
import { addons } from '@storybook/manager-api';
32
import cloudBlueTheme from './CloudBlueTheme';
43

54
addons.setConfig({

.storybook/preview.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import './global-styles.css';
2+
import './stories.css';
23

34
export const parameters = {
4-
actions: { argTypesRegex: '^on[A-Z].*' },
55
controls: {
66
matchers: {
77
color: /(background|color)$/i,

.storybook/stories.css

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
.sb-all-icons {
2+
margin-top: 24px;
3+
width: 100%;
4+
display: flex;
5+
flex-wrap: wrap;
6+
}
7+
8+
.sb-icon-wrapper {
9+
width: calc(33% - 10px);
10+
margin-bottom: 20px;
11+
margin-right: 10px;
12+
display: flex;
13+
align-items: center;
14+
}
15+
.sb-icon {
16+
margin-right: 4px;
17+
}

components/babel.config.js

Lines changed: 0 additions & 3 deletions
This file was deleted.

components/jest.config.js

Lines changed: 0 additions & 44 deletions
This file was deleted.

components/src/composables/validation.spec.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ describe('validation composables', () => {
1111

1212
beforeEach(() => {
1313
model = ref('');
14-
rule = jest.fn().mockReturnValue(true);
14+
rule = vi.fn().mockReturnValue(true);
1515
rules = [rule];
1616
});
1717

components/src/core/injector/core/Core.spec.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ describe('Core', () => {
2424
[{ test: 123 }, null],
2525
[null, { test: 123 }],
2626
])('should do nothing while $state is %j and data is %j', (state, data) => {
27-
global.Object.keys = jest.fn(Object.keys);
27+
global.Object.keys = vi.fn(Object.keys);
2828
core.state = state;
2929
core.assign(data);
3030

@@ -53,7 +53,7 @@ describe('Core', () => {
5353
};
5454

5555
core.watchers = {
56-
test: [jest.fn()],
56+
test: [vi.fn()],
5757
};
5858

5959
core.assign({
@@ -71,7 +71,7 @@ describe('Core', () => {
7171
};
7272

7373
core.watchers = {
74-
'*': [jest.fn()],
74+
'*': [vi.fn()],
7575
};
7676

7777
core.assign({

0 commit comments

Comments
 (0)