Giter Site home page Giter Site logo

ts-invariant 'cant resolve imported dependency process/browser' -- conflict with webpack 5 typical polyfill about invariant-packages HOT 8 OPEN

disarticulate avatar disarticulate commented on June 18, 2024 3
ts-invariant 'cant resolve imported dependency process/browser' -- conflict with webpack 5 typical polyfill

from invariant-packages.

Comments (8)

luckyrobot avatar luckyrobot commented on June 18, 2024 19

found solution, adding fullySpecified to false

/* config-overrides.js */
const webpack = require('webpack')

module.exports = function override(config) {
  const fallback = config.resolve.fallback || {}
  Object.assign(fallback, {
    util: require.resolve('util/'),
    crypto: require.resolve('crypto-browserify'),
    stream: require.resolve('stream-browserify'),
    buffer: require.resolve('buffer'),
    assert: require.resolve('assert'),
    http: require.resolve('stream-http'),
    https: require.resolve('https-browserify'),
    os: require.resolve('os-browserify'),
    url: require.resolve('url'),
  })
  config.plugins.push(
    new webpack.ProvidePlugin({
      Buffer: ['buffer', 'Buffer'],
      process: 'process/browser',
    }),
  )
  config.module.rules = [
    ...config.module.rules,
    {
      test: /\.m?js/,
      resolve: {
        fullySpecified: false,
      },
    },
  ]
  config.resolve.fallback = fallback
  config.ignoreWarnings = [/Failed to parse source map/]
  return config
}

from invariant-packages.

AumyF avatar AumyF commented on June 18, 2024 3

I avoided the problem by replacing process/browser with process: 'process/browser.js'

from invariant-packages.

luckyrobot avatar luckyrobot commented on June 18, 2024

same issue

Uniswap/web3-react#423

from invariant-packages.

disarticulate avatar disarticulate commented on June 18, 2024

@luckyrobot Thanks. This appears to work but it seems like such a monkey patch for this library.

from invariant-packages.

benjamn avatar benjamn commented on June 18, 2024

@disarticulate What version of ts-invariant are you using?

It seems like webpack is injecting an import for process/browser that does not exist in the ts-invariant code.

from invariant-packages.

disarticulate avatar disarticulate commented on June 18, 2024

looks like @apollo-client @ 3.6.2 installs ts-variant @ 0.10.2

@benjamn

from invariant-packages.

ravenflores avatar ravenflores commented on June 18, 2024

found solution, adding fullySpecified to false

/* config-overrides.js */
const webpack = require('webpack')

module.exports = function override(config) {
  const fallback = config.resolve.fallback || {}
  Object.assign(fallback, {
    util: require.resolve('util/'),
    crypto: require.resolve('crypto-browserify'),
    stream: require.resolve('stream-browserify'),
    buffer: require.resolve('buffer'),
    assert: require.resolve('assert'),
    http: require.resolve('stream-http'),
    https: require.resolve('https-browserify'),
    os: require.resolve('os-browserify'),
    url: require.resolve('url'),
  })
  config.plugins.push(
    new webpack.ProvidePlugin({
      Buffer: ['buffer', 'Buffer'],
      process: 'process/browser',
    }),
  )
  config.module.rules = [
    ...config.module.rules,
    {
      test: /\.m?js/,
      resolve: {
        fullySpecified: false,
      },
    },
  ]
  config.resolve.fallback = fallback
  config.ignoreWarnings = [/Failed to parse source map/]
  return config
}

thanks bro

from invariant-packages.

jheavejimenez avatar jheavejimenez commented on June 18, 2024

thanks bro

from invariant-packages.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.