panva / hkdf

HKDF with no dependencies using runtime's native crypto in Node.js, Browser, Cloudflare Workers, Electron, and Deno.
MIT License
34 stars 2 forks source link

"createHmac" is not exported by "__vite-browser-external" #19

Closed Nefcanto closed 23 hours ago

Nefcanto commented 23 hours ago

What happened?

Hi

I'm using Vite + Qwik. I used @auth/core. After upgrading the Vite to version 6 and changing the @auth/core to @auth/qwik, I saw this error:

"createHmac" is not exported by "__vite-browser-external"

This is the complete stack:

x Build failed in 4.76s
error during build:
../../npm/node_modules/@panva/hkdf/dist/node/esm/runtime/fallback.js (1:9): "createHmac" is not exported by "__vite-browser-external", imported by "../../npm/node_modules/@panva/hkdf/dist/node/esm/runtime/fallback.js".
file: /npm/node_modules/@panva/hkdf/dist/node/esm/runtime/fallback.js:1:9

1: import { createHmac } from 'crypto';
            ^
2: export default (digest, ikm, salt, info, keylen) => {
3:     const hashlen = parseInt(digest.substr(3), 10) >> 3 || 20;

    at getRollupError (file:///npm/node_modules/rollup/dist/es/shared/parseAst.js:396:41)
    at error (file:///npm/node_modules/rollup/dist/es/shared/parseAst.js:392:42)
    at Module.error (file:///npm/node_modules/rollup/dist/es/shared/node-entry.js:15593:16)
    at Module.traceVariable (file:///npm/node_modules/rollup/dist/es/shared/node-entry.js:16042:29)
    at ModuleScope.findVariable (file:///npm/node_modules/rollup/dist/es/shared/node-entry.js:13825:39)
    at ReturnValueScope.findVariable (file:///npm/node_modules/rollup/dist/es/shared/node-entry.js:5288:38)
    at FunctionBodyScope.findVariable (file:///npm/node_modules/rollup/dist/es/shared/node-entry.js:5288:38)
    at Identifier.bind (file:///npm/node_modules/rollup/dist/es/shared/node-entry.js:5071:40)
    at CallExpression.bind (file:///npm/node_modules/rollup/dist/es/shared/node-entry.js:2658:23)
    at CallExpression.bind (file:///npm/node_modules/rollup/dist/es/shared/node-entry.js:11289:15)

❌ Error: Client build failed: Error: Command failed with exit code 1: npm run build.client

I searched for @panva/hkdf and found you.

Version

1.2.1

Runtime

Browser

Runtime Details

Vite 6, Qwik 1.11.0, @auth/qwik 0.2.2

Code to reproduce

1- `npm create qwik@latest`
2- Upgrade to Vite 6
3- `npm run qwik add auth`
4- `npm run build`

Required

panva commented 23 hours ago

You're attempting to rollup the package's node's target for the browser. I cannot help with bundling issues.

Nefcanto commented 23 hours ago

@panva, could you please help me by guiding me to the right repo for this issue? Where should I post this issue?

panva commented 23 hours ago

I don't know. kwik or @auth/*?

Nefcanto commented 23 hours ago

@panva, the problem is that it's unclear who's using your library. Thank you.

panva commented 22 hours ago

Your package lock manifest can tell you fairly clearly. It's @auth/core btw https://github.com/nextauthjs/next-auth/blob/2922e286ae7ffb7b8be42603bdb5fe2029504960/packages/core/package.json#L70