diff --git a/packages/plugin-assets-retry/modern.config.ts b/packages/plugin-assets-retry/modern.config.ts index 006abf4e4a..aa96b2c676 100644 --- a/packages/plugin-assets-retry/modern.config.ts +++ b/packages/plugin-assets-retry/modern.config.ts @@ -1,3 +1,3 @@ -import { configForDualPackage } from '@rsbuild/config/modern.config.ts'; +import { configForSeparateTypesPackage } from '@rsbuild/config/modern.config.ts'; -export default configForDualPackage; +export default configForSeparateTypesPackage; diff --git a/packages/plugin-assets-retry/package.json b/packages/plugin-assets-retry/package.json index 08f0862b25..3cbed8f616 100644 --- a/packages/plugin-assets-retry/package.json +++ b/packages/plugin-assets-retry/package.json @@ -12,15 +12,16 @@ "type": "module", "exports": { ".": { - "types": "./dist/index.d.ts", + "types": "./dist-types/index.d.ts", "import": "./dist/index.js", "require": "./dist/index.cjs" } }, "main": "./dist/index.cjs", - "types": "./dist/index.d.ts", + "types": "./dist-types/index.d.ts", "files": [ - "dist" + "dist", + "dist-types" ], "scripts": { "build": "modern build && node scripts/postCompile.mjs", diff --git a/packages/plugin-babel/modern.config.ts b/packages/plugin-babel/modern.config.ts index 006abf4e4a..aa96b2c676 100644 --- a/packages/plugin-babel/modern.config.ts +++ b/packages/plugin-babel/modern.config.ts @@ -1,3 +1,3 @@ -import { configForDualPackage } from '@rsbuild/config/modern.config.ts'; +import { configForSeparateTypesPackage } from '@rsbuild/config/modern.config.ts'; -export default configForDualPackage; +export default configForSeparateTypesPackage; diff --git a/packages/plugin-babel/package.json b/packages/plugin-babel/package.json index df286482a0..c021c95a9b 100644 --- a/packages/plugin-babel/package.json +++ b/packages/plugin-babel/package.json @@ -11,16 +11,17 @@ "type": "module", "exports": { ".": { - "types": "./dist/index.d.ts", + "types": "./dist-types/index.d.ts", "import": "./dist/index.js", "require": "./dist/index.cjs" } }, "main": "./dist/index.cjs", - "types": "./dist/index.d.ts", + "types": "./dist-types/index.d.ts", "files": [ "dist", - "compiled" + "compiled", + "dist-types" ], "scripts": { "build": "modern build", diff --git a/packages/plugin-check-syntax/modern.config.ts b/packages/plugin-check-syntax/modern.config.ts index 006abf4e4a..aa96b2c676 100644 --- a/packages/plugin-check-syntax/modern.config.ts +++ b/packages/plugin-check-syntax/modern.config.ts @@ -1,3 +1,3 @@ -import { configForDualPackage } from '@rsbuild/config/modern.config.ts'; +import { configForSeparateTypesPackage } from '@rsbuild/config/modern.config.ts'; -export default configForDualPackage; +export default configForSeparateTypesPackage; diff --git a/packages/plugin-check-syntax/package.json b/packages/plugin-check-syntax/package.json index 51c48e1f6c..ff709910c3 100644 --- a/packages/plugin-check-syntax/package.json +++ b/packages/plugin-check-syntax/package.json @@ -12,15 +12,16 @@ "type": "module", "exports": { ".": { - "types": "./dist/index.d.ts", + "types": "./dist-types/index.d.ts", "import": "./dist/index.js", "require": "./dist/index.cjs" } }, "main": "./dist/index.cjs", - "types": "./dist/index.d.ts", + "types": "./dist-types/index.d.ts", "files": [ - "dist" + "dist", + "dist-types" ], "scripts": { "build": "modern build", diff --git a/packages/plugin-less/modern.config.ts b/packages/plugin-less/modern.config.ts index 006abf4e4a..aa96b2c676 100644 --- a/packages/plugin-less/modern.config.ts +++ b/packages/plugin-less/modern.config.ts @@ -1,3 +1,3 @@ -import { configForDualPackage } from '@rsbuild/config/modern.config.ts'; +import { configForSeparateTypesPackage } from '@rsbuild/config/modern.config.ts'; -export default configForDualPackage; +export default configForSeparateTypesPackage; diff --git a/packages/plugin-less/package.json b/packages/plugin-less/package.json index 5ee3bc56b6..182353866c 100644 --- a/packages/plugin-less/package.json +++ b/packages/plugin-less/package.json @@ -12,16 +12,17 @@ "type": "module", "exports": { ".": { - "types": "./dist/index.d.ts", + "types": "./dist-types/index.d.ts", "import": "./dist/index.js", "require": "./dist/index.cjs" } }, "main": "./dist/index.cjs", - "types": "./dist/index.d.ts", + "types": "./dist-types/index.d.ts", "files": [ "dist", - "compiled" + "compiled", + "dist-types" ], "scripts": { "build": "modern build", diff --git a/packages/plugin-preact/modern.config.ts b/packages/plugin-preact/modern.config.ts index 006abf4e4a..aa96b2c676 100644 --- a/packages/plugin-preact/modern.config.ts +++ b/packages/plugin-preact/modern.config.ts @@ -1,3 +1,3 @@ -import { configForDualPackage } from '@rsbuild/config/modern.config.ts'; +import { configForSeparateTypesPackage } from '@rsbuild/config/modern.config.ts'; -export default configForDualPackage; +export default configForSeparateTypesPackage; diff --git a/packages/plugin-preact/package.json b/packages/plugin-preact/package.json index 2cde33227b..feb20a5690 100644 --- a/packages/plugin-preact/package.json +++ b/packages/plugin-preact/package.json @@ -11,15 +11,16 @@ "type": "module", "exports": { ".": { - "types": "./dist/index.d.ts", + "types": "./dist-types/index.d.ts", "import": "./dist/index.js", "require": "./dist/index.cjs" } }, "main": "./dist/index.cjs", - "types": "./dist/index.d.ts", + "types": "./dist-types/index.d.ts", "files": [ - "dist" + "dist", + "dist-types" ], "scripts": { "build": "modern build", diff --git a/packages/plugin-react/modern.config.ts b/packages/plugin-react/modern.config.ts index 006abf4e4a..aa96b2c676 100644 --- a/packages/plugin-react/modern.config.ts +++ b/packages/plugin-react/modern.config.ts @@ -1,3 +1,3 @@ -import { configForDualPackage } from '@rsbuild/config/modern.config.ts'; +import { configForSeparateTypesPackage } from '@rsbuild/config/modern.config.ts'; -export default configForDualPackage; +export default configForSeparateTypesPackage; diff --git a/packages/plugin-react/package.json b/packages/plugin-react/package.json index c5edbc94c2..5869de25ff 100644 --- a/packages/plugin-react/package.json +++ b/packages/plugin-react/package.json @@ -11,15 +11,16 @@ "type": "module", "exports": { ".": { - "types": "./dist/index.d.ts", + "types": "./dist-types/index.d.ts", "import": "./dist/index.js", "require": "./dist/index.cjs" } }, "main": "./dist/index.cjs", - "types": "./dist/index.d.ts", + "types": "./dist-types/index.d.ts", "files": [ - "dist" + "dist", + "dist-types" ], "scripts": { "build": "modern build", diff --git a/packages/plugin-rem/modern.config.ts b/packages/plugin-rem/modern.config.ts index 006abf4e4a..aa96b2c676 100644 --- a/packages/plugin-rem/modern.config.ts +++ b/packages/plugin-rem/modern.config.ts @@ -1,3 +1,3 @@ -import { configForDualPackage } from '@rsbuild/config/modern.config.ts'; +import { configForSeparateTypesPackage } from '@rsbuild/config/modern.config.ts'; -export default configForDualPackage; +export default configForSeparateTypesPackage; diff --git a/packages/plugin-rem/package.json b/packages/plugin-rem/package.json index 73ec71bd63..8a90221326 100644 --- a/packages/plugin-rem/package.json +++ b/packages/plugin-rem/package.json @@ -12,16 +12,17 @@ "type": "module", "exports": { ".": { - "types": "./dist/index.d.ts", + "types": "./dist-types/index.d.ts", "import": "./dist/index.js", "require": "./dist/index.cjs" } }, "main": "./dist/index.cjs", - "types": "./dist/index.d.ts", + "types": "./dist-types/index.d.ts", "files": [ "dist", - "compiled" + "compiled", + "dist-types" ], "scripts": { "build": "modern build", diff --git a/packages/plugin-solid/modern.config.ts b/packages/plugin-solid/modern.config.ts index 006abf4e4a..aa96b2c676 100644 --- a/packages/plugin-solid/modern.config.ts +++ b/packages/plugin-solid/modern.config.ts @@ -1,3 +1,3 @@ -import { configForDualPackage } from '@rsbuild/config/modern.config.ts'; +import { configForSeparateTypesPackage } from '@rsbuild/config/modern.config.ts'; -export default configForDualPackage; +export default configForSeparateTypesPackage; diff --git a/packages/plugin-solid/package.json b/packages/plugin-solid/package.json index 36e77fec0b..2e5abb4431 100644 --- a/packages/plugin-solid/package.json +++ b/packages/plugin-solid/package.json @@ -12,15 +12,16 @@ "type": "module", "exports": { ".": { - "types": "./dist/index.d.ts", + "types": "./dist-types/index.d.ts", "import": "./dist/index.js", "require": "./dist/index.cjs" } }, "main": "./dist/index.cjs", - "types": "./dist/index.d.ts", + "types": "./dist-types/index.d.ts", "files": [ - "dist" + "dist", + "dist-types" ], "scripts": { "build": "modern build", diff --git a/packages/plugin-source-build/modern.config.ts b/packages/plugin-source-build/modern.config.ts index 006abf4e4a..aa96b2c676 100644 --- a/packages/plugin-source-build/modern.config.ts +++ b/packages/plugin-source-build/modern.config.ts @@ -1,3 +1,3 @@ -import { configForDualPackage } from '@rsbuild/config/modern.config.ts'; +import { configForSeparateTypesPackage } from '@rsbuild/config/modern.config.ts'; -export default configForDualPackage; +export default configForSeparateTypesPackage; diff --git a/packages/plugin-source-build/package.json b/packages/plugin-source-build/package.json index d1e1ea893c..e69705a078 100644 --- a/packages/plugin-source-build/package.json +++ b/packages/plugin-source-build/package.json @@ -12,15 +12,16 @@ "type": "module", "exports": { ".": { - "types": "./dist/index.d.ts", + "types": "./dist-types/index.d.ts", "import": "./dist/index.js", "require": "./dist/index.cjs" } }, "main": "./dist/index.cjs", - "types": "./dist/index.d.ts", + "types": "./dist-types/index.d.ts", "files": [ - "dist" + "dist", + "dist-types" ], "scripts": { "build": "modern build", diff --git a/packages/plugin-styled-components/modern.config.ts b/packages/plugin-styled-components/modern.config.ts index 006abf4e4a..aa96b2c676 100644 --- a/packages/plugin-styled-components/modern.config.ts +++ b/packages/plugin-styled-components/modern.config.ts @@ -1,3 +1,3 @@ -import { configForDualPackage } from '@rsbuild/config/modern.config.ts'; +import { configForSeparateTypesPackage } from '@rsbuild/config/modern.config.ts'; -export default configForDualPackage; +export default configForSeparateTypesPackage; diff --git a/packages/plugin-styled-components/package.json b/packages/plugin-styled-components/package.json index 7767a7ae50..1ae9e13a27 100644 --- a/packages/plugin-styled-components/package.json +++ b/packages/plugin-styled-components/package.json @@ -11,15 +11,16 @@ "type": "module", "exports": { ".": { - "types": "./dist/index.d.ts", + "types": "./dist-types/index.d.ts", "import": "./dist/index.js", "require": "./dist/index.cjs" } }, "main": "./dist/index.cjs", - "types": "./dist/index.d.ts", + "types": "./dist-types/index.d.ts", "files": [ - "dist" + "dist", + "dist-types" ], "scripts": { "build": "modern build", diff --git a/packages/plugin-stylus/modern.config.ts b/packages/plugin-stylus/modern.config.ts index 006abf4e4a..aa96b2c676 100644 --- a/packages/plugin-stylus/modern.config.ts +++ b/packages/plugin-stylus/modern.config.ts @@ -1,3 +1,3 @@ -import { configForDualPackage } from '@rsbuild/config/modern.config.ts'; +import { configForSeparateTypesPackage } from '@rsbuild/config/modern.config.ts'; -export default configForDualPackage; +export default configForSeparateTypesPackage; diff --git a/packages/plugin-stylus/package.json b/packages/plugin-stylus/package.json index 98e49bd88d..2c8ee39ef0 100644 --- a/packages/plugin-stylus/package.json +++ b/packages/plugin-stylus/package.json @@ -12,15 +12,16 @@ "type": "module", "exports": { ".": { - "types": "./dist/index.d.ts", + "types": "./dist-types/index.d.ts", "import": "./dist/index.js", "require": "./dist/index.cjs" } }, "main": "./dist/index.cjs", - "types": "./dist/index.d.ts", + "types": "./dist-types/index.d.ts", "files": [ - "dist" + "dist", + "dist-types" ], "scripts": { "build": "modern build", diff --git a/packages/plugin-svelte/modern.config.ts b/packages/plugin-svelte/modern.config.ts index b317f50034..bb225b8f0e 100644 --- a/packages/plugin-svelte/modern.config.ts +++ b/packages/plugin-svelte/modern.config.ts @@ -1,14 +1,35 @@ import { moduleTools } from '@modern-js/module-tools'; -import { dualBuildConfigs } from '@rsbuild/config/modern.config.ts'; +import { + cjsBuildConfig, + emitTypePkgJsonPlugin, + esmBuildConfig, +} from '@rsbuild/config/modern.config.ts'; export default { - plugins: [moduleTools()], - buildConfig: dualBuildConfigs.map((config) => { - config.externals = [ - ...(config.externals || []), - 'svelte/compiler', - 'svelte-preprocess/dist/types', - ]; - return config; - }), + plugins: [moduleTools(), emitTypePkgJsonPlugin], + buildConfig: [ + { + ...esmBuildConfig, + externals: [ + ...(esmBuildConfig.externals || []), + 'svelte/compiler', + 'svelte-preprocess/dist/types', + ], + }, + { + ...cjsBuildConfig, + externals: [ + ...(cjsBuildConfig.externals || []), + 'svelte/compiler', + 'svelte-preprocess/dist/types', + ], + }, + { + buildType: 'bundleless', + dts: { + distPath: '../dist-types', + only: true, + }, + }, + ], }; diff --git a/packages/plugin-svelte/package.json b/packages/plugin-svelte/package.json index a3506ba572..bb554c5b15 100644 --- a/packages/plugin-svelte/package.json +++ b/packages/plugin-svelte/package.json @@ -11,15 +11,16 @@ "type": "module", "exports": { ".": { - "types": "./dist/index.d.ts", + "types": "./dist-types/index.d.ts", "import": "./dist/index.js", "require": "./dist/index.cjs" } }, "main": "./dist/index.cjs", - "types": "./dist/index.d.ts", + "types": "./dist-types/index.d.ts", "files": [ - "dist" + "dist", + "dist-types" ], "scripts": { "build": "modern build", diff --git a/packages/plugin-svgr/modern.config.ts b/packages/plugin-svgr/modern.config.ts index f0e5824f0a..267f2d20ea 100644 --- a/packages/plugin-svgr/modern.config.ts +++ b/packages/plugin-svgr/modern.config.ts @@ -1,13 +1,25 @@ -import { moduleTools } from '@modern-js/module-tools'; -import { dualBuildConfigs } from '@rsbuild/config/modern.config.ts'; +import { defineConfig, moduleTools } from '@modern-js/module-tools'; +import { + cjsBuildConfig, + emitTypePkgJsonPlugin, + esmBuildConfig, +} from '@rsbuild/config/modern.config.ts'; -export default { - plugins: [moduleTools()], - buildConfig: dualBuildConfigs.map((config) => { - if (config.format === 'cjs') { +export default defineConfig({ + plugins: [moduleTools(), emitTypePkgJsonPlugin], + buildConfig: [ + esmBuildConfig, + { + ...cjsBuildConfig, // add loader to entry - config.input = ['src/index.ts', 'src/loader.ts']; - } - return config; - }), -}; + 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 e0822d0509..46ff4186fd 100644 --- a/packages/plugin-svgr/package.json +++ b/packages/plugin-svgr/package.json @@ -11,16 +11,17 @@ "type": "module", "exports": { ".": { - "types": "./dist/index.d.ts", + "types": "./dist-types/index.d.ts", "import": "./dist/index.js", "require": "./dist/index.cjs" } }, "main": "./dist/index.cjs", - "types": "./dist/index.d.ts", + "types": "./dist-types/index.d.ts", "files": [ "dist", - "compiled" + "compiled", + "dist-types" ], "scripts": { "build": "modern build", diff --git a/packages/plugin-type-check/modern.config.ts b/packages/plugin-type-check/modern.config.ts index 006abf4e4a..aa96b2c676 100644 --- a/packages/plugin-type-check/modern.config.ts +++ b/packages/plugin-type-check/modern.config.ts @@ -1,3 +1,3 @@ -import { configForDualPackage } from '@rsbuild/config/modern.config.ts'; +import { configForSeparateTypesPackage } from '@rsbuild/config/modern.config.ts'; -export default configForDualPackage; +export default configForSeparateTypesPackage; diff --git a/packages/plugin-type-check/package.json b/packages/plugin-type-check/package.json index a024cfb95d..f9883aacbd 100644 --- a/packages/plugin-type-check/package.json +++ b/packages/plugin-type-check/package.json @@ -12,15 +12,16 @@ "type": "module", "exports": { ".": { - "types": "./dist/index.d.ts", + "types": "./dist-types/index.d.ts", "import": "./dist/index.js", "require": "./dist/index.cjs" } }, "main": "./dist/index.cjs", - "types": "./dist/index.d.ts", + "types": "./dist-types/index.d.ts", "files": [ - "dist" + "dist", + "dist-types" ], "scripts": { "build": "modern build", diff --git a/packages/plugin-vue-jsx/modern.config.ts b/packages/plugin-vue-jsx/modern.config.ts index 006abf4e4a..aa96b2c676 100644 --- a/packages/plugin-vue-jsx/modern.config.ts +++ b/packages/plugin-vue-jsx/modern.config.ts @@ -1,3 +1,3 @@ -import { configForDualPackage } from '@rsbuild/config/modern.config.ts'; +import { configForSeparateTypesPackage } from '@rsbuild/config/modern.config.ts'; -export default configForDualPackage; +export default configForSeparateTypesPackage; diff --git a/packages/plugin-vue-jsx/package.json b/packages/plugin-vue-jsx/package.json index 8592adc9a0..e96f04c584 100644 --- a/packages/plugin-vue-jsx/package.json +++ b/packages/plugin-vue-jsx/package.json @@ -12,15 +12,16 @@ "type": "module", "exports": { ".": { - "types": "./dist/index.d.ts", + "types": "./dist-types/index.d.ts", "import": "./dist/index.js", "require": "./dist/index.cjs" } }, "main": "./dist/index.cjs", - "types": "./dist/index.d.ts", + "types": "./dist-types/index.d.ts", "files": [ - "dist" + "dist", + "dist-types" ], "scripts": { "build": "modern build", diff --git a/packages/plugin-vue/modern.config.ts b/packages/plugin-vue/modern.config.ts index 006abf4e4a..aa96b2c676 100644 --- a/packages/plugin-vue/modern.config.ts +++ b/packages/plugin-vue/modern.config.ts @@ -1,3 +1,3 @@ -import { configForDualPackage } from '@rsbuild/config/modern.config.ts'; +import { configForSeparateTypesPackage } from '@rsbuild/config/modern.config.ts'; -export default configForDualPackage; +export default configForSeparateTypesPackage; diff --git a/packages/plugin-vue/package.json b/packages/plugin-vue/package.json index 40f7e72d27..f6799fffc6 100644 --- a/packages/plugin-vue/package.json +++ b/packages/plugin-vue/package.json @@ -12,15 +12,16 @@ "type": "module", "exports": { ".": { - "types": "./dist/index.d.ts", + "types": "./dist-types/index.d.ts", "import": "./dist/index.js", "require": "./dist/index.cjs" } }, "main": "./dist/index.cjs", - "types": "./dist/index.d.ts", + "types": "./dist-types/index.d.ts", "files": [ - "dist" + "dist", + "dist-types" ], "scripts": { "build": "modern build", diff --git a/packages/plugin-vue2-jsx/modern.config.ts b/packages/plugin-vue2-jsx/modern.config.ts index 006abf4e4a..aa96b2c676 100644 --- a/packages/plugin-vue2-jsx/modern.config.ts +++ b/packages/plugin-vue2-jsx/modern.config.ts @@ -1,3 +1,3 @@ -import { configForDualPackage } from '@rsbuild/config/modern.config.ts'; +import { configForSeparateTypesPackage } from '@rsbuild/config/modern.config.ts'; -export default configForDualPackage; +export default configForSeparateTypesPackage; diff --git a/packages/plugin-vue2-jsx/package.json b/packages/plugin-vue2-jsx/package.json index 13ae4575fe..b3d493283c 100644 --- a/packages/plugin-vue2-jsx/package.json +++ b/packages/plugin-vue2-jsx/package.json @@ -12,15 +12,16 @@ "type": "module", "exports": { ".": { - "types": "./dist/index.d.ts", + "types": "./dist-types/index.d.ts", "import": "./dist/index.js", "require": "./dist/index.cjs" } }, "main": "./dist/index.cjs", - "types": "./dist/index.d.ts", + "types": "./dist-types/index.d.ts", "files": [ - "dist" + "dist", + "dist-types" ], "scripts": { "build": "modern build", diff --git a/packages/plugin-vue2/modern.config.ts b/packages/plugin-vue2/modern.config.ts index 006abf4e4a..aa96b2c676 100644 --- a/packages/plugin-vue2/modern.config.ts +++ b/packages/plugin-vue2/modern.config.ts @@ -1,3 +1,3 @@ -import { configForDualPackage } from '@rsbuild/config/modern.config.ts'; +import { configForSeparateTypesPackage } from '@rsbuild/config/modern.config.ts'; -export default configForDualPackage; +export default configForSeparateTypesPackage; diff --git a/packages/plugin-vue2/package.json b/packages/plugin-vue2/package.json index 42657b86a3..6df8623cf2 100644 --- a/packages/plugin-vue2/package.json +++ b/packages/plugin-vue2/package.json @@ -12,15 +12,16 @@ "type": "module", "exports": { ".": { - "types": "./dist/index.d.ts", + "types": "./dist-types/index.d.ts", "import": "./dist/index.js", "require": "./dist/index.cjs" } }, "main": "./dist/index.cjs", - "types": "./dist/index.d.ts", + "types": "./dist-types/index.d.ts", "files": [ - "dist" + "dist", + "dist-types" ], "scripts": { "build": "modern build",