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

feat(webpack): add fallback for optional wallet dependencies #307

Merged
merged 1 commit into from
Oct 25, 2024

Conversation

drichar
Copy link
Collaborator

@drichar drichar commented Oct 25, 2024

Description

This PR introduces a webpackFallback object to handle optional wallet dependencies in Next.js applications using @txnlab/use-wallet. This allows applications to build without these packages installed, enabling users to include only the wallet packages they need.

Usage

// next.config.mjs

import { webpackFallback } from '@txnlab/use-wallet-react'

/** @type {import('next').NextConfig} */
const nextConfig = {
  /* config options here */
  webpack: (config, { isServer }) => {
    if (!isServer) {
      config.resolve.fallback = {
        ...config.resolve.fallback,
        ...webpackFallback
      }
    }
    return config
  }
}
 
export default nextConfig

Details

  • Add webpackFallback object in src/webpack.ts
  • Export webpackFallback from the main src/index.ts file
  • Update Next.js example app to use the new webpackFallback

This change simplifies the configuration process for Next.js applications and ensures that the fallback configuration is maintained within the @txnlab/use-wallet library, making it easier to keep up-to-date as new optional dependencies are added.

- Add `webpackFallback` object
- Export `webpackFallback` from index.ts
- Update Next.js example app
@drichar drichar merged commit 32baa7f into main Oct 25, 2024
1 check passed
@drichar drichar deleted the feat/nextjs-webpack-fallback branch October 25, 2024 03:41
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 this pull request may close these issues.

1 participant