Skip to content

Commit 2d360fd

Browse files
committed
chore: use type PackageJson from type-fest
1 parent 4e20196 commit 2d360fd

File tree

7 files changed

+18
-14
lines changed

7 files changed

+18
-14
lines changed

packages/core/package.json

+1
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@
5151
"prebundle": "1.1.0",
5252
"rslib": "npm:@rslib/[email protected]",
5353
"rslog": "^1.2.2",
54+
"type-fest": "^4.25.0",
5455
"typescript": "^5.5.4"
5556
},
5657
"peerDependencies": {

packages/core/src/config.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,12 @@ import {
99
mergeRsbuildConfig,
1010
} from '@rsbuild/core';
1111
import glob from 'fast-glob';
12+
import type { PackageJson } from 'type-fest';
1213
import { DEFAULT_CONFIG_NAME, DEFAULT_EXTENSIONS } from './constant';
1314
import type {
1415
AutoExternal,
1516
Format,
1617
LibConfig,
17-
PkgJson,
1818
RslibConfig,
1919
RslibConfigAsyncFn,
2020
RslibConfigExport,
@@ -89,7 +89,7 @@ export async function loadConfig({
8989

9090
export const composeAutoExternalConfig = (options: {
9191
autoExternal: AutoExternal;
92-
pkgJson?: PkgJson;
92+
pkgJson?: PackageJson;
9393
userExternals?: NonNullable<RsbuildConfig['output']>['externals'];
9494
}): RsbuildConfig => {
9595
const { autoExternal, pkgJson, userExternals } = options;
@@ -242,7 +242,7 @@ const composeFormatConfig = (format: Format): RsbuildConfig => {
242242
const composeAutoExtensionConfig = (
243243
config: LibConfig,
244244
autoExtension: boolean,
245-
pkgJson?: PkgJson,
245+
pkgJson?: PackageJson,
246246
): {
247247
config: RsbuildConfig;
248248
jsExtension: string;

packages/core/src/types/index.ts

-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1 @@
11
export type * from './config';
2-
export type * from './utils';

packages/core/src/types/utils.ts

-6
This file was deleted.

packages/core/src/utils/extension.ts

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
1-
import type { Format, PkgJson } from '../types';
1+
import type { PackageJson } from 'type-fest';
2+
import type { Format } from '../types';
23
import { logger } from './logger';
34

45
export const getDefaultExtension = (options: {
56
format: Format;
6-
pkgJson?: PkgJson;
7+
pkgJson?: PackageJson;
78
autoExtension: boolean;
89
}): {
910
jsExtension: string;

packages/core/src/utils/helper.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import fs from 'node:fs';
22
import fsP from 'node:fs/promises';
33
import path from 'node:path';
44
import color from 'picocolors';
5-
import type { PkgJson } from '../types';
5+
import type { PackageJson } from 'type-fest';
66
import { logger } from './logger';
77

88
/**
@@ -107,7 +107,7 @@ export async function calcLongestCommonPath(
107107
return lca;
108108
}
109109

110-
export const readPackageJson = (rootPath: string): undefined | PkgJson => {
110+
export const readPackageJson = (rootPath: string): undefined | PackageJson => {
111111
const pkgJsonPath = path.join(rootPath, './package.json');
112112

113113
if (!fs.existsSync(pkgJsonPath)) {

pnpm-lock.yaml

+9
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)