Skip to content

Commit

Permalink
prettier: fix format
Browse files Browse the repository at this point in the history
  • Loading branch information
huozhi committed Jan 24, 2025
1 parent 0030e90 commit 98a63b2
Show file tree
Hide file tree
Showing 7 changed files with 103 additions and 91 deletions.
1 change: 1 addition & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
pnpm-lock.yaml
README.md
140 changes: 70 additions & 70 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
}
```

Expand All @@ -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",
},
}
```
Expand Down Expand Up @@ -124,15 +124,15 @@ The `dependencies` and `peerDependencies` will be marked as externalized and won
```json5
{
// Externalized
dependencies: {
"dependencies": {
/* ... */
},
peerDependencies: {
"peerDependencies": {
/* ... */
},
// Bundled
devDependencies: {
"devDependencies": {
/* ... */
},
}
Expand All @@ -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",
},
}
```
Expand All @@ -161,8 +161,8 @@ For instance:
```json5
// package.json
{
imports: {
'#util': './src/utils.ts',
"imports": {
"#util": "./src/utils.ts",
},
}
```
Expand All @@ -183,7 +183,7 @@ This will match the `bin` field in package.json as:
```json5
{
bin: './dist/bin.js',
"bin": "./dist/bin.js",
}
```
Expand All @@ -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",
},
}
```
Expand Down Expand Up @@ -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",
},
}
```
Expand All @@ -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",
},
}
```
Expand All @@ -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",
},
}
```
Expand Down Expand Up @@ -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',
},
}
```
Expand Down Expand Up @@ -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",
],
}
```
Expand Down
19 changes: 15 additions & 4 deletions docs/app/globals.css
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -158,4 +169,4 @@ li {

.code--inline {
color: #507a99;
}
}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
12 changes: 6 additions & 6 deletions pnpm-lock.yaml

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

8 changes: 4 additions & 4 deletions src/exports.ts
Original file line number Diff line number Diff line change
Expand Up @@ -330,9 +330,9 @@ export function getExportTypeFromFile(
const exportType = isEsmExt
? 'import'
: isCjsExt
? 'require'
: isESModule
? 'import'
: 'require'
? 'require'
: isESModule
? 'import'
: 'require'
return exportType
}
12 changes: 6 additions & 6 deletions src/rollup/output.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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!)
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 98a63b2

Please sign in to comment.