Skip to content

JSR registry publish fails with "Unknown module" error for Svelte components #16166

@kotkoroid

Description

@kotkoroid

Describe the bug

When attempting to publish a Svelte component library to the JSR registry, the publish process fails with the error Expected a JavaScript or TypeScript module, but identified a Unknown module. Importing these types of modules is currently not supported.

The error appears to be caused by dist/index.js containing references to .svelte files, which JSR doesn't recognize as valid module types. Is the recommended solution to transpile all .svelte files to .js before publishing? Does the Svelte compiler support this?

Several Svelte libraries are already available on JSR, but the build process for component libraries isn't clear from any of the documentations.

Reproduction

https://github.com/kotkoroid/repl-svelte-library-jsr-publish

Logs

johndoe@Johns-MacBook-Air repl-svelte-library-jsr-publish % bunx jsr publish
Downloading JSR release binary...
[00:01] [#################################################>] 35.7 MiB/36.5 MiB
error: Expected a JavaScript or TypeScript module, but identified a Unknown module. Importing these types of modules is currently not supported.
  Specifier: file:///Users/johndoe/Workspace/Dev/repl-svelte-library-jsr-publish/dist/components/Heading.svelte
    at file:///Users/johndoe/Workspace/Dev/repl-svelte-library-jsr-publish/dist/index.js:1:36
Child process exited with: 1

System Info

System:
    OS: macOS 15.5
    CPU: (8) arm64 Apple M2
    Memory: 90.48 MB / 16.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 22.14.0 - ~/.nvm/versions/node/v22.14.0/bin/node
    Yarn: 1.22.22 - ~/.nvm/versions/node/v22.14.0/bin/yarn
    npm: 10.9.2 - ~/.nvm/versions/node/v22.14.0/bin/npm
    pnpm: 10.10.0 - ~/.nvm/versions/node/v22.14.0/bin/pnpm
    bun: 1.2.16 - ~/.bun/bin/bun
  Browsers:
    Safari: 18.5
  npmPackages:
    svelte: ^5.34.3 => 5.34.3

Severity

blocking all usage of svelte

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