Skip to content

Commit

Permalink
chore: use plugin instead of preset
Browse files Browse the repository at this point in the history
  • Loading branch information
yuusheng committed Jan 10, 2024
1 parent 3fba8bf commit f5d3a16
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 60 deletions.
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,13 @@
"@babel/plugin-proposal-decorators": "^7.23.6",
"@babel/plugin-syntax-class-properties": "^7.12.13",
"@babel/plugin-syntax-import-assertions": "^7.23.3",
"@babel/plugin-syntax-jsx": "^7.23.3",
"@babel/plugin-transform-export-namespace-from": "^7.23.4",
"@babel/plugin-transform-modules-commonjs": "^7.23.3",
"@babel/plugin-transform-nullish-coalescing-operator": "^7.23.4",
"@babel/plugin-transform-optional-chaining": "^7.23.4",
"@babel/plugin-transform-react-jsx": "^7.23.4",
"@babel/plugin-transform-typescript": "^7.23.6",
"@babel/preset-react": "^7.23.3",
"@babel/preset-typescript": "^7.23.3",
"@babel/template": "^7.22.15",
"@babel/types": "^7.23.6",
Expand Down
55 changes: 6 additions & 49 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 9 additions & 10 deletions src/babel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,16 +45,15 @@ export default function transform(opts: TransformOptions): TRANSFORM_RESULT {
}

if (opts.jsx) {
if (!_opts.presets) {
_opts.presets = [];
}

_opts.presets.push([
require("@babel/preset-react"),
{
...(typeof opts.jsx === "object" ? opts.jsx : {}),
},
]);
_opts.plugins.push(require("@babel/plugin-syntax-jsx"))
_opts.plugins.push(
[
require('@babel/plugin-transform-react-jsx'),
{
...(typeof opts.jsx === "object" ? opts.jsx : {}),
},
]
);
}

if (opts.legacy) {
Expand Down

0 comments on commit f5d3a16

Please sign in to comment.