Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions packages/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,8 @@
"types.d.ts"
],
"scripts": {
"build": "pnpm run build:types && rslib build",
"build:types": "rimraf ./dist-types && tsc --build --force --emitDeclarationOnly",
"dev": "pnpm run build:types && rslib build --watch",
"build": "rslib build",
"dev": "rslib build --watch",
"prebundle": "prebundle"
},
"dependencies": {
Expand Down
7 changes: 6 additions & 1 deletion packages/core/rslib.config.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import fs from 'node:fs';
import path from 'node:path';
import { pluginCleanTscCache } from '@rsbuild/config/rslib.config';
import { defineConfig } from '@rslib/core';
import type { Configuration } from '@rspack/core';
import pkgJson from './package.json';
Expand Down Expand Up @@ -81,7 +82,10 @@ export default defineConfig({
__dirname: true,
},
},
plugins: [pluginFixDtsTypes],
plugins: [pluginFixDtsTypes, pluginCleanTscCache],
dts: {
build: true,
},
},
// Node / CJS
{
Expand Down Expand Up @@ -124,6 +128,7 @@ export default defineConfig({
overlay: 'src/client/overlay.ts',
},
define: {
// use define to avoid compile time evaluation of __webpack_hash__
WEBPACK_HASH: '__webpack_hash__',
},
},
Expand Down
6 changes: 6 additions & 0 deletions pnpm-lock.yaml

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

2 changes: 2 additions & 0 deletions scripts/config/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
"version": "1.0.1",
"private": true,
"devDependencies": {
"@rsbuild/core": "workspace:*",
"@rslib/core": "0.0.16",
"@types/node": "^22.9.0",
"typescript": "^5.6.3"
}
Expand Down
24 changes: 23 additions & 1 deletion scripts/config/rslib.config.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,36 @@
import fs from 'node:fs';
import path from 'node:path';
import type { RsbuildPlugin } from '@rsbuild/core';
import { type LibConfig, defineConfig } from '@rslib/core';

export const commonExternals: Array<string | RegExp> = [
'webpack',
/[\\/]compiled[\\/]/,
];

// Clean tsc cache to ensure the dts files can be generated correctly
export const pluginCleanTscCache: RsbuildPlugin = {
name: 'plugin-clean-tsc-cache',
setup(api) {
api.onBeforeBuild(() => {
const tsbuildinfo = path.join(
api.context.rootPath,
'tsconfig.tsbuildinfo',
);
if (fs.existsSync(tsbuildinfo)) {
fs.rmSync(tsbuildinfo);
}
});
},
};

export const esmConfig: LibConfig = {
format: 'esm',
syntax: 'es2021',
dts: { bundle: false },
dts: {
build: true,
},
plugins: [pluginCleanTscCache],
};

export const cjsConfig: LibConfig = {
Expand Down
Loading