diff --git a/packages/plugin-svgr/modern.config.ts b/packages/plugin-svgr/modern.config.ts deleted file mode 100644 index 267f2d20ea..0000000000 --- a/packages/plugin-svgr/modern.config.ts +++ /dev/null @@ -1,25 +0,0 @@ -import { defineConfig, moduleTools } from '@modern-js/module-tools'; -import { - cjsBuildConfig, - emitTypePkgJsonPlugin, - esmBuildConfig, -} from '@rsbuild/config/modern.config.ts'; - -export default defineConfig({ - plugins: [moduleTools(), emitTypePkgJsonPlugin], - buildConfig: [ - esmBuildConfig, - { - ...cjsBuildConfig, - // add loader to entry - input: ['src/index.ts', 'src/loader.ts'], - }, - { - buildType: 'bundleless', - dts: { - distPath: '../dist-types', - only: true, - }, - }, - ], -}); diff --git a/packages/plugin-svgr/package.json b/packages/plugin-svgr/package.json index c619c46d28..b2b5203b68 100644 --- a/packages/plugin-svgr/package.json +++ b/packages/plugin-svgr/package.json @@ -11,21 +11,20 @@ "type": "module", "exports": { ".": { - "types": "./dist-types/index.d.ts", + "types": "./dist/index.d.ts", "import": "./dist/index.js", "require": "./dist/index.cjs" } }, "main": "./dist/index.cjs", - "types": "./dist-types/index.d.ts", + "types": "./dist/index.d.ts", "files": [ "dist", - "compiled", - "dist-types" + "compiled" ], "scripts": { - "build": "modern build", - "dev": "modern build --watch", + "build": "rslib build", + "dev": "rslib build --watch", "prebundle": "prebundle" }, "dependencies": { diff --git a/packages/plugin-svgr/rslib.config.ts b/packages/plugin-svgr/rslib.config.ts new file mode 100644 index 0000000000..556d686794 --- /dev/null +++ b/packages/plugin-svgr/rslib.config.ts @@ -0,0 +1,18 @@ +import { dualPackage } from '@rsbuild/config/rslib.config.ts'; +import { defineConfig } from '@rslib/core'; + +export default defineConfig({ + ...dualPackage, + lib: [ + ...dualPackage.lib, + { + syntax: 'es2021', + format: 'cjs', + source: { + entry: { + loader: './src/loader.ts', + }, + }, + }, + ], +}); diff --git a/packages/plugin-svgr/src/loader.ts b/packages/plugin-svgr/src/loader.ts index 5d2de47d2d..0bac9c9f12 100644 --- a/packages/plugin-svgr/src/loader.ts +++ b/packages/plugin-svgr/src/loader.ts @@ -9,7 +9,7 @@ import { normalize } from 'node:path'; import { callbackify } from 'node:util'; import type { Rspack } from '@rsbuild/core'; -import { type Config, type State, transform } from '@svgr/core'; +import { type Config, type Plugin, type State, transform } from '@svgr/core'; import jsx from '@svgr/plugin-jsx'; import svgo from '@svgr/plugin-svgo'; @@ -34,11 +34,11 @@ function svgrLoader( return exportMatches ? `export default ${exportMatches[1]}` : null; })(); - const state = { + const state: Partial = { caller: { name: '@rsbuild/plugin-svgr', previousExport, - defaultPlugins: [svgo, jsx], + defaultPlugins: [svgo, jsx] as unknown as Plugin[], }, filePath: normalize(this.resourcePath), }; diff --git a/packages/plugin-svgr/tsconfig.json b/packages/plugin-svgr/tsconfig.json index 3f705ca93b..ac9bf1b465 100644 --- a/packages/plugin-svgr/tsconfig.json +++ b/packages/plugin-svgr/tsconfig.json @@ -1,5 +1,5 @@ { - "extends": "@rsbuild/config/tsconfig", + "extends": "@rsbuild/config/tsconfig-node16", "compilerOptions": { "outDir": "./dist", "baseUrl": "./",