Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(prettier-config): switch bundled config to CJS #659

Merged
merged 1 commit into from
Nov 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .changeset/kind-pets-vanish.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"@bfra.me/prettier-config": patch
---

Output the bundled config as CJS in an attempt to resolve issues with the VS Code Prettier extension.

2 changes: 1 addition & 1 deletion .gitattributes
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
* text=auto eol=lf

packages/prettier-config/index.js -diff linguist-generated=true
packages/prettier-config/index.cjs -diff linguist-generated=true
2 changes: 1 addition & 1 deletion .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@
packages/api-core/test-utils/sdks/
packages/eslint-config/.eslint-config-inspector
packages/eslint-config/src/*.d.ts
packages/prettier-config/index.js
packages/prettier-config/index.cjs
1 change: 1 addition & 0 deletions packages/prettier-config/.gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
test/_fixtures
index.cjs.map
2 changes: 1 addition & 1 deletion packages/prettier-config/.prettierignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
test/fixtures/
index.js
index.cjs
2 changes: 1 addition & 1 deletion packages/prettier-config/eslint.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ import config from '../../eslint.config'

export default composeConfig(config, {
name: '@bfra.me/prettier-config/bundled',
ignores: ['index.js'],
ignores: ['index.cjs'],
})
9 changes: 9 additions & 0 deletions packages/prettier-config/index.cjs

Large diffs are not rendered by default.

10 changes: 0 additions & 10 deletions packages/prettier-config/index.js

This file was deleted.

2 changes: 1 addition & 1 deletion packages/prettier-config/index.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
"index.js"
"index.cjs"
9 changes: 5 additions & 4 deletions packages/prettier-config/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
".": {
"types": "./lib/index.d.ts",
"source": "./src/index.ts",
"default": "./index.js"
"default": "./index.cjs"
},
"./*": {
"types": "./lib/*.d.ts",
Expand All @@ -38,18 +38,19 @@
"./*/semi": "./lib/*.js?semi=true",
"./package.json": "./package.json"
},
"main": "./index.js",
"main": "./index.cjs",
"module": "./lib/index.js",
"types": "./lib/index.d.ts",
"files": [
"lib",
"src",
"index.json",
"index.js",
"index.cjs",
"!**/*.map"
],
"scripts": {
"build": "tsup",
"postbuild": "prettier --config ./index.js --ignore-path .prettierignore --log-level warn --write .",
"postbuild": "prettier --config ./index.cjs --ignore-path .prettierignore --log-level warn --write .",
"prepack": "pnpm --filter-prod=\"{.}...\" --loglevel error run build",
"test": "pnpm --filter-prod=\"{.}...\" --loglevel error run build && vitest"
},
Expand Down
8 changes: 3 additions & 5 deletions packages/prettier-config/tsup.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,15 @@ export default defineConfig([
target: 'es2022',
},
{
banner: {
js: "import {createRequire}from'node:module';const require=createRequire(import.meta.url);",
},
entry: ['./src/index.ts'],
format: ['esm'],
format: ['cjs'],
minify: true,
// Bundle the config and dependencies into a single file.
noExternal: [/^@bfra.me\//],
outDir: '.',
shims: true,
sourcemap: true,
target: 'es2022',
treeshake: 'smallest',
treeshake: 'safest',
},
])