importing from the runtime

I see this in the template-svelte-esm example:
import { ApplicationShell } from '#runtime/svelte/component/core';
import { ApplicationShell } from '#runtime/svelte/component/core';
I'm not familiar with this syntax – i.e. the # here in the path. What does it mean and what enables it? I looked in vite.config.js and the # symbol doesn't appear in that file. I also couldn't find anything about that being standard sugar for ESM6 syntax.
2 Replies
Vauxs
Vauxs7mo ago
see package.json
TyphonJS (Michael)
It's a feature of Node to remap an external package. This makes it easier than always having to write out @typhonjs-fvtt/runtime/<XXX> in ESM imports. It also makes the API documentation clearer / more concise particularly because there will be multiple versions of TRL in the future without Foundry support, but a large swath of the library / framework variations will have the same package paths. Components like those in the standard library can be written in a manner where they can be distributed for any version of TRL with the package remapping, etc. One downside is that IDE support may vary. Things are better in general w/ WebStorm recently for auto-imports. I'm not so sure about VSCode. For auto-imports on WebStorm you still need to replace the @typhonjs-fvtt/runtime w/ #runtime. Perhaps in the future IDEs will be smart enough to do this automatically. For end developers using TRL you can continue to use @typhonjs-fvtt/runtime/<XXX>. The #runtime remap is a convenience mechanism.
Want results from more Discord servers?
Add your server