diff --git a/.github/MAINTENANCE.md b/.github/MAINTENANCE.md new file mode 100644 index 0000000..6c0c2c0 --- /dev/null +++ b/.github/MAINTENANCE.md @@ -0,0 +1,10 @@ +This document explains how to perform the project's maintenance tasks. + +### Creating a new release + +Anyone with write access to the repository can request a new release. To do so, follow these steps: + +1. Run `npm version ` locally to bump the version number and create a new commit / tag. +2. Push the commit and tag to the repository by running `git push --follow-tags`. +3. The release will be automatically published to npm by GitHub Actions once approved by an administrator. +4. Go to and create a new release with the tag that was just created. Describe the notable changes in the release notes. diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml new file mode 100644 index 0000000..a7b7170 --- /dev/null +++ b/.github/workflows/publish.yml @@ -0,0 +1,24 @@ +name: Release + +on: + push: + tags: + - 'v*' # Push events to matching v*, i.e. v1.0, v20.15.10 + +jobs: + release: + # Use Publish environment for deployment protection + environment: Publish + runs-on: ubuntu-latest + permissions: + contents: read + id-token: write + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-node@v4 + with: + node-version: 'lts/*' + registry-url: 'https://registry.npmjs.org' + - run: npm publish + env: + NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} diff --git a/README.md b/README.md index f05e195..60068b5 100644 --- a/README.md +++ b/README.md @@ -3,8 +3,9 @@ TSConfigs for Vue projects to extend. Requires TypeScript >= 5.0. For TypeScript v4.5 to v4.9, please use [v0.1.x](https://www.npmjs.com/package/@vue/tsconfig/v/0.1.3). +Requires Vue.js >= 3.3. -[See below for the changes in v0.3.x.](#migrating-from-typescript--50) +[See below for the breaking changes in v0.3.x.](#migrating-from-typescript--50) ## Installation @@ -33,13 +34,13 @@ Add one of the available configurations to your `tsconfig.json`: First install the base tsconfig and types for the Node.js version you are targeting, for example: ```sh -npm add -D @tsconfig/node18 @types/node@18 +npm add -D @tsconfig/node22 @types/node@22 ``` If you are not using any bundlers, the Node.js code doesn't rely on any Vue/Vite-specific features, then these would be enough, you may not need to extend the Vue TSConfig: ```json -"extends": "@tsconfig/node18/tsconfig.json", +"extends": "@tsconfig/node22/tsconfig.json", "compilerOptions": { "types": ["node"] } @@ -49,7 +50,7 @@ Otherwise, if you are trying to use Vue components in Node.js environments (e.g. ```json "extends": [ - "@tsconfig/node18/tsconfig.json", + "@tsconfig/node22/tsconfig.json", "@vue/tsconfig/tsconfig.json" ], "compilerOptions": { @@ -57,7 +58,18 @@ Otherwise, if you are trying to use Vue components in Node.js environments (e.g. } ``` -Make sure to place `@vue/tsconfig/tsconfig.json` *after* `@tsconfig/node18/tsconfig.json` so that it takes precedence. +Make sure to place `@vue/tsconfig/tsconfig.json` *after* `@tsconfig/node22/tsconfig.json` so that it takes precedence. + +## Emitting Declaration Files + +As most Vue projects are built with bundlers, the default Vue TSConfig does not emit declaration files. If you are building a library or a component library, you can enable declaration file emitting by also extending `@vue/tsconfig/tsconfig.lib.json` in your `tsconfig.json`: + +```json +"extends": [ + "@vue/tsconfig/tsconfig.dom.json", + "@vue/tsconfig/tsconfig.lib.json" +] +``` ## Migrating from TypeScript < 5.0 diff --git a/package.json b/package.json index 88227bf..d1986b0 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@vue/tsconfig", - "version": "0.4.0", + "version": "0.7.0", "description": "A base TSConfig for working with Vue.js", "main": "tsconfig.json", "scripts": { @@ -21,6 +21,19 @@ }, "homepage": "https://github.com/vuejs/tsconfig#readme", "publishConfig": { - "access": "public" + "access": "public", + "provenance": true + }, + "peerDependencies": { + "typescript": "5.x", + "vue": "^3.4.0" + }, + "peerDependenciesMeta": { + "typescript": { + "optional": true + }, + "vue": { + "optional": true + } } } diff --git a/tsconfig.json b/tsconfig.json index d185ef8..6584fa9 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,5 +1,9 @@ { "compilerOptions": { + // Most non-library projects don't need to emit declarations. + // So we add this option by default to make the config more friendly to most users. + "noEmit": true, + // As long as you are using a build tool, we recommend you to author and ship in ES modules. // Even if you are targeting Node.js, because // - `CommonJS` is too outdated @@ -9,13 +13,13 @@ // We expect users to use bundlers. // So here we enable some resolution features that are only available in bundlers. - "moduleResolution": "bundler", + "moduleResolution": "Bundler", "resolveJsonModule": true, - // `allowImportingTsExtensions` can only be used when `noEmit` or `emitDeclarationOnly` is set. - // But `noEmit` may cause problems with solution-style tsconfigs: - // - // And `emitDeclarationOnly` is not always wanted. - // Considering it's not likely to be commonly used in Vue codebases, we don't enable it here. + "allowImportingTsExtensions": true, + // Even files without `import` or `export` are treated as modules. + // It helps to avoid mysterious errors such as `Cannot redeclare block-scoped variable 'name`. + // https://www.totaltypescript.com/cannot-redeclare-block-scoped-variable#solution-3-your-module-isnt-a-module + "moduleDetection": "force", // Required in Vue projects "jsx": "preserve", @@ -40,7 +44,7 @@ // at least `ES2020` for dynamic `import()`s and `import.meta` to work correctly. // - If you are not using Vite, feel free to overwrite the `target` field. "target": "ESNext", - // For spec compilance. + // For spec compliance. // `true` by default if the `target` is `ES2020` or higher. // Explicitly set it to `true` here in case some users want to overwrite the `target`. "useDefineForClassFields": true, diff --git a/tsconfig.lib.json b/tsconfig.lib.json new file mode 100644 index 0000000..d6b6fca --- /dev/null +++ b/tsconfig.lib.json @@ -0,0 +1,8 @@ +{ + "compilerOptions": { + "noEmit": false, + "declaration": true, + "emitDeclarationOnly": true, + "skipLibCheck": false + } +} pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy