From 98a63b241aa7167e4ab18b58db159c8eda69368c Mon Sep 17 00:00:00 2001 From: Jiachi Liu Date: Sat, 25 Jan 2025 00:45:39 +0100 Subject: [PATCH] prettier: fix format --- .prettierignore | 1 + README.md | 140 +++++++++++++++++++++---------------------- docs/app/globals.css | 19 ++++-- package.json | 2 +- pnpm-lock.yaml | 12 ++-- src/exports.ts | 8 +-- src/rollup/output.ts | 12 ++-- 7 files changed, 103 insertions(+), 91 deletions(-) diff --git a/.prettierignore b/.prettierignore index bd5535a6..39cb3f67 100644 --- a/.prettierignore +++ b/.prettierignore @@ -1 +1,2 @@ pnpm-lock.yaml +README.md diff --git a/README.md b/README.md index 02ce83cc..42ee4626 100644 --- a/README.md +++ b/README.md @@ -41,12 +41,12 @@ Add the exports in `package.json`. ```json5 { - name: 'coffee', - type: 'module', - main: './dist/index.js', - scripts: { - build: 'bunchee', - }, + "name":"coffee", + "type":"module", + "main":"./dist/index.js", + "scripts":{ + "build":"bunchee" + } } ``` @@ -73,23 +73,23 @@ Here's a example of entry files and exports configuration: ```json5 { - name: 'coffee', - scripts: { - build: 'bunchee', + "name": "coffee", + "scripts": { + "build: "bunchee", }, - type: 'module', - exports: { + "type": "module", + "exports": { // entry: ./src/index.ts - '.': { - import: './dist/index.js', - require: './dist/index.cjs', + ".": { + "import": "./dist/index.js", + "require": "./dist/index.cjs", }, // entry: ./src/lite.ts - './lite': './dist/lite.js', + "./lite": "./dist/lite.js", // entry: ./src/react/index.ts - './react': './dist/react.js', + "./react": "./dist/react.js", }, } ``` @@ -124,15 +124,15 @@ The `dependencies` and `peerDependencies` will be marked as externalized and won ```json5 { // Externalized - dependencies: { + "dependencies": { /* ... */ }, - peerDependencies: { + "peerDependencies": { /* ... */ }, // Bundled - devDependencies: { + "devDependencies": { /* ... */ }, } @@ -146,10 +146,10 @@ For instance: ```json5 { - exports: { - 'react-server': './dist/react-server.mjs', - 'edge-light': './dist/edge-light.mjs', - import: './dist/index.mjs', + "exports": { + "react-server": "./dist/react-server.mjs", + "edge-light": "./dist/edge-light.mjs", + "import": "./dist/index.mjs", }, } ``` @@ -161,8 +161,8 @@ For instance: ```json5 // package.json { - imports: { - '#util': './src/utils.ts', + "imports": { + "#util": "./src/utils.ts", }, } ``` @@ -183,7 +183,7 @@ This will match the `bin` field in package.json as: ```json5 { - bin: './dist/bin.js', + "bin": "./dist/bin.js", } ``` @@ -204,9 +204,9 @@ This will match the `bin` field in package.json as: ```json5 { - bin: { - foo: './dist/bin/a.js', - bar: './dist/bin/b.js', + "bin": { + "foo": "./dist/bin/a.js", + "bar": "./dist/bin/b.js", }, } ``` @@ -338,14 +338,14 @@ Then use use the [exports field in package.json](https://nodejs.org/api/packages ```json5 { - files: ['dist'], - type: 'module', - exports: { - '.': './dist/es/index.js', - './react': './dist/es/react.js', + "files": ["dist"], + "type": "module", + "exports": { + ".": "./dist/es/index.js", + "./react": "./dist/es/react.js", }, - scripts: { - build: 'bunchee', + "scripts": { + "build": "bunchee", }, } ``` @@ -359,21 +359,21 @@ If you're building a TypeScript library, separate the types from the main entry ```json5 { - files: ['dist'], - type: 'module', - main: './dist/index.js', - exports: { - '.': { - types: './dist/index.d.ts', - default: './dist/index.js', + "files": ["dist"], + "type": "module", + "main": "./dist/index.js", + "exports": { + ".": { + "types": "./dist/index.d.ts", + "default": "./dist/index.js", }, - './react': { - types: './dist/react/index.d.ts', - default: './dist/react/index.js', + "./react": { + "types": "./dist/react/index.d.ts", + "default": "./dist/react/index.js", }, }, - scripts: { - build: 'bunchee', + "scripts": { + "build": "bunchee", }, } ``` @@ -388,23 +388,23 @@ _NOTE_: When you're using `.mjs` or `.cjs` extensions with TypeScript and modern ```json5 { - files: ['dist'], - type: 'module', - main: './dist/index.js', - module: './dist/index.js', - types: './dist/index.d.ts', - exports: { - import: { - types: './dist/index.d.ts', - default: './dist/index.js', + "files": ["dist"], + "type": "module", + "main": "./dist/index.js", + "module": "./dist/index.js", + "types": "./dist/index.d.ts", + "exports": { + "import": { + "types": "./dist/index.d.ts", + "default": "./dist/index.js", }, - require: { - types: './dist/index.d.cts', - default: './dist/index.cjs', + "require": { + "types": "./dist/index.d.cts", + "default": "./dist/index.cjs", }, }, - scripts: { - build: 'bunchee', + "scripts": { + "build": "bunchee", }, } ``` @@ -450,9 +450,9 @@ This will match the export name `"react-server"` and `"edge-light"` then use the ```json5 { - exports: { - development: './dist/index.development.js', - production: './dist/index.production.js', + "exports": { + "development": './dist/index.development.js', + "production": './dist/index.production.js', }, } ``` @@ -538,11 +538,11 @@ For example: ```json5 { - browserslist: [ - 'last 1 version', - '> 1%', - 'maintained node versions', - 'not dead', + "browserslist": [ + "last 1 version", + "> 1%", + "maintained node versions", + "not dead", ], } ``` diff --git a/docs/app/globals.css b/docs/app/globals.css index 1da99f08..0c134c08 100644 --- a/docs/app/globals.css +++ b/docs/app/globals.css @@ -42,9 +42,20 @@ h6 { /** Styles */ body { - font-family: var(--font-geist-sans), system-ui, -apple-system, - BlinkMacSystemFont, Segoe UI, Roboto, Helvetica Neue, Arial, Noto Sans, - sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol, + font-family: + var(--font-geist-sans), + system-ui, + -apple-system, + BlinkMacSystemFont, + Segoe UI, + Roboto, + Helvetica Neue, + Arial, + Noto Sans, + sans-serif, + Apple Color Emoji, + Segoe UI Emoji, + Segoe UI Symbol, Noto Color Emoji; font-feature-settings: 'liga', 'clig', 'calt'; font-variant: common-ligatures contextual; @@ -158,4 +169,4 @@ li { .code--inline { color: #507a99; -} \ No newline at end of file +} diff --git a/package.json b/package.json index d60560a5..46727948 100644 --- a/package.json +++ b/package.json @@ -107,7 +107,7 @@ "lint-staged": "^15.2.2", "next": "^15.0.4", "picocolors": "^1.0.0", - "prettier": "2.8.8", + "prettier": "3.4.2", "react": "^19.0.0", "react-dom": "^19.0.0", "typescript": "^5.7.2" diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 41ff43c8..68f697e2 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -121,8 +121,8 @@ importers: specifier: ^1.0.0 version: 1.0.0 prettier: - specifier: 2.8.8 - version: 2.8.8 + specifier: 3.4.2 + version: 3.4.2 react: specifier: ^19.0.0 version: 19.0.0 @@ -2027,9 +2027,9 @@ packages: resolution: {integrity: sha512-PS08Iboia9mts/2ygV3eLpY5ghnUcfLV/EXTOW1E2qYxJKGGBUtNjN76FYHnMs36RmARn41bC0AZmn+rR0OVpQ==} engines: {node: ^10 || ^12 || >=14} - prettier@2.8.8: - resolution: {integrity: sha512-tdN8qQGvNjw4CHbY+XXk0JgCXn9QiF21a55rBe5LJAU+kDyC4WQn4+awm2Xfk2lQMk5fKup9XgzTZtGkjBdP9Q==} - engines: {node: '>=10.13.0'} + prettier@3.4.2: + resolution: {integrity: sha512-e9MewbtFo+Fevyuxn/4rrcDAaq0IYxPGLvObpQjiZBMAzB9IGmzlnG9RZy3FFas+eBMu2vA0CszMeduow5dIuQ==} + engines: {node: '>=14'} hasBin: true pretty-bytes@5.6.0: @@ -4509,7 +4509,7 @@ snapshots: picocolors: 1.0.0 source-map-js: 1.2.1 - prettier@2.8.8: {} + prettier@3.4.2: {} pretty-bytes@5.6.0: {} diff --git a/src/exports.ts b/src/exports.ts index f6973808..69d4a353 100644 --- a/src/exports.ts +++ b/src/exports.ts @@ -330,9 +330,9 @@ export function getExportTypeFromFile( const exportType = isEsmExt ? 'import' : isCjsExt - ? 'require' - : isESModule - ? 'import' - : 'require' + ? 'require' + : isESModule + ? 'import' + : 'require' return exportType } diff --git a/src/rollup/output.ts b/src/rollup/output.ts index 71c70d9c..aea507c4 100644 --- a/src/rollup/output.ts +++ b/src/rollup/output.ts @@ -32,8 +32,8 @@ export async function buildOutputConfigs( cwd, dts ? bundleConfig.file! - : exportCondition.export.types ?? - getExportFileTypePath(bundleConfig.file!), + : (exportCondition.export.types ?? + getExportFileTypePath(bundleConfig.file!)), ) const typesDir = dirname(dtsFile) const jsDir = dirname(absoluteOutputFile!) @@ -61,10 +61,10 @@ export async function buildOutputConfigs( const ext = dts ? 'd.ts' : isCjsFormat && isEsmPkg - ? 'cjs' - : !isCjsFormat && !isEsmPkg - ? 'mjs' - : 'js' + ? 'cjs' + : !isCjsFormat && !isEsmPkg + ? 'mjs' + : 'js' return '[name]-[hash].' + ext }, // By default in rollup, when creating multiple chunks, transitive imports of entry chunks