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 build/deploy an application using @app-config/main on vercel #229

Open
stevejpurves opened this issue Nov 20, 2024 · 1 comment
Open

Comments

@stevejpurves
Copy link

Hi There!

I've been migrating my application to use @app-config/main and have everthing working locally / in development but I hit problems when attempting to deploy to vercel. The specific error I am seeing is:

Cannot find module 'asn1.js'
Require stack:
- /var/task/node_modules/openpgp/dist/openpgp.js
- /var/task/node_modules/@app-config/encryption/dist/encryption.js
- /var/task/node_modules/@app-config/encryption/dist/index.js
- /var/task/node_modules/@app-config/main/dist/index.js
Did you forget to add it to "dependencies" in `package.json`?

I'm having a hard time tracking this down but wonder if it's a known/familiar issue when bundling for serverless (my application is remix.run built with vite)?

Alternatively, I am using @app-config but I'm not using encryption for secrets, in that case is it possible to exclude the @app-config/encryption package by say using @app-config/config directly? are potentially mitigating this issue?

@stevejpurves
Copy link
Author

I've managed to work around this as follows, totally open to suggestions on a better way though, especially to avoid the hard type assignment.

// app-config.server.ts
import { loadValidatedConfig } from '@app-config/config';
import type { Config } from 'app-config';

let config: Awaited<ReturnType<typeof loadValidatedConfig>> | null = null;

export async function getConfig(): Promise<Config> {
  if (!config) {
    config = await loadValidatedConfig();
  }

  return config.fullConfig as unknown as Config;
}
// app-config.meta.yml
generate:
  - { file: '@types/app-config/index.d.ts', augmentModule: false }

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

No branches or pull requests

1 participant