Skip to content

Commit

Permalink
chore: use module-builder stub mode for more accurate types
Browse files Browse the repository at this point in the history
  • Loading branch information
johannschopplich committed Dec 6, 2023
1 parent 44de48e commit 515c6b9
Show file tree
Hide file tree
Showing 11 changed files with 1,559 additions and 1,626 deletions.
39 changes: 21 additions & 18 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,33 +13,35 @@ jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- uses: actions/setup-node@v3
- uses: actions/checkout@v4
- run: corepack enable
- uses: actions/setup-node@v4
with:
node-version: 18

- run: corepack enable

- name: Install
run: pnpm i
run: pnpm install

- name: Build type stubs
run: pnpm dev:prepare

- name: Lint
run: pnpm run lint

typecheck:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- uses: actions/setup-node@v3
- uses: actions/checkout@v4
- run: corepack enable
- uses: actions/setup-node@v4
with:
node-version: 18

- run: corepack enable

- name: Install
run: pnpm i
run: pnpm install

- name: Build type stubs
run: pnpm dev:prepare

- name: Typecheck
run: pnpm run test:types
Expand All @@ -54,16 +56,17 @@ jobs:
fail-fast: false

steps:
- uses: actions/checkout@v3

- uses: actions/setup-node@v3
- uses: actions/checkout@v4
- run: corepack enable
- uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node }}

- run: corepack enable

- name: Install
run: pnpm i
run: pnpm install

- name: Build type stubs
run: pnpm dev:prepare

- name: Test
run: pnpm run test
13 changes: 7 additions & 6 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,23 +12,24 @@ jobs:
release:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
fetch-depth: 0

- uses: actions/setup-node@v3
- run: corepack enable
- uses: actions/setup-node@v4
with:
node-version: 18
registry-url: https://registry.npmjs.org/

- run: corepack enable

- run: npx changelogithub
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Install
run: pnpm i
run: pnpm install

- name: Build type stubs
run: pnpm dev:prepare

- name: Publish to npm
run: npm publish --access public
Expand Down
10 changes: 4 additions & 6 deletions eslint.config.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
import antfu from '@antfu/eslint-config'

export default antfu(
{
rules: {
'node/prefer-global/process': 'off',
},
export default await antfu({
rules: {
'node/prefer-global/process': 'off',
},
)
})
27 changes: 13 additions & 14 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "@byjohann/nuxt-i18n",
"type": "module",
"version": "1.0.3",
"packageManager": "pnpm@8.10.2",
"packageManager": "pnpm@8.11.0",
"description": "Minimal module for i18n with locale auto-imports & localized routing",
"author": "Johann Schopplich <[email protected]>",
"license": "MIT",
Expand Down Expand Up @@ -30,34 +30,33 @@
"dist"
],
"scripts": {
"prepack": "nuxt-module-build build",
"dev": "nuxi dev playground",
"dev:build": "nuxi build playground",
"dev:prepare": "nuxt-module-build --stub && nuxi prepare playground",
"dev:prepare": "nuxt-module-build build --stub && nuxt-module-build prepare && nuxi prepare playground",
"lint": "eslint .",
"lint:fix": "eslint . --fix",
"test": "vitest",
"test:types": "tsc --noEmit",
"release": "bumpp --commit --push --tag",
"prepare": "nuxi prepare playground",
"prepack": "nuxt-module-build build"
"release": "bumpp --commit --push --tag"
},
"dependencies": {
"@byjohann/vue-i18n": "^1.2.1",
"@nuxt/kit": "^3.8.1",
"@nuxt/kit": "^3.8.2",
"knitwork": "^1.0.0",
"pathe": "^1.1.1"
},
"devDependencies": {
"@antfu/eslint-config": "^1.1.0",
"@antfu/eslint-config": "^2.3.4",
"@byjohann/nuxt-i18n": "workspace:*",
"@nuxt/module-builder": "^0.5.3",
"@nuxt/module-builder": "^0.5.4",
"@nuxt/test-utils": "^3.8.1",
"@types/node": "^20.8.10",
"@types/node": "^20.10.3",
"bumpp": "^9.2.0",
"eslint": "^8.53.0",
"nuxt": "^3.8.1",
"typescript": "^5.2.2",
"vitest": "^0.34.6",
"vue-tsc": "^1.8.22"
"eslint": "^8.55.0",
"nuxt": "^3.8.2",
"typescript": "^5.3.2",
"vitest": "^1.0.1",
"vue-tsc": "^1.8.25"
}
}
2 changes: 2 additions & 0 deletions playground/composables/test-result.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { useHead } from '#imports'

export function useTestResult(data: any) {
useHead({
script: [
Expand Down
2 changes: 2 additions & 0 deletions playground/middleware/redirects.global.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { defineNuxtRouteMiddleware, navigateTo, useI18n, useRequestHeaders } from '#imports'

export default defineNuxtRouteMiddleware((to) => {
const { defaultLocale } = useI18n()

Expand Down
8 changes: 7 additions & 1 deletion playground/package.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
{
"name": "playground",
"private": true
"type": "module",
"private": true,
"scripts": {
"dev": "nuxi dev",
"build": "nuxi build",
"generate": "nuxi generate"
}
}
3 changes: 3 additions & 0 deletions playground/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"extends": "./.nuxt/tsconfig.json"
}
Loading

0 comments on commit 515c6b9

Please sign in to comment.