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. Generates index files from templates based on the build configuration
233
+
3. Creates version-specific export files
234
+
4. Creates a `build-info.json` file documenting what was included
235
+
236
+
The templates automatically adjust to include only the versions specified in the build configuration, ensuring proper TypeScript types and runtime validation.
237
+
238
+
**Note**: Build scripts use `cross-env` for Windows compatibility.
239
+
240
+
**Important**: Before building the parser package, ensure that the version packages are built first:
241
+
```bash
242
+
# Build all version packages first
243
+
pnpm build # builds libpg-query versions
244
+
245
+
# Then build the parser with desired configuration
246
+
cd parser
247
+
npm run build:lts # or build:full, build:latest, etc.
248
+
```
249
+
250
+
### Publishing with Different Tags
251
+
252
+
```bash
253
+
# Publish full version as latest
254
+
npm run build:full
255
+
npm publish
256
+
257
+
# Publish LTS version with lts tag
258
+
npm run build:lts
259
+
npm publish --tag lts
260
+
261
+
# Publish legacy version with legacy tag
262
+
npm run build:legacy
263
+
npm publish --tag legacy
264
+
```
265
+
266
+
### What it does
267
+
- Publishes `@pgsql/parser` - a multi-version PostgreSQL parser with dynamic version selection
268
+
- Provides a unified interface to work with multiple PostgreSQL versions
269
+
- Supports different build configurations for different use cases
270
+
- Includes both CommonJS and ESM builds
271
+
- Exports version-specific parsers via subpaths (e.g., `@pgsql/parser/v17`)
272
+
273
+
### Install published package
274
+
```bash
275
+
# Install latest (full build)
276
+
npm install @pgsql/parser
277
+
278
+
# Install LTS version
279
+
npm install @pgsql/parser@lts
280
+
281
+
# Install legacy version
282
+
npm install @pgsql/parser@legacy
283
+
284
+
# Use version-specific imports:
285
+
# import { parse } from '@pgsql/parser/v17'
286
+
# import { parse } from '@pgsql/parser/v16'
287
+
# import { parse } from '@pgsql/parser/v13'
288
+
```
289
+
290
+
### Alternative: Using npm scripts from root
291
+
```bash
292
+
# From the repository root:
293
+
pnpm build:parser # Build the parser package (full build)
294
+
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