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

Build: Migrate @storybook/preset-vue-webpack to strict TS #22320

Merged
merged 2 commits into from
May 1, 2023
Merged
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
4 changes: 2 additions & 2 deletions code/presets/vue-webpack/src/framework-preset-vue-docs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,15 @@ export const webpackFinal: StorybookConfig['webpackFinal'] = (config, options) =
}
});

config.module.rules.push({
config.module?.rules?.push({
test: /\.vue$/,
loader: require.resolve('vue-docgen-loader', {
paths: [require.resolve('@storybook/preset-vue-webpack')],
}),
enforce: 'post',
options: {
docgenOptions: {
alias: config.resolve.alias,
alias: config.resolve?.alias,
...vueDocgenOptions,
},
},
Expand Down
24 changes: 13 additions & 11 deletions code/presets/vue-webpack/src/framework-preset-vue.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,30 +4,27 @@ import { VueLoaderPlugin } from 'vue-loader';
import type { StorybookConfig } from '@storybook/core-webpack';

export const webpack: StorybookConfig['webpack'] = async (config, { presets }) => {
const typescriptOptions = await presets.apply<StorybookConfig['typescript']>(
'typescript',
{} as any
);
const typescriptOptions = await presets.apply<StorybookConfig['typescript']>('typescript', {});

config.plugins.push(new VueLoaderPlugin());
config.module.rules.push({
config.plugins?.push(new VueLoaderPlugin());
config.module?.rules?.push({
test: /\.vue$/,
loader: require.resolve('vue-loader'),
options: {},
});
config.module.rules.push({
config.module?.rules?.push({
test: /\.ts$/,
use: [
{
loader: require.resolve('ts-loader'),
options: {
transpileOnly: !typescriptOptions.check,
transpileOnly: !typescriptOptions?.check,
appendTsSuffixTo: [/\.vue$/],
},
},
],
});
config.module.rules.push({
config.module?.rules?.push({
test: /\.tsx$/,
use: [
{
Expand All @@ -40,8 +37,13 @@ export const webpack: StorybookConfig['webpack'] = async (config, { presets }) =
],
});

config.resolve.extensions.push('.vue');
config.resolve.alias = { ...config.resolve.alias, vue$: require.resolve('vue/dist/vue.esm.js') };
if (config.resolve) {
config.resolve.extensions?.push('.vue');
config.resolve.alias = {
...config.resolve.alias,
vue$: require.resolve('vue/dist/vue.esm.js'),
};
}

return config;
};
2 changes: 1 addition & 1 deletion code/presets/vue-webpack/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"compilerOptions": {
"skipLibCheck": true,
"resolveJsonModule": true,
"strict": false
"strict": true
},
"include": ["src/**/*"]
}