diff --git a/package-lock.json b/package-lock.json index 1292672..4e464d1 100644 --- a/package-lock.json +++ b/package-lock.json @@ -19,7 +19,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", @@ -10102,9 +10102,9 @@ } }, "node_modules/fsh-sushi": { - "version": "3.2.0", - "resolved": "https://registry.npmjs.org/fsh-sushi/-/fsh-sushi-3.2.0.tgz", - "integrity": "sha512-x868X0+a1vc/0Muw2l2j7S4+Xw51MNcEd9iAP0SJDEvl/ZjTUQhpPHzxL8p93NauJ05sRnlKMT15y+RZvt9rHg==", + "version": "3.3.0", + "resolved": "https://registry.npmjs.org/fsh-sushi/-/fsh-sushi-3.3.0.tgz", + "integrity": "sha512-vUR1BsTI464a67l/M4I7UIt1gL6cc0I4yHj1n1C4g3tnN5IkJwOvx2qKX5G055NN98Ca0wGrVmNSeLaRbROuWQ==", "dependencies": { "ajv": "^8.12.0", "antlr4": "~4.13.0", @@ -31777,9 +31777,9 @@ "optional": true }, "fsh-sushi": { - "version": "3.2.0", - "resolved": "https://registry.npmjs.org/fsh-sushi/-/fsh-sushi-3.2.0.tgz", - "integrity": "sha512-x868X0+a1vc/0Muw2l2j7S4+Xw51MNcEd9iAP0SJDEvl/ZjTUQhpPHzxL8p93NauJ05sRnlKMT15y+RZvt9rHg==", + "version": "3.3.0", + "resolved": "https://registry.npmjs.org/fsh-sushi/-/fsh-sushi-3.3.0.tgz", + "integrity": "sha512-vUR1BsTI464a67l/M4I7UIt1gL6cc0I4yHj1n1C4g3tnN5IkJwOvx2qKX5G055NN98Ca0wGrVmNSeLaRbROuWQ==", "requires": { "ajv": "^8.12.0", "antlr4": "~4.13.0", diff --git a/package.json b/package.json index 1c316e0..c3c99b2 100644 --- a/package.json +++ b/package.json @@ -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", @@ -53,6 +53,9 @@ "eslintConfig": { "extends": "react-app" }, + "jest": { + "resolver": "/resolver.js" + }, "browserslist": { "production": [ ">0.2%", diff --git a/resolver.js b/resolver.js new file mode 100644 index 0000000..b8e6d7e --- /dev/null +++ b/resolver.js @@ -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 + }; + } + }); +}; diff --git a/src/components/TopBar.js b/src/components/TopBar.js index f391ab8..e1e62a8 100644 --- a/src/components/TopBar.js +++ b/src/components/TopBar.js @@ -59,7 +59,7 @@ export default function TopBar() { FSH ONLINE - Powered by SUSHI v3.1.0 and GoFSH v2.0.1 + Powered by SUSHI v3.3.0 and GoFSH v2.0.1