From 8ec06f444d8f4559eda5c3dbf189e5183b1c5b42 Mon Sep 17 00:00:00 2001 From: Ben Christel Date: Wed, 27 Nov 2024 10:57:37 -0700 Subject: [PATCH] Inline version in expression widget parser (#1921) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The Expression widget imports the KAS parser, which contains generated code with some syntax that `@swc-node/register` (which we use to run TypeScript from the command line) can't parse. The parse error was preventing the exhaustive tests for the parsers (packages/perseus/src/util/parse-perseus-json/exhaustive-test-tool/index.ts) from running. Since we can't change the generated code, the solution is to avoid importing the version number from the Expression widget, and hardcode it instead. I think this is okay, because the migration function that used the version number is called `migrateV0ToV1`, so we actually want to hardcode version 1 rather than taking the current version from the widget. Issue: none ## Test plan: Run the exhaustive test tool according to the instructions in the file. Author: benchristel Reviewers: jeremywiebe Required Reviewers: Approved By: jeremywiebe Checks: ✅ Publish npm snapshot (ubuntu-latest, 20.x), ✅ Cypress (ubuntu-latest, 20.x), ✅ Check builds for changes in size (ubuntu-latest, 20.x), ✅ Lint, Typecheck, Format, and Test (ubuntu-latest, 20.x), ✅ Check for .changeset entries for all changed files (ubuntu-latest, 20.x), ✅ Publish Storybook to Chromatic (ubuntu-latest, 20.x), ✅ gerald Pull Request URL: https://github.com/Khan/perseus/pull/1921 --- .changeset/seven-owls-explain.md | 5 +++++ .../parse-perseus-json/perseus-parsers/expression-widget.ts | 3 +-- 2 files changed, 6 insertions(+), 2 deletions(-) create mode 100644 .changeset/seven-owls-explain.md diff --git a/.changeset/seven-owls-explain.md b/.changeset/seven-owls-explain.md new file mode 100644 index 0000000000..6e1d852646 --- /dev/null +++ b/.changeset/seven-owls-explain.md @@ -0,0 +1,5 @@ +--- +"@khanacademy/perseus": patch +--- + +Internal: Inline widget version into Expression widget parser. diff --git a/packages/perseus/src/util/parse-perseus-json/perseus-parsers/expression-widget.ts b/packages/perseus/src/util/parse-perseus-json/perseus-parsers/expression-widget.ts index 3d181092fe..9bff1a6a46 100644 --- a/packages/perseus/src/util/parse-perseus-json/perseus-parsers/expression-widget.ts +++ b/packages/perseus/src/util/parse-perseus-json/perseus-parsers/expression-widget.ts @@ -1,4 +1,3 @@ -import ExpressionWidgetModule from "../../../widgets/expression/expression"; import { array, boolean, @@ -93,7 +92,7 @@ function migrateV0ToV1( const {options} = widget; return ctx.success({ ...widget, - version: ExpressionWidgetModule.version, + version: {major: 1, minor: 0}, options: { times: options.times, buttonSets: options.buttonSets,