diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index e54a288a..e5dcaeae 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -1,29 +1,27 @@ // For format details, see https://aka.ms/devcontainer.json. For config options, see the README at: // https://github.com/microsoft/vscode-dev-containers/tree/v0.222.0/containers/javascript-node { - "name": "Node.js", - "build": { - "dockerfile": "Dockerfile", - // Update 'VARIANT' to pick a Node version: 16, 14, 12. - // Append -bullseye or -buster to pin to an OS version. - // Use -bullseye variants on local arm64/Apple Silicon. - "args": { "VARIANT": "16-bullseye" } - }, + "name": "Node.js", + "build": { + "dockerfile": "Dockerfile", + // Update 'VARIANT' to pick a Node version: 16, 14, 12. + // Append -bullseye or -buster to pin to an OS version. + // Use -bullseye variants on local arm64/Apple Silicon. + "args": { "VARIANT": "16-bullseye" } + }, - // Set *default* container specific settings.json values on container create. - "settings": {}, + // Set *default* container specific settings.json values on container create. + "settings": {}, - // Add the IDs of extensions you want installed when the container is created. - "extensions": [ - "dbaeumer.vscode-eslint" - ], + // Add the IDs of extensions you want installed when the container is created. + "extensions": ["dbaeumer.vscode-eslint"], - // Use 'forwardPorts' to make a list of ports inside the container available locally. - // "forwardPorts": [], + // Use 'forwardPorts' to make a list of ports inside the container available locally. + // "forwardPorts": [], - // Use 'postCreateCommand' to run commands after the container is created. - "postCreateCommand": "pnpm install", + // Use 'postCreateCommand' to run commands after the container is created. + "postCreateCommand": "pnpm install", - // Comment out to connect as root instead. More info: https://aka.ms/vscode-remote/containers/non-root. - "remoteUser": "node" + // Comment out to connect as root instead. More info: https://aka.ms/vscode-remote/containers/non-root. + "remoteUser": "node" } diff --git a/.github/workflows/format.yml b/.github/workflows/format.yml new file mode 100644 index 00000000..41ddf54a --- /dev/null +++ b/.github/workflows/format.yml @@ -0,0 +1,37 @@ +name: Fix + +on: + push: + branches-ignore: + - 'main' + - 'dev' + +jobs: + format: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + + - uses: pnpm/action-setup@v2 + name: Install pnpm + + - uses: actions/setup-node@v4 + with: + node-version: lts/* + cache: pnpm + + - run: pnpm i + + - name: Format + run: pnpm run format + + - name: Commit files and push + continue-on-error: true + if: ${{ github.ref != 'refs/heads/main' && github.ref != 'refs/heads/dev' }} + run: | + git config --local user.email "github-actions[bot]@users.noreply.github.com" + git config --local user.name "github-actions[bot]" + git add --all + git commit -m "chore(ci): [bot] format code" + git push diff --git a/.prettierignore b/.prettierignore new file mode 100644 index 00000000..b8ba9a0e --- /dev/null +++ b/.prettierignore @@ -0,0 +1,3 @@ +pnpm-lock.yaml +.cache +dist diff --git a/.prettierrc b/.prettierrc index c3481a75..fd496a82 100644 --- a/.prettierrc +++ b/.prettierrc @@ -1,4 +1,4 @@ { "singleQuote": true, "semi": false -} \ No newline at end of file +} diff --git a/README.md b/README.md index 7b984cf6..a6a6d444 100644 --- a/README.md +++ b/README.md @@ -52,7 +52,6 @@ Head over to the [discussions](https://github.com/egoist/tsup/discussions) to sh ## Sponsors -

diff --git a/package.json b/package.json index f6145ba2..647b09d0 100644 --- a/package.json +++ b/package.json @@ -24,6 +24,7 @@ "build": "tsup src/cli-*.ts src/index.ts src/rollup.ts --clean --splitting", "prepublishOnly": "npm run build", "test": "npm run build && npm run test-only", + "format": "prettier --write .", "test-only": "vitest run", "build-fast": "npm run build -- --no-dts" }, diff --git a/renovate.json b/renovate.json index f45d8f11..4f39080e 100644 --- a/renovate.json +++ b/renovate.json @@ -1,5 +1,3 @@ { - "extends": [ - "config:base" - ] + "extends": ["config:base"] } diff --git a/schema.json b/schema.json index 0402482e..a033bf76 100644 --- a/schema.json +++ b/schema.json @@ -24,7 +24,6 @@ } } ] - } } }, diff --git a/src/cli-main.ts b/src/cli-main.ts index 790723e1..58f9dad0 100644 --- a/src/cli-main.ts +++ b/src/cli-main.ts @@ -38,7 +38,10 @@ export async function main(options: Options = {}) { .option('--dts [entry]', 'Generate declaration file') .option('--dts-resolve', 'Resolve externals types used for d.ts files') .option('--dts-only', 'Emit declaration files only') - .option('--experimental-dts [entry]', 'Generate declaration file (experimental)') + .option( + '--experimental-dts [entry]', + 'Generate declaration file (experimental)' + ) .option( '--sourcemap [inline]', 'Generate external sourcemap, or inline source: --sourcemap inline' diff --git a/src/esbuild/node-protocol.ts b/src/esbuild/node-protocol.ts index 1bf66228..a35e0abd 100644 --- a/src/esbuild/node-protocol.ts +++ b/src/esbuild/node-protocol.ts @@ -5,17 +5,20 @@ import { Plugin } from 'esbuild' * https://nodejs.org/api/esm.html#node-imports */ export const nodeProtocolPlugin = (): Plugin => { - const nodeProtocol = 'node:' + const nodeProtocol = 'node:' - return { - name: 'node-protocol-plugin', - setup({ onResolve }) { - onResolve({ - filter: /^node:/, - }, ({ path }) => ({ - path: path.slice(nodeProtocol.length), - external: true - })) - } - } + return { + name: 'node-protocol-plugin', + setup({ onResolve }) { + onResolve( + { + filter: /^node:/, + }, + ({ path }) => ({ + path: path.slice(nodeProtocol.length), + external: true, + }) + ) + }, + } } diff --git a/src/exports.ts b/src/exports.ts index d265effe..c1fdf3e2 100644 --- a/src/exports.ts +++ b/src/exports.ts @@ -82,7 +82,7 @@ export function formatDistributionExports( if (!importPath.match(/^\.+\//)) { importPath = './' + importPath } - + let seen = { named: new Set(), module: new Set(), diff --git a/src/plugins/tree-shaking.ts b/src/plugins/tree-shaking.ts index f1c9a9ef..3826f1ce 100644 --- a/src/plugins/tree-shaking.ts +++ b/src/plugins/tree-shaking.ts @@ -11,7 +11,7 @@ export const treeShakingPlugin = ({ name, silent, }: { - treeshake?: TreeshakingStrategy, + treeshake?: TreeshakingStrategy name?: string silent?: boolean }): Plugin => { @@ -46,7 +46,7 @@ export const treeShakingPlugin = ({ format: this.format, file: 'out.js', sourcemap: !!this.options.sourcemap, - name + name, }) for (const file of result.output) {