-
-
Notifications
You must be signed in to change notification settings - Fork 9.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #22075 from storybookjs/norbert/other-secret-project
storybook webpack builder to use swc instead of babel
- Loading branch information
Showing
7 changed files
with
201 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 0 additions & 20 deletions
20
code/lib/builder-webpack5/src/preview/babel-loader-preview.ts
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
import { getProjectRoot } from '@storybook/core-common'; | ||
import type { Options } from '@swc/core'; | ||
import { dedent } from 'ts-dedent'; | ||
import { logger } from '@storybook/node-logger'; | ||
import type { TypescriptOptions } from '../types'; | ||
|
||
export const createBabelLoader = ( | ||
options: any, | ||
typescriptOptions: TypescriptOptions, | ||
excludes: string[] = [] | ||
) => { | ||
return { | ||
test: typescriptOptions.skipBabel ? /\.(mjs|jsx?)$/ : /\.(mjs|tsx?|jsx?)$/, | ||
use: [ | ||
{ | ||
loader: require.resolve('babel-loader'), | ||
options, | ||
}, | ||
], | ||
include: [getProjectRoot()], | ||
exclude: [/node_modules/, ...excludes], | ||
}; | ||
}; | ||
|
||
export const createSWCLoader = (excludes: string[] = []) => { | ||
logger.warn(dedent` | ||
The SWC loader is an experimental feature and may change or even be removed at any time. | ||
`); | ||
|
||
const config: Options = { | ||
jsc: { | ||
parser: { | ||
syntax: 'typescript', | ||
tsx: true, | ||
dynamicImport: true, | ||
}, | ||
}, | ||
}; | ||
return { | ||
test: /\.(mjs|cjs|tsx?|jsx?)$/, | ||
use: [ | ||
{ | ||
loader: require.resolve('swc-loader'), | ||
options: config, | ||
}, | ||
], | ||
include: [getProjectRoot()], | ||
exclude: [/node_modules/, ...excludes], | ||
}; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters