Skip to content

Commit

Permalink
Update to SUSHI 3.3.0 and fix tests
Browse files Browse the repository at this point in the history
- Update to SUSHI 3.3.0
  Note: the version specified in the packages.json is an exact
  version because 3.3.1 has a bug where the dependency install
  does not work correctly. This will be changed eventually.
- Add a resolver for Jest to use the correct commonjs file when
  resolving anltr files in Jest.
  • Loading branch information
jafeltra committed Aug 18, 2023
1 parent c0b5fd3 commit 7b29062
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 9 deletions.
14 changes: 7 additions & 7 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 4 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"browserify-zlib": "^0.2.0",
"codemirror": "^5.62.3",
"file-saver": "^2.0.5",
"fsh-sushi": "^3.2.0",
"fsh-sushi": "3.3.0",
"gofsh": "^2.0.1",
"jszip": "^3.10.1",
"lodash": "^4.17.21",
Expand Down Expand Up @@ -53,6 +53,9 @@
"eslintConfig": {
"extends": "react-app"
},
"jest": {
"resolver": "<rootDir>/resolver.js"
},
"browserslist": {
"production": [
">0.2%",
Expand Down
19 changes: 19 additions & 0 deletions resolver.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
// Based on documentation here: https://jestjs.io/docs/configuration#resolver-string
// FSH Online needs a resolver because the anltr4 package tries to manipulate which dist file
// to use in node vs browser environments in the package.json#exports property.
// However, Jest ignores the exports property. So we need a resolver to resolve it correctly.
// Also see https://github.com/jestjs/jest/issues/10422
module.exports = (path, options) => {
// Call the defaultResolver, so we leverage its cache, error handling, etc.
return options.defaultResolver(path, {
...options,
// Use packageFilter to process parsed `package.json` before the resolution (see https://www.npmjs.com/package/resolve#resolveid-opts-cb)
packageFilter: (pkg) => {
return {
...pkg,
// Alter the value of `main` before resolving the antlr4 package
main: pkg.name === 'antlr4' ? 'dist/antlr4.node.cjs' : pkg.main
};
}
});
};
2 changes: 1 addition & 1 deletion src/components/TopBar.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ export default function TopBar() {
FSH ONLINE
</Typography>
<Typography order={2} className={classes.versionText}>
Powered by SUSHI v3.1.0 and GoFSH v2.0.1
Powered by SUSHI v3.3.0 and GoFSH v2.0.1
</Typography>
</StylesProvider>
</Box>
Expand Down

0 comments on commit 7b29062

Please sign in to comment.