Skip to content

Commit

Permalink
Workaround for antlr4 performance issue
Browse files Browse the repository at this point in the history
  • Loading branch information
mint-thompson committed Aug 15, 2023
1 parent 315a574 commit b2db1dd
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 2 deletions.
18 changes: 18 additions & 0 deletions dev/fixAntlr4.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
/**
* The purpose of this script is to modify the configuration.
* of the antlr4 dependency. This is necessary as a workaround
* in order to avoid performance problems from antlr4.
* The fix is taken from https://github.com/antlr/antlr4/pull/4323
* This script can be removed when the fix is available as part of
* a published NPM package.
*/

const fs = require('fs-extra');

Check failure on line 10 in dev/fixAntlr4.js

View workflow job for this annotation

GitHub Actions / Check tsc, lint, and prettier

Require statement not part of import statement
const path = require('path');

Check failure on line 11 in dev/fixAntlr4.js

View workflow job for this annotation

GitHub Actions / Check tsc, lint, and prettier

Require statement not part of import statement

const antlr4BabelPath = path.join(__dirname, '..', 'node_modules', 'antlr4', '.babelrc');
const babelContents = {
presets: ['@babel/preset-env'],
targets: 'defaults'
};
fs.writeJSONSync(antlr4BabelPath, babelContents);
7 changes: 5 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,10 @@
"regression": "ts-node regression/run-regression.ts",
"regression:all": "ts-node regression/run-regression.ts regression/repos-all.txt",
"prepare": "npm run build",
"postinstall": "npm run fixAntlr4",
"prepublishOnly": "npm run check && npm run fixGrammarTypes",
"fixGrammarTypes": "ts-node dev/fixGrammarTypes.ts"
"fixGrammarTypes": "ts-node dev/fixGrammarTypes.ts",
"fixAntlr4": "node dev/fixAntlr4.js && cd node_modules && cd antlr4 && npm install && npm run build"
},
"contributors": [
"Julia Afeltra <[email protected]>",
Expand All @@ -42,7 +44,8 @@
"dist/**/*.{js,json,d.ts}",
"dist/ig/files/**/*",
"dist/utils/init-project/**/*",
"antlr/**/*.g4"
"antlr/**/*.g4",
"dev/fixAntlr4.js"
],
"license": "Apache-2.0",
"devDependencies": {
Expand Down

0 comments on commit b2db1dd

Please sign in to comment.