-
Davis Silverman authored
Hi there, `Peg.js` is unmaintained, so I figure you all would appreciate if I replaced it with the drop-in replacement of Peggy. This is work I am breaking out of #918. Peggy adds new features like source map support that we could use, although I do not include that in this change-set. It may be useful for debugging changes to the .pegjs file we have.e
Davis Silverman authoredHi there, `Peg.js` is unmaintained, so I figure you all would appreciate if I replaced it with the drop-in replacement of Peggy. This is work I am breaking out of #918. Peggy adds new features like source map support that we could use, although I do not include that in this change-set. It may be useful for debugging changes to the .pegjs file we have.e
peg-transform.mjs 584 B
// A peggy version of the pegjs-jest-transformer
// Transforms .pegjs compliant files to JS code.
import * as crypto from 'crypto';
import peg from 'peggy';
const transform = {
process(sourceText, sourcePath, _options) {
return `module.exports = ${peg.generate(sourceText, {
output: 'source-with-inline-map',
grammarSource: sourcePath,
})}`;
},
getCacheKey(sourceText, _sourcePath, options) {
return crypto
.createHash('md5')
.update(sourceText)
.update(options.configString)
.digest('hex');
},
};
export default transform;