Skip to content

Dev Server - TypeScript: The requested module X does not provide an export Y on hot reload #1759

@elliott-with-the-longest-name-on-github

Description

Describe the bug
For some reason, one particular type based on SvelteComponentTyped seems to be being type-erasured incorrectly in the dev server on hot reloads. This is way easier to see than to explain, so just follow the repro steps below (I was able to get two people reproducing it in the Discord pretty quickly).

To Reproduce

  1. Clone my repository.
  2. Check out the this-does-not-work branch.
  3. Run the dev server (yarn dev)
  4. Make any change to routes/index.svelte that triggers a hot reload.
  5. Profit by seeing the error: SyntaxError: The requested module '/src/lib/Notifications/types.ts' does not provide an export named 'CustomNotificationComponent'

You can also diff the this-works branch with the this-does-not-work branch to see the workaround that, for some super weird reason, makes everything work fine.

Expected behavior
No 500 error :)

System: OS: Linux 5.8 Pop!_OS 20.04 LTS CPU: (12) x64 AMD Ryzen 5 5600X 6-Core Processor Memory: 12.36 GB / 31.37 GB Container: Yes Shell: 5.0.17 - /bin/bash Binaries: Node: 14.16.1 - ~/.nvm/versions/node/v14.16.1/bin/node Yarn: 1.22.10 - ~/.nvm/versions/node/v14.16.1/bin/yarn npm: 7.15.0 - ~/.nvm/versions/node/v14.16.1/bin/npm Browsers: Chromium: 83.0.4103.116 Firefox: 89.0.1 npmPackages: @sveltejs/adapter-node: next => 1.0.0-next.27 @sveltejs/kit: next => 1.0.0-next.116 svelte: ^3.34.0 => 3.38.3

Severity
Major annoyance because I can't export my types from one file :)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions