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

SWC: Set default targets for swc that align with our esbuild targets #28435

Merged
merged 1 commit into from
Jul 3, 2024
Merged
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
Original file line number Diff line number Diff line change
@@ -1,10 +1,28 @@
import * as webpackReal from 'webpack';
import { logger } from 'storybook/internal/node-logger';
import type { Options } from 'storybook/internal/types';
import type { Options, PresetProperty } from 'storybook/internal/types';
import type { Configuration } from 'webpack';
import { loadCustomWebpackConfig } from '@storybook/core-webpack';
import { createDefaultWebpackConfig } from '../preview/base-webpack.config';

export const swc: PresetProperty<'swc'> = (config: Record<string, any>): Record<string, any> => {
return {
...config,
env: {
...(config?.env ?? {}),
targets: config?.env?.targets ?? {
chrome: 100,
safari: 15,
firefox: 91,
},
// Transpiles the broken syntax to the closest non-broken modern syntax.
// E.g. it won't transpile parameter destructuring in Safari
// which would break how we detect if the mount context property is used in the play function.
bugfixes: config?.env?.bugfixes ?? true,
},
};
};

export async function webpack(config: Configuration, options: Options) {
const { configDir, configType, presets } = options;

Expand Down
Loading