| 1 | import { readFile } from 'node:fs/promises'; |
| 2 | import { transformJison } from '../.build/jisonTransformer.js'; |
| 3 | import type { Plugin } from 'esbuild'; |
| 4 | |
| 5 | export const jisonPlugin: Plugin = { |
| 6 | name: 'jison', |
| 7 | setup(build) { |
| 8 | build.onLoad({ filter: /\.jison$/ }, async (args) => { |
| 9 | // Load the file from the file system |
| 10 | const source = await readFile(args.path, 'utf8'); |
| 11 | const contents = transformJison(source); |
| 12 | return { contents, warnings: [] }; |
| 13 | }); |
| 14 | }, |
| 15 | }; |
| 16 |