Skip to content

Commit

Permalink
chore: use type PackageJson from type-fest
Browse files Browse the repository at this point in the history
  • Loading branch information
shulaoda committed Aug 14, 2024
1 parent 38fcca5 commit b885aa6
Show file tree
Hide file tree
Showing 8 changed files with 23 additions and 15 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
"prettier": "^3.3.2",
"prettier-plugin-packagejson": "^2.5.0",
"simple-git-hooks": "^2.11.1",
"type-fest": "^4.24.0",
"typescript": "^5.5.3",
"vitest": "^2.0.5"
},
Expand Down
1 change: 1 addition & 0 deletions packages/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
"picocolors": "1.0.1",
"prebundle": "1.1.0",
"rslog": "^1.2.2",
"type-fest": "^4.24.0",
"typescript": "^5.5.3"
},
"peerDependencies": {
Expand Down
6 changes: 3 additions & 3 deletions packages/core/src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@ import {
mergeRsbuildConfig,
} from '@rsbuild/core';
import glob from 'fast-glob';
import type { PackageJson } from 'type-fest';
import { DEFAULT_CONFIG_NAME, DEFAULT_EXTENSIONS } from './constant';
import type {
AutoExternal,
Format,
LibConfig,
PkgJson,
RslibConfig,
RslibConfigAsyncFn,
RslibConfigExport,
Expand Down Expand Up @@ -85,7 +85,7 @@ export async function loadConfig(

export const composeAutoExternalConfig = (options: {
autoExternal: AutoExternal;
pkgJson?: PkgJson;
pkgJson?: PackageJson;
userExternals?: NonNullable<RsbuildConfig['output']>['externals'];
}): RsbuildConfig => {
const { autoExternal, pkgJson, userExternals } = options;
Expand Down Expand Up @@ -230,7 +230,7 @@ const composeFormatConfig = (format: Format): RsbuildConfig => {
const composeAutoExtensionConfig = (
format: Format,
autoExtension: boolean,
pkgJson?: PkgJson,
pkgJson?: PackageJson,
): {
config: RsbuildConfig;
dtsExtension: string;
Expand Down
1 change: 0 additions & 1 deletion packages/core/src/types/index.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
export * from './config';
export * from './utils';
6 changes: 0 additions & 6 deletions packages/core/src/types/utils.ts

This file was deleted.

5 changes: 3 additions & 2 deletions packages/core/src/utils/extension.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import type { Format, PkgJson } from 'src/types';
import type { Format } from 'src/types';
import type { PackageJson } from 'type-fest';
import { logger } from './logger';

export const getDefaultExtension = (options: {
format: Format;
pkgJson?: PkgJson;
pkgJson?: PackageJson;
autoExtension: boolean;
}): {
jsExtension: string;
Expand Down
4 changes: 2 additions & 2 deletions packages/core/src/utils/helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import fs from 'node:fs';
import fsP from 'node:fs/promises';
import path from 'node:path';
import color from 'picocolors';
import type { PkgJson } from '../types';
import type { PackageJson } from 'type-fest';
import { logger } from './logger';

/**
Expand Down Expand Up @@ -102,7 +102,7 @@ async function calcLongestCommonPath(
return lca;
}

export const readPackageJson = (rootPath: string): undefined | PkgJson => {
export const readPackageJson = (rootPath: string): undefined | PackageJson => {
const pkgJsonPath = path.resolve(rootPath, './package.json');

if (!fs.existsSync(pkgJsonPath)) {
Expand Down
14 changes: 13 additions & 1 deletion pnpm-lock.yaml

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

0 comments on commit b885aa6

Please sign in to comment.