Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HMR error in development server with sveltekit >=1.8.0 #700

Closed
aslakhellesoy opened this issue Feb 24, 2023 · 7 comments
Closed

HMR error in development server with sveltekit >=1.8.0 #700

aslakhellesoy opened this issue Feb 24, 2023 · 7 comments
Assignees
Labels
bug Something isn't working

Comments

@aslakhellesoy
Copy link

Hello - thanks for this library!

I took version 0.4.3 (a year old) for a spin, but it doesn't work with the latest sveltekit.

Would you be able to publish a new release to npm? It looks like a lot of changes were made in the past year.

Many thanks,
Aslak Hellesøy

@sfriedel sfriedel self-assigned this Feb 24, 2023
@sfriedel
Copy link
Collaborator

@aslakhellesoy I'm curious what exactly is broken, can you elaborate a bit please? I'm not aware of any incompatibilities with the latest sveltekit. Just earlier this week I set up a new project using svelte-fluent@0.4.3 and latest sveltekit and everything worked fine.

I was planning to release a new version this week but while there were some changes lately, they were mostly related to the new documentation site and build process and should not have any impact on sveltekit compatibility so I wouldn't expect it to fix any issues that you might be seeing.

@aslakhellesoy
Copy link
Author

Hi @sfriedel.

A couple of things seem to be wrong.

  1. TypeScript definitions (*.d.ts) are included in the npm module, but package.json uses the wrong path. Therefore the types cannot be found:
npm run check

> svelte-fluent-test@0.0.1 check
> svelte-kit sync && svelte-check --tsconfig ./tsconfig.json


====================================
Loading svelte-check in workspace: /Users/aslakhellesoy/git/aslakhellesoy/svelte-fluent-test
Getting Svelte diagnostics...

/Users/aslakhellesoy/git/aslakhellesoy/svelte-fluent-test/vite.config.ts:3:26
Error: Cannot find module '@nubolab-ffwd/svelte-fluent/rollup-plugin' or its corresponding type declarations.
import { defineConfig } from 'vite';
import svelteFluent from '@nubolab-ffwd/svelte-fluent/rollup-plugin';



/Users/aslakhellesoy/git/aslakhellesoy/svelte-fluent-test/src/routes/+page.svelte:3:44
Error: Cannot find module '@nubolab-ffwd/svelte-fluent' or its corresponding type declarations. (js)
	import { FluentBundle, FluentResource } from '@fluent/bundle';
	import { FluentProvider, Localized } from '@nubolab-ffwd/svelte-fluent';



====================================
svelte-check found 2 errors and 0 warnings

And VSCode:

Screenshot 2023-02-24 at 10 19 40

  1. Despite the TypeScript problems, I am able to start the app and load the page. However, there are errors in the browser console:
Uncaught (in promise) TypeError: parent_component is undefined
    init index.mjs:307
    FluentProvider index.mjs:691
    create_fragment +page.svelte:68
    init index.mjs:2031
    Page +page.svelte:150
    createProxiedComponent svelte-hooks.js:341
    ProxyComponent proxy.js:242
    Proxy<+page> proxy.js:349
    construct_svelte_component_dev index.mjs:2232
    create_default_slot root.svelte:252
    create_slot index.mjs:71
    create_fragment layout.svelte:21
    init index.mjs:2031
    Layout layout.svelte:97
    createProxiedComponent svelte-hooks.js:341
    ProxyComponent proxy.js:242
    Proxy<Layout> proxy.js:349
    construct_svelte_component_dev index.mjs:2232
    create_if_block_2 root.svelte:154
    create_fragment root.svelte:449
    init index.mjs:2031
    Root root.svelte:688
    createProxiedComponent svelte-hooks.js:341
    ProxyComponent proxy.js:242

Screenshot 2023-02-24 at 10 22 24

Here is my repo: https://github.com/aslakhellesoy/svelte-fluent-test
The commit where I added svelte-fluent: aslakhellesoy/svelte-fluent-test@1a92a5b

Perhaps I am doing something wrong? I believe I followed the installation instructions to the letter.

Many thanks

@sfriedel
Copy link
Collaborator

@aslakhellesoy the typescript error is expected because in svelte-fluent@0.4.3 the lib didn't use typescript yet. This will actually change in the next release.

I haven't seen this error before in any project. I'll have to investigate what's going on.

@aslakhellesoy
Copy link
Author

Thanks @sfriedel - much appreciated. Let me know if I can help in any way.

@sfriedel
Copy link
Collaborator

@aslakhellesoy I've managed to reproduce the issue and I'm still searching for the cause. I found out that the error was introduced with @sveltejs/kit@1.8.0 and also only seems to affect the development server.

I'm still looking for the root cause but may have to open an issue in sveltekit. If you want to use svelte-fluent in the meantime, you need to downgrade to @sveltejs/kit@1.7.2

@sfriedel
Copy link
Collaborator

@aslakhellesoy I'm done with the investigation for now. It appears that due to the changes in sveltejs/kit#8957 somehow sveltekit picked up the pre-compiled CJS/UMD components and not the svelte source files in the published version of the library.

Since the new version of the library does not include those pre-compiled components any more since it's now based on @sveltejs/package I just released version 0.5.0. In my reproduction repo the error does not appear any more with the new version. Please give it a try and let me know if the new version solves the error for you too.

@sfriedel sfriedel added the bug Something isn't working label Feb 24, 2023
@sfriedel sfriedel changed the title New release? HMR error in development server with sveltekit >=1.8.0 Feb 24, 2023
@sfriedel
Copy link
Collaborator

sfriedel commented Mar 6, 2023

Closing this issue since I can't reproduce it any more. Please open a new issue should any problems persist

@sfriedel sfriedel closed this as completed Mar 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants