Does not work with Vite/Sveltekit
See original GitHub issueError only occurs when running npm run build
:
> Using @sveltejs/adapter-netlify
> Named export 'Webhooks' not found. The requested module '@mux/mux-node' is a CommonJS module, which may not support all module.exports as named exports.
CommonJS modules can always be imported via the default export, for example using:
import pkg from '@mux/mux-node';
const { Webhooks } = pkg;
file:///Users/ben/dev/mux-node-esm-issue/.svelte-kit/output/server/app.js:4
import { Webhooks } from "@mux/mux-node";
^^^^^^^^
SyntaxError: Named export 'Webhooks' not found. The requested module '@mux/mux-node' is a CommonJS module, which may not support all module.exports as named exports.
CommonJS modules can always be imported via the default export, for example using:
import pkg from '@mux/mux-node';
const { Webhooks } = pkg;
at ModuleJob._instantiate (internal/modules/esm/module_job.js:97:21)
at async ModuleJob.run (internal/modules/esm/module_job.js:142:20)
at async Loader.import (internal/modules/esm/loader.js:182:24)
at async prerender (file:///Users/ben/dev/mux-node-esm-issue/node_modules/@sveltejs/kit/dist/chunks/index6.js:80:14)
at async Object.prerender (file:///Users/ben/dev/mux-node-esm-issue/node_modules/@sveltejs/kit/dist/chunks/index6.js:312:5)
at async adapt (file:///Users/ben/dev/mux-node-esm-issue/node_modules/@sveltejs/adapter-netlify/index.js:34:4)
at async adapt (file:///Users/ben/dev/mux-node-esm-issue/node_modules/@sveltejs/kit/dist/chunks/index6.js:338:2)
at async file:///Users/ben/dev/mux-node-esm-issue/node_modules/@sveltejs/kit/dist/cli.js:887:5
adapter-netlify
/ SvelteKit are not recognising @mux/mux-node
as an ESM package. This could be due to "type": "module"
not being present in the package.json
. Could also be that "main": "src/index.js"
needs to be replaced with "exports": "src/index.js"
EDIT: Repro repo: https://github.com/benwoodward/mux-node-esm-issue (Run npm run build
to see the error`)
Issue Analytics
- State:
- Created 2 years ago
- Comments:9
Top Results From Across the Web
Svelte-Kit Dev Is No Longer Available Use Vite Dev Instead
API Layer: https://apilayer.com/?utm_source=LevelUpTutorials&utm_medium=LeadsAcquisition&utm_content=july22Github PR ...
Read more >FAQ • SvelteKit
Most issues related to including a library are due to incorrect packaging. Libraries work best with Vite when they distribute an ESM version...
Read more >Bring @sveltejs/kit/experimental/vite out of experimental #5184
Describe the problem Right now SvelteKit asks users to pass Vite configuration via the kit.vite option in svelte.config.js.
Read more >svelte - Vite+SvelteKit Build Failing - Stack Overflow
I'm building a website using SvelteKit , scaffolded using pnpm create svelte . However, when I run pnpm build , I get the...
Read more >Working Sveltekit App w/vite deployed to node server? - Reddit
Can anyone point me to a repo with recent version of Sveltekit that is ... so it's just the client side of Sveltekit...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@benwoodward ah yeah, you’re totally right 😄
Webhooks
is a static attribute on theMux
constructor whereasVideo
andData
are on the instance. Thanks for clarifying and posting the code sample!Actually found that the
const { Webhooks } = new Mux();
throws an error:Throws
Cannot read property 'verifyHeader' of undefined
Works:
Second example ↑ is what’s in the README.
Aha, ok thanks 🙂
Oh, thanks for pointing this out, this code was written with a lot of haste. Yes, looks like
rawBody
is accessible in Sveltekit endpoint request objects.Here’s the updated code for my Mux webhook in Sveltekit + Dgraph (in case anyone’s googling this!)