on click font loading.

Hey, I'm creating an app which should support themes. However I'm having a trouble loading fonts dynamically. Since there will be many fonts, I thought that I'd import fonts inside function (when choosing theme), like so:

const handleThemeChange = async (newThemeId: string) => {
    const newTheme = themes.find(({ id }) => id === newThemeId);

    if (!newTheme) {
      return;
    }

    await import(newTheme.source);
    setThemeId(newTheme.id)
  }

however it says it cannot find module. When I import them top level then it's fine.
What could be the culprit here?