awslabs / aws-jwt-verify

JS library for verifying JWTs signed by Amazon Cognito, and any OIDC-compatible IDP that signs JWTs with RS256, RS384, and RS512
Apache License 2.0
598 stars 43 forks source link

[BUG] Error when bundling with Vite: Rollup failed to resolve import "#node-web-compat" #114

Closed Fitzpasd closed 1 year ago

Fitzpasd commented 1 year ago

Describe the bug The below error is thrown when trying to use this in an application that is bundled with Vite:

[vite]: Rollup failed to resolve import "#node-web-compat" from .....

Versions 3.4.0

To Reproduce Here is a StackBlitz which shows the issue. Run npm run build in the console there and it will fail.

Fitzpasd commented 1 year ago

Closing since this workaround will likely work here as well.

hakanson commented 1 year ago

I was able to compile with this vite.config.ts (and after a npm install @rollup/plugin-node-resolve)

import { defineConfig } from 'vite';
import resolve from '@rollup/plugin-node-resolve';

// https://vitejs.dev/config/
export default defineConfig({
  plugins: [resolve({ browser: true })],
});

see https://stackblitz.com/edit/vitejs-vite-cpfuqa?file=vite.config.ts

Fitzpasd commented 1 year ago

I landed on something similar:

export default defineConfig({
  plugins: [resolve({ resolveOnly: ['aws-jwt-verify'] })],
});

For now I'm not going to switch everything over to node resolve.