chore: emit dts by oxc

This commit is contained in:
三咲智子 Kevin Deng
2025-08-10 09:05:18 +08:00
parent d411ef3ba1
commit b937287732
3 changed files with 309 additions and 290 deletions

View File

@ -40,8 +40,14 @@ function interopDefault(m: any) {
const syntaxJsx = /*#__PURE__*/ interopDefault(_syntaxJsx); const syntaxJsx = /*#__PURE__*/ interopDefault(_syntaxJsx);
const template = /*#__PURE__*/ interopDefault(_template); const template = /*#__PURE__*/ interopDefault(_template);
export default declare<VueJSXPluginOptions, BabelCore.PluginObj<State>>( const plugin: (
(api, opt, dirname) => { api: object,
options: VueJSXPluginOptions | null | undefined,
dirname: string
) => BabelCore.PluginObj<State> = declare<
VueJSXPluginOptions,
BabelCore.PluginObj<State>
>((api, opt, dirname) => {
const { types } = api; const { types } = api;
let resolveType: BabelCore.PluginObj<BabelCore.PluginPass> | undefined; let resolveType: BabelCore.PluginObj<BabelCore.PluginPass> | undefined;
if (opt.resolveType) { if (opt.resolveType) {
@ -194,5 +200,6 @@ export default declare<VueJSXPluginOptions, BabelCore.PluginObj<State>>(
}, },
}, },
}; };
} });
);
export default plugin;

View File

@ -12,7 +12,12 @@ import { declare } from '@babel/helper-plugin-utils';
export { SimpleTypeResolveOptions as Options }; export { SimpleTypeResolveOptions as Options };
export default declare<SimpleTypeResolveOptions>(({ types: t }, options) => { const plugin: (
api: object,
options: SimpleTypeResolveOptions | null | undefined,
dirname: string
) => BabelCore.PluginObj<BabelCore.PluginPass> =
declare<SimpleTypeResolveOptions>(({ types: t }, options) => {
let ctx: SimpleTypeResolveContext | undefined; let ctx: SimpleTypeResolveContext | undefined;
let helpers: Set<string> | undefined; let helpers: Set<string> | undefined;
@ -98,9 +103,11 @@ export default declare<SimpleTypeResolveOptions>(({ types: t }, options) => {
) { ) {
const id = path.get('id'); const id = path.get('id');
const init = path.get('init'); const init = path.get('init');
if (!id || !id.isIdentifier() || !init || !init.isCallExpression()) return; if (!id || !id.isIdentifier() || !init || !init.isCallExpression())
return;
if (!init.get('callee')?.isIdentifier({ name: 'defineComponent' })) return; if (!init.get('callee')?.isIdentifier({ name: 'defineComponent' }))
return;
if (!checkDefineComponent(init)) return; if (!checkDefineComponent(init)) return;
const nameProperty = t.objectProperty( const nameProperty = t.objectProperty(
@ -180,6 +187,8 @@ export default declare<SimpleTypeResolveOptions>(({ types: t }, options) => {
} }
}); });
export default plugin;
function getTypeAnnotation(node: BabelCore.types.Node) { function getTypeAnnotation(node: BabelCore.types.Node) {
if ( if (
'typeAnnotation' in node && 'typeAnnotation' in node &&

View File

@ -1,10 +1,13 @@
import { defineConfig } from 'tsdown'; import { defineConfig } from 'tsdown';
export default defineConfig({ export default defineConfig({
workspace: ['./packages/babel-plugin-jsx', './packages/babel-plugin-resolve-type'], workspace: [
'./packages/babel-plugin-jsx',
'./packages/babel-plugin-resolve-type',
],
entry: ['src/index.ts'], entry: ['src/index.ts'],
format: ['cjs', 'esm'], format: ['cjs', 'esm'],
dts: true, dts: { oxc: true },
target: 'es2015', target: 'es2015',
platform: 'neutral', platform: 'neutral',
}); });