bitcoinjs / bip39

JavaScript implementation of Bitcoin BIP39: Mnemonic code for generating deterministic keys
ISC License
1.11k stars 447 forks source link

Webpack Ignore Plugin not working? #130

Closed YanDevDe closed 3 years ago

YanDevDe commented 4 years ago

Hello everyone,

I tried the following method:

new webpack.IgnorePlugin(/^\.\/wordlists\/(?!english)/, /bip39\/src$/)

But for some reason this is not working and I'm still able to get wordlist from other languages. I also tried the old method back in times from #118 which is obviously not working too.

Ignoring other package is working fine at my side, as example for "moment"

new webpack.IgnorePlugin(/^\.\/locale$/, /moment$/)

Was wondering if you could reproduce the issue too?

I'm using Webpack 4.41.5

junderw commented 4 years ago

Could you try with an old version of webpack?

Maybe look on their repo to see which version was latests when I merged that PR. Try that version, and if it works, then try asking webpack devs.

DougAnderson444 commented 4 years ago

According to the webpack website, perhaps it needs to be this instead?

new webpack.IgnorePlugin({
        resourceRegExp: /^\.\/(?!english)/, 
        contextRegExp: /bip39\/src\/wordlists$/
    })
jonathansampson commented 4 years ago

I ran into this issue today, and decided to log the arguments passed to checkResource (some results excluded):

[Arguments] {
  '0': './_wordlists',
  '1': 'D:\\...\\node_modules\\bip39\\src'
}
[Arguments] {
  '0': './wordlists/chinese_simplified.json',
  '1': 'D:\\...\\node_modules\\bip39\\src'
}
[Arguments] {
  '0': './wordlists/english.json',
  '1': 'D:\\...\\node_modules\\bip39\\src'
}

What I didn't expect was to see the wordlists substring in the first argument, rather than the second. As such, I was able to apply the following change to the config file to exclude non-English lists:

module.exports = {
    plugins: [
        new webpack.IgnorePlugin(/^\.\/wordlists\/(?!english)/)
    ]
}
pundoo commented 4 years ago

If you're on Windows, you should use backslash (\) for the context :

new webpack.IgnorePlugin(/^\.\/wordlists\/(?!english)/, /bip39\\src$/)                               ^