mirror of
https://github.com/mermaid-js/mermaid.git
synced 2025-09-07 17:46:44 +02:00
Vite
This commit is contained in:
31
jison.js
Normal file
31
jison.js
Normal file
@@ -0,0 +1,31 @@
|
||||
import { Jison } from 'jison';
|
||||
import { createFilter } from 'rollup-pluginutils';
|
||||
|
||||
export default (options = {}) => ({
|
||||
name: 'jison',
|
||||
transform(grammar, id) {
|
||||
const { include = ['*.jison', '**/*.jison'], exclude, type = 'lalr' } = options;
|
||||
const filter = createFilter(include, exclude);
|
||||
if (!filter(id)) return null;
|
||||
|
||||
const parser = new Jison.Generator(grammar, {
|
||||
moduleType: 'js',
|
||||
type,
|
||||
});
|
||||
|
||||
const source = parser.generate();
|
||||
const exporter = `
|
||||
const parse = parser.parse.bind(parser);
|
||||
parser.parser = parse;
|
||||
|
||||
export { parser };
|
||||
export default parser;
|
||||
`;
|
||||
|
||||
console.log('helll');
|
||||
return {
|
||||
code: `${source} ${exporter}`,
|
||||
map: { mappings: '' },
|
||||
};
|
||||
},
|
||||
});
|
Reference in New Issue
Block a user