Skip to content

Commit

Permalink
fix(plugin-solid): remove @babel/preset-typescript for resolve the …
Browse files Browse the repository at this point in the history
…babel warning
  • Loading branch information
zhylmzr committed Jul 8, 2024
1 parent 356ffa2 commit d6b4f74
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 35 deletions.
12 changes: 7 additions & 5 deletions packages/plugin-solid/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,13 @@ export function pluginSolid(options: PluginSolidOptions = {}): RsbuildPlugin {
chain,
CHAIN_ID,
modifier: (babelOptions) => {
babelOptions.presets ??= [];
babelOptions.presets.push([
require.resolve('babel-preset-solid'),
options.solidPresetOptions || {},
]);
babelOptions.presets = [
[
require.resolve('babel-preset-solid'),
options.solidPresetOptions || {},
],
];
babelOptions.parserOpts = { plugins: ['jsx', 'typescript'] };

const usingHMR =
!isProd && environmentConfig.dev.hmr && target === 'web';
Expand Down
48 changes: 18 additions & 30 deletions packages/plugin-solid/tests/__snapshots__/index.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,12 @@ exports[`plugin-solid > should allow to configure solid preset options 1`] = `
"babelrc": false,
"compact": false,
"configFile": false,
"parserOpts": {
"plugins": [
"jsx",
"typescript",
],
},
"plugins": [
[
"<ROOT>/node_modules/<PNPM_INNER>/@babel/plugin-proposal-decorators/lib/index.js",
Expand All @@ -25,16 +31,6 @@ exports[`plugin-solid > should allow to configure solid preset options 1`] = `
],
],
"presets": [
[
"<ROOT>/node_modules/<PNPM_INNER>/@babel/preset-typescript/lib/index.js",
{
"allExtensions": true,
"allowDeclareFields": true,
"allowNamespaces": true,
"isTSX": true,
"optimizeConstEnums": true,
},
],
[
"<ROOT>/node_modules/<PNPM_INNER>/babel-preset-solid/index.js",
{
Expand Down Expand Up @@ -70,6 +66,12 @@ exports[`plugin-solid > should apply solid preset correctly 1`] = `
"babelrc": false,
"compact": false,
"configFile": false,
"parserOpts": {
"plugins": [
"jsx",
"typescript",
],
},
"plugins": [
[
"<ROOT>/node_modules/<PNPM_INNER>/@babel/plugin-proposal-decorators/lib/index.js",
Expand All @@ -82,16 +84,6 @@ exports[`plugin-solid > should apply solid preset correctly 1`] = `
],
],
"presets": [
[
"<ROOT>/node_modules/<PNPM_INNER>/@babel/preset-typescript/lib/index.js",
{
"allExtensions": true,
"allowDeclareFields": true,
"allowNamespaces": true,
"isTSX": true,
"optimizeConstEnums": true,
},
],
[
"<ROOT>/node_modules/<PNPM_INNER>/babel-preset-solid/index.js",
{},
Expand Down Expand Up @@ -124,6 +116,12 @@ exports[`plugin-solid > should apply solid preset correctly in rspack mode 1`] =
"babelrc": false,
"compact": false,
"configFile": false,
"parserOpts": {
"plugins": [
"jsx",
"typescript",
],
},
"plugins": [
[
"<ROOT>/node_modules/<PNPM_INNER>/@babel/plugin-proposal-decorators/lib/index.js",
Expand All @@ -136,16 +134,6 @@ exports[`plugin-solid > should apply solid preset correctly in rspack mode 1`] =
],
],
"presets": [
[
"<ROOT>/node_modules/<PNPM_INNER>/@babel/preset-typescript/lib/index.js",
{
"allExtensions": true,
"allowDeclareFields": true,
"allowNamespaces": true,
"isTSX": true,
"optimizeConstEnums": true,
},
],
[
"<ROOT>/node_modules/<PNPM_INNER>/babel-preset-solid/index.js",
{},
Expand Down

0 comments on commit d6b4f74

Please sign in to comment.