pnpm run publish:versionsThis interactive script will:
- Check for uncommitted changes (will error if any exist)
- Let you select which versions to publish (or all)
- Also includes the full package (@libpg-query/parser)
- Ask for version bump type (patch or minor only)
- Ask if you want to skip the build step (useful if already built)
- Always run tests (even if build is skipped)
- Publish each selected version
- Optionally promote pg17 to latest
pnpm run publish:typesThis interactive script will:
- Check for uncommitted changes (will error if any exist)
- Let you select which versions to publish (or all)
- Ask for version bump type (patch or minor only)
- Build, prepare, and publish each selected version
- Optionally promote pg17 to latest
pnpm run publish:enumsThis interactive script will:
- Check for uncommitted changes (will error if any exist)
- Let you select which versions to publish (or all)
- Ask for version bump type (patch or minor only)
- Build, prepare, and publish each selected version
- Optionally promote pg17 to latest
The parser package supports multiple build configurations:
pnpm run publish:parser
# or with specific build type
PARSER_BUILD_TYPE=full pnpm run publish:parserPARSER_BUILD_TYPE=lts pnpm run publish:parserPARSER_BUILD_TYPE=latest pnpm run publish:parserPARSER_BUILD_TYPE=legacy pnpm run publish:parserThis command will:
- Navigate to the parser directory
- Build the parser with the specified configuration
- Publish the @pgsql/parser package to npm with appropriate dist-tag
- Note: You should manually bump the version and commit changes before running this
- Prerequisite: The version packages must be built first as the parser copies their WASM files during build
# Set the version (e.g. 17, 16, 15, etc.)
VERSION=17
cd types/${VERSION}
pnpm version patch
git add . && git commit -m "release: bump @pgsql/types${VERSION} version"
pnpm build
pnpm prepare:types
pnpm publish --tag pg${VERSION}Promote to latest (optional)
# Set the version (e.g. 17, 16, 15, etc.)
VERSION=17
# Promote pg${VERSION} tag to latest
npm dist-tag add @pgsql/types@pg${VERSION} latest- Transforms
@libpg-query/types17β@pgsql/typeswith tagpg17 - Transforms
@libpg-query/types16β@pgsql/typeswith tagpg16 - etc.
# Set the version (e.g. 17, 16, 15, etc.)
VERSION=17
cd enums/${VERSION}
pnpm version patch
git add . && git commit -m "release: bump @pgsql/enums${VERSION} version"
pnpm build
pnpm prepare:enums
pnpm publish --tag pg${VERSION}Promote to latest (optional)
# Set the version (e.g. 17, 16, 15, etc.)
VERSION=17
# Promote pg${VERSION} tag to latest
npm dist-tag add @pgsql/enums@pg${VERSION} latest- Transforms
@libpg-query/enums17β@pgsql/enumswith tagpg17 - Transforms
@libpg-query/enums16β@pgsql/enumswith tagpg16 - etc.
# Set the version (e.g. 17, 16, 15, etc.)
VERSION=17
# Build and publish a specific version
cd versions/${VERSION}
pnpm version patch
git add . && git commit -m "release: bump libpg-query${VERSION} version"
pnpm build
pnpm test
pnpm run publish:pkg- Transforms
@libpg-query/v17βlibpg-querywith tagpg17 - Transforms
@libpg-query/v16βlibpg-querywith tagpg16 - Uses
x-publish.publishNameandx-publish.distTagfrom package.json - Temporarily modifies package.json during publish, then restores it
npm install libpg-query@pg17 # PostgreSQL 17 specific
npm install libpg-query@pg16 # PostgreSQL 16 specific
npm install libpg-query # Latest/default versioncd full
pnpm version patch
git add . && git commit -m "release: bump @libpg-query/parser version"
pnpm build
pnpm test
pnpm publish --tag pg17npm dist-tag add @libpg-query/parser@pg17 latest- Publishes
@libpg-query/parserwith tagpg17 - Currently based on PostgreSQL 17
- Includes full parser with all features
npm install @libpg-query/parser@pg17 # PostgreSQL 17 specific
npm install @libpg-query/parser # Latest versioncd parser
pnpm version patch
git add . && git commit -m "release: bump @pgsql/parser version"
pnpm build
pnpm test
pnpm publishThe parser package is now a simple distribution package that copies pre-built WASM files. No TypeScript compilation needed!
- full: All versions (13, 14, 15, 16, 17) - Default
- lts: LTS versions only (16, 17)
- latest: Latest version only (17)
- legacy: Legacy versions (13, 14, 15)
# Full build (default)
npm run build
# Specific builds
npm run build:lts
npm run build:latest
npm run build:legacy
# Or using environment variable
PARSER_BUILD_TYPE=lts npm run buildThe simplified parser package:
- Copies WASM files from the
versions/*/wasm/directories - Copies TypeScript type definitions from the
types/*/dist/directories - Updates import paths to use local types instead of
@pgsql/types - Generates index files from templates based on the build configuration
- Creates version-specific export files
- Creates a
build-info.jsonfile documenting what was included
The templates automatically adjust to include only the versions specified in the build configuration, ensuring proper TypeScript types and runtime validation. The package is completely self-contained with all necessary types bundled.
Note: Build scripts use cross-env for Windows compatibility.
Important: Before building the parser package, ensure that the version packages are built first:
# Build all version packages first
pnpm build # builds libpg-query versions
# Then build the parser with desired configuration
cd parser
npm run build:lts # or build:full, build:latest, etc.The parser build process automatically:
- Copies TypeScript type definitions from
types/*/dist/directories - Places them in
wasm/v*/types/for each version - Updates all import references from
@pgsql/typesto./types - Makes the package self-contained without external type dependencies
# Publish full version as latest
npm run build:full
npm publish
# Publish LTS version with lts tag
npm run build:lts
npm publish --tag lts
# Publish legacy version with legacy tag
npm run build:legacy
npm publish --tag legacy- Publishes
@pgsql/parser- a multi-version PostgreSQL parser with dynamic version selection - Provides a unified interface to work with multiple PostgreSQL versions
- Supports different build configurations for different use cases
- Includes both CommonJS and ESM builds
- Exports version-specific parsers via subpaths (e.g.,
@pgsql/parser/v17) - Self-contained: Bundles TypeScript types locally (no external @pgsql/types dependency)
# Install latest (full build)
npm install @pgsql/parser
# Install LTS version
npm install @pgsql/parser@lts
# Install legacy version
npm install @pgsql/parser@legacy
# Use version-specific imports:
# import { parse } from '@pgsql/parser/v17'
# import { parse } from '@pgsql/parser/v16'
# import { parse } from '@pgsql/parser/v13'# From the repository root:
pnpm build:parser # Build the parser package (full build)
PARSER_BUILD_TYPE=lts pnpm build:parser # Build LTS version
pnpm publish:parser # Publish the parser package