sveltejs / template-webpack

Template for building basic Svelte applications with webpack
300 stars 118 forks source link

Dealing with external svelte components #4

Closed kaisermann closed 3 years ago

kaisermann commented 6 years ago

Since we're excluding /node_modules/ from the svelte-loader, what's the best way to use external svelte components like svelte-routing?

Adding a negative lookahead to the exclusion rule kinda works, but can we assume that every svelte component/package will have the svelte prefix?

{
  test: /\.(html|svelte)$/,
  exclude: /node_modules\/(?!svelte)/,
  ...
}
Rich-Harris commented 6 years ago

I actually hit this earlier today. I just removed the exclude field altogether in the project I'm working on. The svelte- prefix assumption is probably reasonable, but I don't know if I'd consider it watertight.

antony commented 5 years ago

This just got me :)

Why exclude node_modules? We're entering a world now where there are a fair few third-party svelte components.

Perhaps there should be a recommendation that Svelte components generally use a .svelte suffix, since .html causes Svelte to break in Parcel bundler, too. Im assuming that Vue uses .vue so that there aren't headaches like this.

benmccann commented 3 years ago

Hopefully this is fixed now with https://github.com/sveltejs/template-webpack/pull/36