Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
1 change: 1 addition & 0 deletions packages/core/rslib.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ export default defineConfig({
RSLIB_VERSION: JSON.stringify(require('./package.json').version),
},
},
// externalize pre-bundled dependencies
output: {
externals: {
picocolors: '../compiled/picocolors/index.js',
Expand Down
15 changes: 9 additions & 6 deletions packages/plugin-dts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,27 +22,30 @@
"main": "./dist/index.js",
"types": "./dist/index.d.ts",
"files": [
"dist"
"dist",
"compiled"
],
"scripts": {
"build": "rslib build",
"dev": "rslib build --watch",
"prebundle": "prebundle",
"test": "rstest"
},
"dependencies": {
"@ast-grep/napi": "0.37.0",
"magic-string": "^0.30.19",
"picocolors": "1.1.1",
"tinyglobby": "0.2.14",
"tsconfig-paths": "^4.2.0"
"@ast-grep/napi": "0.37.0"
},
"devDependencies": {
"@microsoft/api-extractor": "^7.52.13",
"@rsbuild/core": "~1.5.7",
"@rslib/tsconfig": "workspace:*",
"@typescript/native-preview": "7.0.0-dev.20250915.1",
"magic-string": "^0.30.19",
"picocolors": "1.1.1",
"prebundle": "1.4.2",
"rsbuild-plugin-publint": "^0.3.3",
"rslib": "npm:@rslib/[email protected]",
"tinyglobby": "0.2.14",
"tsconfig-paths": "^4.2.0",
"typescript": "^5.9.2"
},
"peerDependencies": {
Expand Down
29 changes: 29 additions & 0 deletions packages/plugin-dts/prebundle.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
// @ts-check
import { join } from 'node:path';
import fs from 'fs-extra';

/**
* Tip: please add the prebundled packages to `tsconfig.json#paths`.
*/

/** @type {import('prebundle').Config} */
export default {
externals: {
typescript: 'typescript',
},
dependencies: [
'tinyglobby',
'magic-string',
'tsconfig-paths',
{
name: 'picocolors',
beforeBundle({ depPath }) {
const typesFile = join(depPath, 'types.ts');
// Fix type bundle
if (fs.existsSync(typesFile)) {
fs.renameSync(typesFile, join(depPath, 'types.d.ts'));
}
},
},
],
};
9 changes: 9 additions & 0 deletions packages/plugin-dts/rslib.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,14 @@ export default defineConfig({
index: ['./src/**'],
},
},
// externalize pre-bundled dependencies
output: {
externals: {
'magic-string': '../compiled/magic-string/index.js',
picocolors: '../compiled/picocolors/index.js',
tinyglobby: '../compiled/tinyglobby/index.js',
'tsconfig-paths': 'node-commonjs ../compiled/tsconfig-paths/index.js',
},
},
plugins: [pluginPublint()],
});
4 changes: 3 additions & 1 deletion packages/plugin-dts/src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,16 @@ import { logger, type RsbuildConfig } from '@rsbuild/core';
import MagicString from 'magic-string';
import color from 'picocolors';
import { convertPathToPattern, glob } from 'tinyglobby';
import { createMatchPath, loadConfig, type MatchPath } from 'tsconfig-paths';
import type { MatchPath } from 'tsconfig-paths';
import * as tsconfigPaths from 'tsconfig-paths';
import type {
CompilerOptions,
Diagnostic,
ParsedCommandLine,
} from 'typescript';
import type { DtsEntry, DtsRedirect } from './index';

const { createMatchPath, loadConfig } = tsconfigPaths;
const __filename = fileURLToPath(import.meta.url);
const require = createRequire(__filename);

Expand Down
8 changes: 7 additions & 1 deletion packages/plugin-dts/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,13 @@
"isolatedDeclarations": true,
"composite": true,
"module": "ESNext",
"moduleResolution": "Bundler"
"moduleResolution": "Bundler",
"paths": {
"magic-string": ["./compiled/magic-string"],
"picocolors": ["./compiled/picocolors"],
"tinyglobby": ["./compiled/tinyglobby"],
"tsconfig-paths": ["./compiled/tsconfig-paths"]
}
},
"include": ["src"],
"exclude": ["**/node_modules"]
Expand Down
27 changes: 15 additions & 12 deletions pnpm-lock.yaml

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

Loading