11ty / eleventy-plugin-vite

A plugin to use Vite with Eleventy
134 stars 10 forks source link

Error resolving node_modules dependencies in serve mode #16

Closed flortsch closed 1 year ago

flortsch commented 1 year ago

I am currently trying out this plugin and hope I can use it as future replacement of my current setup with Parcel.

Building my project with eleventy-plugin-vite works fine - all scripts, styles and other assets are bundled correctly. But when running in dev / serve mode, I get an error in the browser stating that it can't resolve node_modules dependencies.

E.g., I import Alpine.js in my main script with:

import Alpine from "alpinejs";

In my base layout, I include my main script like this:

<script type="module" src="/js/index.js"></script>

In my Eleventy config, I do a passthrough-copy of the script:

...
eleventyConfig.addPassthroughCopy("src/www/js");
...

return {
  dir: {
    input: "src/www",
    output: "_site",
  },
};

And I get this error:

Error resolving module specifier “alpinejs”. Relative module specifiers must start with “./”, “../” or “/”.

Any hints / suggestions? Do you face similar issues?

Cheers, Florian

KiwiKilian commented 1 year ago

Experiencing the same with @11ty/eleventy@2.0.0-canary.15 and @11ty/eleventy-plugin-vite@2.0.0-canary.2. Might be connected with #9. Reverting to the old behavior as documented fixes it for now:

eleventyConfig.setServerPassthroughCopyBehavior("copy");
zachleat commented 1 year ago

The fix here shipped with 2.0.0-canary.3 and will ship with 2.0.0 stable shortly!