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

Cannot use Svix JS SDK in ESM mode #1554

Closed
danilofuchs opened this issue Dec 9, 2024 · 7 comments · Fixed by #1555
Closed

Cannot use Svix JS SDK in ESM mode #1554

danilofuchs opened this issue Dec 9, 2024 · 7 comments · Fixed by #1555
Assignees

Comments

@danilofuchs
Copy link

Bug Report

Version

1.43.0

Platform

Linux, Node 22.11.0 LTS

Description

After upgrading to Svix 1.43.0, I cannot import Webhook from svix:

Error [ERR_MODULE_NOT_FOUND]: Cannot find module '/home/danilo/salvy/salvy-api/node_modules/.pnpm/[email protected][email protected]/node_modules/svix/dist/esm/openapi/index' imported from /home/danilo/salvy/salvy-api/node_modules/.pnpm/[email protected][email protected]/node_modules/svix/dist/esm/index.js
import { Webhook } from "svix";
         ^^^^^^^
SyntaxError: Named export 'Webhook' not found. The requested module 'svix' 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 'svix';
const { Webhook } = pkg;

    at ModuleJob._instantiate (node:internal/modules/esm/module_job:177:[21](https://github.com/SalvyLTD/salvy-api/actions/runs/12238907040/job/34138088620#step:10:22))
    at async ModuleJob.run (node:internal/modules/esm/module_job:260:5)
    at async onImport.tracePromise.__proto__ (node:internal/modules/esm/loader:543:26)
    at async Promise.all (index 82)
    at async file:///home/runner/work/salvy-api/salvy-api/docs/src/generate-openapi.ts:11:29

My package.json contains type: "module"

@tasn
Copy link
Member

tasn commented Dec 9, 2024

@svix-jplatte, I thought we fixed it? Or am I misremembering?

@svix-jplatte
Copy link
Member

This seems like a new issue with 1.43.0, likely due to the fix for tree shaking we landed recently (#1549).

@svix-lucho
Copy link
Contributor

I may have missed something in #1549. Taking a look

@svix-jplatte
Copy link
Member

svix-jplatte commented Dec 9, 2024

@danilofuchs This should be fixed with the next release. If you want to test it now, there's a pre-release on npm: 1.43.1-next-0fd525eb2e2d585279f95079257594078c27335c.0

Unfortunately, fix seems to not have been sufficient.

@svix-jplatte svix-jplatte reopened this Dec 9, 2024
@svix-lucho svix-lucho self-assigned this Dec 9, 2024
@svix-lucho
Copy link
Contributor

Hey @danilofuchs, it seems the ESM upgrade still had a few issues that I am still investigating. In the meanwhile, we'll revert the behavior to the one we had before 1.43 (so, export as commonjs). I'll keep you updated

@abetoots
Copy link

hi, just a heads up that installing 1.43.1-next-0fd525eb2e2d585279f95079257594078c27335c.0 from the next release still doesn't fix the issue.

node:internal/modules/esm/resolve:265
    throw new ERR_MODULE_NOT_FOUND(
          ^

Error [ERR_MODULE_NOT_FOUND]: Cannot find module '/home/anon/websand-v4/node_modules/.pnpm/[email protected]/node_modules/svix/dist/esm/openapi/index' imported from /home/anon/websand-v4/node_modules/.pnpm/[email protected]/node_modules/svix/dist/esm/index.js
    at finalizeResolution (node:internal/modules/esm/resolve:265:11)
    at moduleResolve (node:internal/modules/esm/resolve:933:10)
    at defaultResolve (node:internal/modules/esm/resolve:1169:11)
    at ModuleLoader.defaultResolve (node:internal/modules/esm/loader:542:12)
    at ModuleLoader.resolve (node:internal/modules/esm/loader:510:25)
    at ModuleLoader.getModuleJob (node:internal/modules/esm/loader:239:38)
    at ModuleWrap.<anonymous> (node:internal/modules/esm/module_job:96:40)
    at link (node:internal/modules/esm/module_job:95:36) {
  code: 'ERR_MODULE_NOT_FOUND',
  url: 'file:///home/anon/websand-v4/node_modules/.pnpm/[email protected]/node_modules/svix/dist/esm/openapi/index'
}

@vhiz
Copy link

vhiz commented Dec 11, 2024

I used the the current version 1.43.1-next-6ec657d78fbee46ae3fac6616b1e4393ddd25fea.0 and it worked

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants