import.meta.url for loading optional modules. Some bundlers may require additional configuration to handle this correctly.
Vite
If using Vite, add the following to yourvite.config.js:
vite.config.js
This tells Vite to skip pre-bundling GenosDB, allowing the dynamic imports to resolve correctly at runtime.
Webpack
No additional configuration is typically required for Webpack 5+. GenosDB’s dynamic imports work out of the box with modern Webpack configurations.If you encounter issues with older Webpack versions (< 5), consider upgrading or using a different bundler.
esbuild / Bun
Bun Example
When usingBun.build, no special configuration is needed:
bundler.ts
Rollup
Rollup handles dynamic imports natively. No special configuration needed:rollup.config.js
Parcel
Parcel 2+ supports dynamic imports out of the box. No configuration required:CDN Usage (No Bundler)
When loading GenosDB directly from a CDN, no bundler configuration is needed:Recommended for Quick Starts
Using the CDN is the fastest way to get started with GenosDB without any build setup.
Troubleshooting
Error: Cannot find module './genosrtc.min.js'
Error: Cannot find module './genosrtc.min.js'
Cause: Bundler is trying to statically resolve dynamic importsSolution: Configure bundler to exclude GenosDB from pre-bundling (see Vite example above)
Error: import.meta is not defined
Error: import.meta is not defined
Cause: Build target is not ESM or environment doesn’t support import.metaSolution: Ensure your bundler output format is
esm and target is modern browsersModules not loading at runtime
Modules not loading at runtime
Cause: Dynamic imports are being bundled but files aren’t copied to distSolution: Ensure GenosDB’s dist files are accessible in your output directory
Best Practices
- Use ESM output format for best compatibility
- Exclude GenosDB from pre-bundling if using aggressive optimization
- Test in production build to catch bundling issues early
- Use CDN for prototypes to avoid bundler complexity
For production applications, we recommend using a bundler with proper configuration to optimize bundle size and performance.