shalomscott / eleventy-plugin-embed-svelte

An Eleventy plugin that makes embedding Svelte components in your static pages painfully easy.
https://shalomscott.github.io/eleventy-plugin-embed-svelte/
MIT License
40 stars 4 forks source link

Example non-functional on Windows #13

Open daemuth opened 2 years ago

daemuth commented 2 years ago

Issue description The standalone example is non-functional. Creating a build (with the workaround mentioned in #12) of the plugin, then running the example will result in a webpage that does not contain the interactive Svelte elements.

Steps to reproduce

  1. Clone the repository
  2. Install dependencies of main project
  3. Build the plugin (if appropriate, apply workaround in #12)
  4. Install dependencies in example folder
  5. Run npm run start in example folder
  6. Observe build displaying the following warnings: 'C:UsersdaemuthWorkeleventy-plugin-embed-svelteexamplesvelteGreeter.svelte' is imported by virtual:entry, but could not be resolved – treating it as an external dependency 'C:UsersdaemuthWorkeleventy-plugin-embed-svelteexamplesvelteCounter.svelte' is imported by virtual:entry, but could not be resolved – treating it as an external dependency No name was provided for external module 'C:UsersdaemuthWorkeleventy-plugin-embed-svelteexamplesvelteGreeter.svelte' in output.globals – guessing 'C_UsersdaemuthWorkeleventyPluginEmbedSvelteexamplesvelteGree ter_svelte' No name was provided for external module 'C:UsersdaemuthWorkeleventy-plugin-embed-svelteexamplesvelteCounter.svelte' in output.globals – guessing 'C_UsersdaemuthWorkeleventyPluginEmbedSvelteexamplesvelteCoun ter_svelte'
  7. Observe successful build
  8. Open hosted build in browser
  9. Observe webpage not containing any interactive Svelte elements
daemuth commented 2 years ago

Update: I have tried to run the example on WSL and it has worked without a hitch. This seems to be related to #12 in some way. I'm currently investigating why the resolution of the modules fails on Windows but not getting far yet.

daemuth commented 2 years ago

Temporary workaround: Inserting fileName = fileName.replaceAll("\\", "\\\\") after fileName = path.resolve(svelteDir, fileName) seems to solve this problem. I am not certain why.