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

the name fn is defined multiple times when using swc-loader #75

Closed
achmadk opened this issue Jun 20, 2022 · 1 comment
Closed

the name fn is defined multiple times when using swc-loader #75

achmadk opened this issue Jun 20, 2022 · 1 comment

Comments

@achmadk
Copy link

achmadk commented Jun 20, 2022

I have an ejected CRA with a custom webpack loader. I use swc-loader instead of babel-loader for faster compile time. Actually, I add @walletconnect/web3-provider into my app. I got an error to include { util: require.resolve('util/') } into resolve.fallback webpack configuration. After that error was fixed, I got the error again like this

ERROR in ./node_modules/util/util.js
Module build failed (from ./node_modules/swc-loader/src/index.js):
Error: 
  × the name `fn` is defined multiple times
     ╭─[/media/data/SIDE_PROJECTS/webpack-react-ts-inversify-web-worker/node_modules/util/util.js:617:5]
 617 │ var fn = original[kCustomPromisifiedSymbol];
     ·     ─┬
     ·      ╰── previous definition of `fn` here
 618 │     if (typeof fn !== 'function') {
 619 │       throw new TypeError('The "util.promisify.custom" argument must be of type Function');
 620 │     }
 621 │     Object.defineProperty(fn, kCustomPromisifiedSymbol, {
 622 │       value: fn, enumerable: false, writable: false, configurable: true
 623 │     });
 624 │     return fn;
 625 │   }
 626 │ 
 627 │   function fn() {
     ·            ─┬
     ·             ╰── `fn` redefined here
     ╰────

could you please refactor the variable/function declaration name in order to solve my problem?

var fn = original[kCustomPromisifiedSymbol];

function fn() {

@ljharb
Copy link
Member

ljharb commented Jun 21, 2022

No, this is valid sloppy mode code - swc must have a bug (perhaps, incorrectly defaulting CJS code to strict mode).

Browserify has no bug here.

@ljharb ljharb closed this as not planned Won't fix, can't repro, duplicate, stale Jun 21, 2022
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

2 participants