Skip to content

docs: Update migration howto with jest @src alias#182

Open
arbrandes wants to merge 1 commit intoopenedx:mainfrom
arbrandes:update-migration-howto
Open

docs: Update migration howto with jest @src alias#182
arbrandes wants to merge 1 commit intoopenedx:mainfrom
arbrandes:update-migration-howto

Conversation

@arbrandes
Copy link
Contributor

@arbrandes arbrandes commented Mar 5, 2026

The migration howto was missing the @src alias in jest configuration, since it's no longer provided by the default in frontend-base.

The site.config.test.tsx circular import fix was also included.

Copy link
Contributor

@brian-smith-tcril brian-smith-tcril left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a way to have a single source of truth for asset file types? It looks like we used to just have a big list in moduleNameMapper, but now we need to call out file types in the build target too.

I don't think this is something frontend-base should maintain, each app can specify what file types are used in its assets, but needing to update that list in 2 places feels less than ideal.

tsc-alias -p tsconfig.build.json
```

Note that if you import assets such as SVG files using aliases, you have to call `tsc-alias` after the assets are copied to `dist/`. Otherwise, it won't find them and omit them from the relative path conversion.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Might be good to mention the build target in the example makefile is doing this for png and svg. That should make it clearer that this note is saying "if you have asset files using types that aren't covered by the example build target, you can update the build target to include those types"

@arbrandes arbrandes force-pushed the update-migration-howto branch from 7205845 to 09936f4 Compare March 13, 2026 20:45
The migration howto was missing the @src alias in jest configuration,
since it's no longer provided by the default in frontend-base.

Add the finding that `tsc-alias` needs to be called after assets are
copied.

Finally, document the fix to the site.config.test.tsx circular dependency
when mocking `@openedx/frontend-base` itself.
@arbrandes arbrandes force-pushed the update-migration-howto branch from 09936f4 to 5753c56 Compare March 13, 2026 20:56
@arbrandes
Copy link
Contributor Author

@brian-smith-tcril,

Is there a way to have a single source of truth for asset file types?

I think it's just happenstance that the particular assets we want to copy over to dist are also ones that require a jestism to mock out. Another way to put it is: would you trust having the Makefile parse jest.config.js and then copy assets based on that?

I couldn't agree more with the following, though:

needing to update that list in 2 places feels less than ideal

How about we just assume what sane app authors would want to do anyway, which is to put all assets under a predictable directory name? That way the jestism remains a jestism (no way around that), but they don't have to worry about the Makefile. See changes in the latest commit.

Copy link
Contributor

@holaontiveros holaontiveros left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Haven't seen how the fail with the circular dependency works, and the solution is perfect but maybe it should be somewhere else apart from the doc so it's easily recognizable for anyone that it shouldn't like that in there.

Also maybe we need to change it in here? ->

environment: EnvironmentTypes.TEST,

@arbrandes
Copy link
Contributor Author

@holaontiveros, I don't think it's needed in the shell because the shell can't mock the entire @openedx/frontend-base for testing, like consumers can. (That type of mocking is why the workaround is needed for tests.)

@holaontiveros
Copy link
Contributor

That makes sense, but then wouldn't that confuse someone that only sees that one and tries to use it as a refernce?

@arbrandes
Copy link
Contributor Author

wouldn't that confuse someone that only sees that one and tries to use it as a refernce?

They should be using frontend-template-app@frontend-base for reference... Once we update it. :)

For now, the migration howto is the reference.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants