Skip to content

Commit

Permalink
chore: update
Browse files Browse the repository at this point in the history
  • Loading branch information
SoonIter committed Feb 7, 2025
1 parent ea3b304 commit 43e2b30
Show file tree
Hide file tree
Showing 10 changed files with 24 additions and 37 deletions.
3 changes: 2 additions & 1 deletion packages/cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,8 @@
"@rspress/core": "workspace:*",
"@rspress/shared": "workspace:*",
"cac": "^6.7.14",
"chokidar": "^3.6.0"
"chokidar": "^3.6.0",
"picocolors": "^1.1.1"
},
"devDependencies": {
"@microsoft/api-extractor": "^7.49.2",
Expand Down
4 changes: 2 additions & 2 deletions packages/cli/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { createRequire } from 'node:module';
import path from 'node:path';
import { build, dev, serve } from '@rspress/core';
import chalk from '@rspress/shared/chalk';
import { logger } from '@rspress/shared/logger';
import { cac } from 'cac';
import chokidar from 'chokidar';
import picocolors from 'picocolors';
import { loadConfigFile, resolveDocRoot } from './config/loadConfigFile';
import update from './update';

Expand Down Expand Up @@ -78,7 +78,7 @@ cli
}
isRestarting = true;
console.log(
`\n✨ ${eventName} ${chalk.green(
`\n✨ ${eventName} ${picocolors.green(
path.relative(cwd, filepath),
)}, dev server will restart...\n`,
);
Expand Down
1 change: 1 addition & 0 deletions packages/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@
"lodash-es": "^4.17.21",
"mdast-util-mdxjs-esm": "^1.3.1",
"memfs": "^4.17.0",
"picocolors": "^1.1.1",
"react": "^18.3.1",
"react-dom": "^18.3.1",
"react-helmet-async": "^1.3.0",
Expand Down
12 changes: 6 additions & 6 deletions packages/core/src/node/build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ import {
normalizeSlash,
withBase,
} from '@rspress/shared';
import chalk from '@rspress/shared/chalk';
import { logger } from '@rspress/shared/logger';
import picocolors from 'picocolors';
import type { HelmetData } from 'react-helmet-async';
import { PluginDriver } from './PluginDriver';
import {
Expand Down Expand Up @@ -100,15 +100,15 @@ export async function renderPages(
// see: https://github.com/web-infra-dev/rspress/issues/1317
if (typeof ssgConfig === 'object' && ssgConfig.strict) {
logger.error(
`Failed to load SSG bundle: ${chalk.yellow(ssrBundlePath)}.`,
`Failed to load SSG bundle: ${picocolors.yellow(ssrBundlePath)}.`,
);
throw e;
}

// fallback to CSR
logger.error(e);
logger.warn(
`Failed to load SSG bundle: ${chalk.yellow(ssrBundlePath)}, fallback to CSR.`,
`Failed to load SSG bundle: ${picocolors.yellow(ssrBundlePath)}, fallback to CSR.`,
);
}
}
Expand Down Expand Up @@ -149,14 +149,14 @@ export async function renderPages(
} catch (e) {
if (typeof ssgConfig === 'object' && ssgConfig.strict) {
logger.error(
`Page "${chalk.yellow(routePath)}" SSG rendering failed.`,
`Page "${picocolors.yellow(routePath)}" SSG rendering failed.`,
);
throw e;
}

// fallback to CSR
logger.warn(
`Page "${chalk.yellow(routePath)}" SSG rendering error: ${e.message}, fallback to CSR.`,
`Page "${picocolors.yellow(routePath)}" SSG rendering error: ${e.message}, fallback to CSR.`,
);
}
}
Expand Down Expand Up @@ -221,7 +221,7 @@ export async function renderPages(
await emptyDir(join(outputPath, 'html'));

const totalTime = Date.now() - startTime;
logger.success(`Pages rendered in ${chalk.yellow(totalTime)} ms.`);
logger.success(`Pages rendered in ${picocolors.yellow(totalTime)} ms.`);
} catch (e) {
logger.error(`Pages render error: ${e.stack}`);
throw e;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { DEFAULT_HIGHLIGHT_LANGUAGES } from '@rspress/shared';
import chalk from '@rspress/shared/chalk';
import picocolors from 'picocolors';

let supportedLanguages: Set<string>;

Expand All @@ -26,7 +26,7 @@ export function handleHighlightLanguages(
} else if (useDeprecatedTypeWarning) {
// Deprecated warning
console.log(
`${chalk.yellowBright(
`${picocolors.yellowBright(
'warning',
)} Automatic import is supported. \`highlightLanguages\` is now used only as alias, and string types will be ignored. \n`,
);
Expand Down
6 changes: 3 additions & 3 deletions packages/core/src/node/searchIndex.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ import fs from 'node:fs/promises';
import type { IncomingMessage, ServerResponse } from 'node:http';
import path, { join } from 'node:path';
import { SEARCH_INDEX_NAME, type UserConfig, isSCM } from '@rspress/shared';
import chalk from '@rspress/shared/chalk';
import { logger } from '@rspress/shared/logger';
import picocolors from 'picocolors';
import { OUTPUT_DIR, TEMP_DIR, isProduction } from './constants';

export async function writeSearchIndex(config: UserConfig) {
Expand Down Expand Up @@ -54,13 +54,13 @@ export async function writeSearchIndex(config: UserConfig) {
});

logger.info(
chalk.green(
picocolors.green(
`[doc-tools] Search index uploaded to ${apiUrl}, indexName: ${indexName}`,
),
);
} catch (e) {
logger.info(
chalk.red(
picocolors.red(
`[doc-tools] Upload search index \`${indexName}\` failed:\n ${e}`,
),
);
Expand Down
14 changes: 2 additions & 12 deletions packages/shared/modern.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,25 +4,15 @@ const config: ReturnType<typeof defineConfig> = defineConfig({
plugins: [moduleTools()],
buildConfig: [
{
input: [
'src/index.ts',
'src/logger.ts',
'src/chalk.ts',
'src/node-utils.ts',
],
input: ['src/index.ts', 'src/logger.ts', 'src/node-utils.ts'],
target: 'esnext',
format: 'esm',
buildType: 'bundle',
dts: false,
autoExtension: true,
},
{
input: [
'src/index.ts',
'src/logger.ts',
'src/chalk.ts',
'src/node-utils.ts',
],
input: ['src/index.ts', 'src/logger.ts', 'src/node-utils.ts'],
target: 'esnext',
format: 'cjs',
buildType: 'bundle',
Expand Down
6 changes: 0 additions & 6 deletions packages/shared/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,6 @@
"import": "./dist/index.mjs",
"require": "./dist/index.js"
},
"./chalk": {
"types": "./dist/chalk.d.ts",
"import": "./dist/chalk.mjs",
"require": "./dist/chalk.js"
},
"./logger": {
"types": "./dist/logger.d.ts",
"import": "./dist/logger.mjs",
Expand Down Expand Up @@ -46,7 +41,6 @@
},
"dependencies": {
"@rsbuild/core": "1.2.3",
"chalk": "5.4.1",
"gray-matter": "4.0.3",
"lodash-es": "^4.17.21",
"unified": "^10.1.2"
Expand Down
2 changes: 0 additions & 2 deletions packages/shared/src/chalk.ts

This file was deleted.

9 changes: 6 additions & 3 deletions pnpm-lock.yaml

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

0 comments on commit 43e2b30

Please sign in to comment.