Skip to content
This repository has been archived by the owner on Jul 14, 2023. It is now read-only.

incorrectly defaulting CJS code to strict mode #54

Open
achmadk opened this issue Jun 21, 2022 · 1 comment
Open

incorrectly defaulting CJS code to strict mode #54

achmadk opened this issue Jun 21, 2022 · 1 comment

Comments

@achmadk
Copy link

achmadk commented Jun 21, 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
     ╰────

I request to refactor fn variable/function definition, but I have a comment like this from its member:

browserify/node-util#75 (comment)

Maybe, is swc-loader (or @swc/core) has a problem incorrectly defaulting CJS code to strict mode?

@zuolung
Copy link

zuolung commented May 26, 2023

how to close strict mode, With statement are not allowed in strict mode

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Development

No branches or pull requests

2 participants