Description
Is your feature request related to a problem? Please describe.
Deno is slowly gaining traction and we see some requests to support svelte development from deno. However it was decided that maintaining a "native" ESM release next to the nodejs one would be too much work for the svelte team in the current setup.
Describe the solution you'd like
I propose a minimal effort compromise to allow supporting ESM/ deno based workflows by officially referring to available bridge software (snowpack and/or unpkg.com) and just maintaining the minimally needed changes in the svelte codebase that are necessary to run in such a setup without manual patching.
Describe alternatives you've considered
#4807:
"[...] removing the snowpack [eg. be available for deno in the pika registry] requirement would be more work to get right [...] It would require either package.json to support multiple module entry points, which it currently does not, or for us to find a way to export the compiler into the main module entry point without making esm importing browsers to import the compiler when not needing it. [...]
How important is this feature to you?
It would be most important to new developers that try out svelte + deno and all run into the same issues. If we minimally support this and also add a few sentences of documentation we could save each of these developers work and possibly duplicate issues or support requests on discord.
Implementation Details
There are currently two possibilities to do this
a) by using snowpack
- add a compiler option to include a ".js" or ".mjs" file ending so the import in the esm compiled output will be
..} from "svelte/internal.(m)js";
(as the probing for file extensions and handling of index.js files is nodejs specific)
this could also be solved in a preprocessor step, but i think it is better to officially add the file ending when using the compiler with esm output - add a section to the svelte readme or the api docs or to the https://github.com/sveltejs/integrations repo how to use svelte with snowpack and deno, i would also create an example starter template and add my example deno/svelte build script
b) by using unpkg.com
this method is also compatible with a, the only downside is that it requires one more change to the svelte codebase compared to a) This additional change already has a PR here:
#4972
- changes from a
- add the compiler esm output to the nodejs package
- add documentation in the appropriate place how to use unpkg.com to import the esm compiler