peggy-loader.ts 490 B

123456789101112131415161718
  1. import peggy from 'peggy';
  2. import type {LoaderDefinitionFunction} from 'webpack';
  3. const peggyLoader: LoaderDefinitionFunction = source => {
  4. // https://peggyjs.org/documentation.html#generating-a-parser-javascript-api
  5. const peggyOptions: peggy.OutputFormatAmdCommonjsEs = {
  6. cache: false,
  7. dependencies: {},
  8. format: 'commonjs',
  9. optimize: 'speed',
  10. trace: false,
  11. output: 'source',
  12. };
  13. return peggy.generate(source, peggyOptions);
  14. };
  15. export default peggyLoader;