Skip to content

Commit

Permalink
fix: plugin type missing when set moduleResolution node16+ (#3089)
Browse files Browse the repository at this point in the history
  • Loading branch information
9aoy authored Aug 1, 2024
1 parent 387176c commit 1bb8bba
Show file tree
Hide file tree
Showing 36 changed files with 158 additions and 107 deletions.
4 changes: 2 additions & 2 deletions packages/plugin-assets-retry/modern.config.ts
Original file line number Diff line number Diff line change
@@ -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;
7 changes: 4 additions & 3 deletions packages/plugin-assets-retry/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
4 changes: 2 additions & 2 deletions packages/plugin-babel/modern.config.ts
Original file line number Diff line number Diff line change
@@ -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;
7 changes: 4 additions & 3 deletions packages/plugin-babel/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
4 changes: 2 additions & 2 deletions packages/plugin-check-syntax/modern.config.ts
Original file line number Diff line number Diff line change
@@ -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;
7 changes: 4 additions & 3 deletions packages/plugin-check-syntax/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
4 changes: 2 additions & 2 deletions packages/plugin-less/modern.config.ts
Original file line number Diff line number Diff line change
@@ -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;
7 changes: 4 additions & 3 deletions packages/plugin-less/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
4 changes: 2 additions & 2 deletions packages/plugin-preact/modern.config.ts
Original file line number Diff line number Diff line change
@@ -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;
7 changes: 4 additions & 3 deletions packages/plugin-preact/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
4 changes: 2 additions & 2 deletions packages/plugin-react/modern.config.ts
Original file line number Diff line number Diff line change
@@ -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;
7 changes: 4 additions & 3 deletions packages/plugin-react/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
4 changes: 2 additions & 2 deletions packages/plugin-rem/modern.config.ts
Original file line number Diff line number Diff line change
@@ -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;
7 changes: 4 additions & 3 deletions packages/plugin-rem/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
4 changes: 2 additions & 2 deletions packages/plugin-solid/modern.config.ts
Original file line number Diff line number Diff line change
@@ -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;
7 changes: 4 additions & 3 deletions packages/plugin-solid/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
4 changes: 2 additions & 2 deletions packages/plugin-source-build/modern.config.ts
Original file line number Diff line number Diff line change
@@ -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;
7 changes: 4 additions & 3 deletions packages/plugin-source-build/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
4 changes: 2 additions & 2 deletions packages/plugin-styled-components/modern.config.ts
Original file line number Diff line number Diff line change
@@ -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;
7 changes: 4 additions & 3 deletions packages/plugin-styled-components/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
4 changes: 2 additions & 2 deletions packages/plugin-stylus/modern.config.ts
Original file line number Diff line number Diff line change
@@ -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;
7 changes: 4 additions & 3 deletions packages/plugin-stylus/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
41 changes: 31 additions & 10 deletions packages/plugin-svelte/modern.config.ts
Original file line number Diff line number Diff line change
@@ -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,
},
},
],
};
7 changes: 4 additions & 3 deletions packages/plugin-svelte/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
34 changes: 23 additions & 11 deletions packages/plugin-svgr/modern.config.ts
Original file line number Diff line number Diff line change
@@ -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,
},
},
],
});
Loading

0 comments on commit 1bb8bba

Please sign in to comment.