Surface `jison` errors

Co-authored-by: Alois Klink <alois@aloisklink.com>
This commit is contained in:
Sidharth Vinod 2022-09-06 20:23:46 +05:30
parent a0fa8df0f1
commit 3a179170bb
No known key found for this signature in database
GPG Key ID: FB5CCD378D3907CD
1 changed files with 6 additions and 10 deletions

View File

@ -1,3 +1,6 @@
const { Generator } = require('jison');
const fs = require('fs');
/** @typedef {import('esbuild').BuildOptions} Options */
/**
@ -46,21 +49,14 @@ exports.umdBuild = (override = { minify: true }) => {
});
};
const { Generator } = require('jison');
let fs = require('fs');
const jisonPlugin = {
name: 'jison',
setup(build) {
build.onLoad({ filter: /\.jison$/ }, async (args) => {
// Load the file from the file system
let source = await fs.promises.readFile(args.path, 'utf8');
try {
let contents = new Generator(source, { 'token-stack': true }).generate();
return { contents, warnings: [] };
} catch (e) {
return { errors: [] };
}
const source = await fs.promises.readFile(args.path, 'utf8');
const contents = new Generator(source, { 'token-stack': true }).generate();
return { contents, warnings: [] };
});
},
};