I believe this error is related to the new frontend-base schema for apps. The code provided in the issues works for “legacy” MFEs, but not for the new apps. If I don’t add our script to ‘all’, but only to the list of MFEs that exclude notifications and instructor-dashboard, then the MFE image builds fine.
Therefore, it fails building the notifications (and probably the instructor dashboard) which enable frontend-base by default.
Would there be a corrected code for frontend-base MFEs ?
Just so we’re on the same page: did you follow the relevant instructions in the tutor-mfe README?
I don’t mean to imply you’re doing anything wrong, by the way. It’s entirely possible the documentation is incomplete, or that the code itself has a bug.
As I look at what the sample Google Analytics tutor plugin does, it seems the tutor-mfe README is indeed incomplete. It’s missing the frontend-base bit:
Can you check if it works for you if you add that?
Or rather, the information is there, but I figure the placement could be improved. The frontend-base bits are in the last paragraph, with no examples to shore it up:
To register a loader on the frontend-base site, use the mfe-site-custom-app-definitions and mfe-site-custom-app-imports patches in place of their mfe-env-config-buildtime-* equivalents, and target “site” (or “all”) in EXTERNAL_SCRIPTS. The loader’s constructor({ config }) receives the customApp runtime configuration, which you can populate via the site config (for example, through commonAppConfig) or the runtimeConfigJsonUrl endpoint.
So, I have only managed to make this work by defining both a JSX and a TSX (thanks Antigravity for translating the code), and adding the JSX version to MFEs, and the TSX version to apps.
Indeed, it did. Good find! Both GA plugin and sample code were developed before the full frontend-base implementation landed, so neither were properly tested with it.
The GA plugin was fixed here, and the tutor-mfe README, here.
The root cause, as you figured out, is that the Typescript compiler is configured to be stricter in *.ts files. This is generally a good thing, as it usually results in safer, cleaner code. It’s also perfectly possible to write plain javascript that passes these checks and also works in *.js files. Check the diff in the GA plugin fix, for instance.
Your solution is perfectly fine, but there’s probably no need to have two sets of snippets. You just have to write an equivalent piece of plain javascript that passes the stricter checks.