Closed Gotterbild closed 5 years ago
To help investigating the issue, I've created a boilerplate of my project: https://github.com/Gotterbild/svelte-webpack-handlebars-koa-template
To run it, you need to:
.env
file from .env_exmaple
docker-compose up
(requires docker
and docker-compose
)localhost:3000
/assets/app/home-page.js
has few lines commented. Comment them out to see error.document.querySelector('DiagramsFilter')
should be document.querySelector('#DiagramsFilter')
(or getElementById)
It seems that, like us, you use webpack3 (I saw ExtractTextPlugin
). Your error message looks like ours, too.
So your issue is maybe related to ours : #89
What is the version of webpack you use ?
@creaven Yes, there was error in querySelector
, but that wasn't the case. I've fixed it, but initial error stays the same. Looks like it breaks before reaching to the line with querySelector
.
@0gust1 I've checked my webpack version and it is 2.7.0
. So, the issue is not with webpack 3 in my case. However, your error looks somewhat similar (Unrecognized option 'N'
), so maybe it is related.
Yes, we use ExtractTextPlugin
, but I can't see any console errors related to it. It looks like working properly:
But I'm not sure. Maybe some webpack plugin is the source of error. Can you post your webpack config, so we can compare plugins we're using and configuration options? I understand webpack 3 is a bit different, but who knows.
@Gotterbild Yes, I think so. I made some analysis/debug of the code yesterday (more details below). I even have a pull request in progress. It could help a lot if you could test it on your side ! 😄
In your project, could you replace temporarily the content of node_modules/svelte-loader/index.js
by this code : https://github.com/0gust1/svelte-loader/blob/fix/webpack3_and_svelte3/index.js and try building again ?
Explanation :
btw, I talked about ExtractTextPlugin
, but it's unrelated to the bug, that's just the way I saw you were not using webpack4.
It's also not a problem in webpack configuration file by itself, but more a nasty bug related to the differences in webpack internal loader engine between webpack <4 and 4
@0gust1 It was a bit hacky as my setup is inside a docker container and node modules are cached, but I've managed to replace content of svelte-loader/index.js
with yours. Webpack builds succesfully after. Looks like you're located the issue correctly. I didn't test if Svelte works as I have no time for it right now, but at a glance looks like your change fixes the issue.
@0gust1 I've found a second to test if Svelte works as expected with your changes in place and it works like charm.
@Gotterbild the PR was merged ! tell us if it does the job. Thanks for your help and your time.
@0gust1 Sorry, but it seems that GitHub didn't send me a notification about your message. But I did receive notification that this issue was closed so here I am.
Two months have passed and we upgraded webpack to v4, so I can't test it with actual code. Also, I'm a bit busy to blow off the dust from older release versions of our project. And worth mention that we decided to use Vue in place of Svelte for several reasons. Anyway, it worked two months ago when I tested it, so why wouldn't it work now?
To sum up everything listed, I won't test it. Sorry :)
I'm considering using Svelte 3 as a replacement to JQuery. As an example for myself how that could work, I am trying to implement simple filter (text input that filters elements by name). I want to plant this filter deep inside existing HTML layout (actually, Handlebars layout).
Here's my webpack config:
My component file is called
diagrams-filter.svelte
and looks as dumb as it could be:I import this component like this:
And in my Handlebars template I have an element with
DiagramsFilter
id:What am I doing wrong? Or maybe I'm trying to do something that is not possible? Or maybe I'm trying to do something that is just not yet supported? Or it is just a bug?
Any advice will be appreciated. Thank you.