Skip to content
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
22 changes: 22 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -94,3 +94,25 @@ jobs:
env:
NUXT_VERSION: ${{ matrix.nuxt-version }}
NUXT_TELEMETRY_DISABLED: '1'

declarations:
timeout-minutes: 10
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
typescript-version: ['6', '7']
steps:
- uses: actions/checkout@v7
- uses: actions/setup-node@v7
with:
node-version: 22
- uses: pnpm/action-setup@v6
with:
cache: true
- run: pnpm install --frozen-lockfile
- run: pnpm dev:prepare
- name: Check published package types with TypeScript ${{ matrix.typescript-version }}
run: pnpm test:package
env:
TYPESCRIPT_VERSION: ${{ matrix.typescript-version }}
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -351,6 +351,8 @@ const attribution: AttributionSnapshot = {

Supported UTM fields are the manual campaign parameters Google Analytics 4 documents: `utm_id`, `utm_source`, `utm_medium`, `utm_campaign`, `utm_source_platform`, `utm_term`, `utm_content`, `utm_creative_format`, and `utm_marketing_tactic`. Google click fields are `gclid`, `gad_source`, `gad_campaignid`, `gbraid`, `wbraid`, and `dclid`; Google Ads sends `gbraid` or `wbraid` alongside or instead of `gclid` for some iOS traffic. A nonempty value in any of these fields makes a visit a campaign visit. When a parameter repeats in the URL, each field, including configured click parameters, keeps its first nonempty value: `?utm_source=&utm_source=google&utm_source=newsletter` saves `google`. `clickParams` holds the values of the names listed in the `clickParams` option. `gclidParams`, `clickParams`, and `customParams` are optional. The package also exports `ModuleOptions`, `UTMParams`, `GCLIDParams`, `ClickParams`, `AdditionalInfo`, `BeforeTrackContext`, `NuxtUTMHooks`, and `UseNuxtUTMReturn`.

CI compiles the published declarations with TypeScript 5.9 and with the latest TypeScript 6 and 7 releases. Older TypeScript releases are untested.

## Development

Use the pnpm version pinned in `package.json`. The commands below assume Corepack is installed; see [pnpm installation](https://pnpm.io/installation) if needed.
Expand All @@ -372,6 +374,8 @@ pnpm dev:build

`test:package` checks the actual npm tarball from an isolated TypeScript consumer. `test:compatibility` also installs it in an independent Nuxt app, checks types, builds and generates static pages, and exercises campaign navigation, reload persistence, and form submission in Chromium. It tests the latest Nuxt 4 release by default; set `NUXT_VERSION=3` for Nuxt 3 or `NUXT_VERSION=npm:nuxt-nightly@5x` for the Nuxt 5 nightly. CI runs all three separately from the checks on each supported Node.js version, and a nightly failure does not fail the workflow. These are tested configurations, not runtime version restrictions.

Set `TYPESCRIPT_VERSION` to check the tarball with another TypeScript release, for example `TYPESCRIPT_VERSION=7 pnpm test:package`. Applications compile the published declarations with their own TypeScript, so CI also runs this check with each release listed in [Data and TypeScript](#data-and-typescript).

Use `pnpm dev` for the playground. See the [release documentation](docs/RELEASING.md) for preparing and publishing a version.

## License
Expand Down
25 changes: 22 additions & 3 deletions scripts/test-package.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,29 @@ try {
files: ['consumer.mts'],
}),
)
execFileSync(process.execPath, [join(root, 'node_modules/typescript/bin/tsc'), '-p', directory], {
stdio: 'inherit',
})
const compiler = typescriptCompiler(process.env.TYPESCRIPT_VERSION)
execFileSync(process.execPath, [compiler, '-p', directory], { stdio: 'inherit' })
if (process.argv.includes('--app')) await testCompatibility({ root, directory, tarball })
} finally {
rmSync(directory, { recursive: true, force: true })
}

// Consumers compile the published declarations with their own TypeScript, so CI checks newer
// releases than the one this repository builds with
function typescriptCompiler(version) {
if (!version) return join(root, 'node_modules/typescript/bin/tsc')
const prefix = join(directory, 'typescript')
const install = [
'install',
'--prefix',
prefix,
'--no-audit',
'--no-fund',
`typescript@${version}`,
]
execFileSync('npm', install, { stdio: 'inherit' })
const typescript = join(prefix, 'node_modules/typescript')
const { version: installed } = JSON.parse(readFileSync(join(typescript, 'package.json'), 'utf8'))
console.log(`Checking package types with TypeScript ${installed}`)
return join(typescript, 'bin/tsc')
}
Loading