You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The parser package is now a simple distribution package that copies pre-built WASM files. No TypeScript compilation needed!
209
+
210
+
#### Available Build Types:
211
+
-**full**: All versions (13, 14, 15, 16, 17) - Default
212
+
-**lts**: LTS versions only (16, 17)
213
+
-**latest**: Latest version only (17)
214
+
-**legacy**: Legacy versions (13, 14, 15)
215
+
216
+
```bash
217
+
# Full build (default)
218
+
npm run build
219
+
220
+
# Specific builds
221
+
npm run build:lts
222
+
npm run build:latest
223
+
npm run build:legacy
224
+
225
+
# Or using environment variable
226
+
PARSER_BUILD_TYPE=lts npm run build
227
+
```
228
+
229
+
### Build Process
230
+
The simplified parser package:
231
+
1. Copies WASM files from the `versions/*/wasm/` directories
232
+
2. Copies TypeScript type definitions from the `types/*/dist/` directories
233
+
3. Updates import paths to use local types instead of `@pgsql/types`
234
+
4. Generates index files from templates based on the build configuration
235
+
5. Creates version-specific export files
236
+
6. Creates a `build-info.json` file documenting what was included
237
+
238
+
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.
239
+
240
+
**Note**: Build scripts use `cross-env` for Windows compatibility.
241
+
242
+
**Important**: Before building the parser package, ensure that the version packages are built first:
243
+
```bash
244
+
# Build all version packages first
245
+
pnpm build # builds libpg-query versions
246
+
247
+
# Then build the parser with desired configuration
248
+
cd parser
249
+
npm run build:lts # or build:full, build:latest, etc.
250
+
```
251
+
252
+
### Types Bundling
253
+
The parser build process automatically:
254
+
1. Copies TypeScript type definitions from `types/*/dist/` directories
255
+
2. Places them in `wasm/v*/types/` for each version
256
+
3. Updates all import references from `@pgsql/types` to `./types`
257
+
4. Makes the package self-contained without external type dependencies
258
+
259
+
### Publishing with Different Tags
260
+
261
+
```bash
262
+
# Publish full version as latest
263
+
npm run build:full
264
+
npm publish
265
+
266
+
# Publish LTS version with lts tag
267
+
npm run build:lts
268
+
npm publish --tag lts
269
+
270
+
# Publish legacy version with legacy tag
271
+
npm run build:legacy
272
+
npm publish --tag legacy
273
+
```
274
+
275
+
### What it does
276
+
- Publishes `@pgsql/parser` - a multi-version PostgreSQL parser with dynamic version selection
277
+
- Provides a unified interface to work with multiple PostgreSQL versions
278
+
- Supports different build configurations for different use cases
279
+
- Includes both CommonJS and ESM builds
280
+
- Exports version-specific parsers via subpaths (e.g., `@pgsql/parser/v17`)
281
+
-**Self-contained**: Bundles TypeScript types locally (no external @pgsql/types dependency)
282
+
283
+
### Install published package
284
+
```bash
285
+
# Install latest (full build)
286
+
npm install @pgsql/parser
287
+
288
+
# Install LTS version
289
+
npm install @pgsql/parser@lts
290
+
291
+
# Install legacy version
292
+
npm install @pgsql/parser@legacy
293
+
294
+
# Use version-specific imports:
295
+
# import { parse } from '@pgsql/parser/v17'
296
+
# import { parse } from '@pgsql/parser/v16'
297
+
# import { parse } from '@pgsql/parser/v13'
298
+
```
299
+
300
+
### Alternative: Using npm scripts from root
301
+
```bash
302
+
# From the repository root:
303
+
pnpm build:parser # Build the parser package (full build)
304
+
PARSER_BUILD_TYPE=lts pnpm build:parser # Build LTS version
Multi-version PostgreSQL parser with dynamic version selection. This package provides a unified interface to parse PostgreSQL queries using different parser versions (15, 16, 17).
16
+
Multi-version PostgreSQL parser with dynamic version selection. This package provides a unified interface to parse PostgreSQL queries using different parser versions (13, 14, 15, 16, 17).
0 commit comments