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

0.16.9 throws [ERROR] The symbol has already been declared for same name nested functions #2757

Closed
dominikg opened this issue Dec 19, 2022 · 4 comments

Comments

@dominikg
Copy link

dominikg commented Dec 19, 2022

export function a() {
  var b = 'b';
  var b = 'b';
  function c() {
    console.log('c');
  }
  function c() {
    console.log('c');
  }
  return c();
}

causes

✘ [ERROR] The symbol "c" has already been declared

    a.js:7:11:
      7 │   function c() {
        ╵            ^

  The symbol "c" was originally declared here:

    a.js:4:11:
      4 │   function c() {
        ╵            ^

  Duplicate lexically-declared names are not allowed in an ECMAScript module. This file is considered to be an ECMAScript module because of the "export" keyword here:

    a.js:1:0:
      1 │ export function a() {
        ╵ ~~~~~~

reproduction: https://stackblitz.com/edit/node-tl5iaw?file=a.js pnpm build

downgrading to 0.16.8 works.
running node index.js works.

the sample code is adapted from the 0.16.9 changelog example "// JavaScript allows this".

edit:
discovered via reports in @sveltejs/kit triggered by svelte generating duplicate code

@danielkita
Copy link

I have the same issue with axe-core and jspdf

@cnkbekir
Copy link

I add "devDependencies": { "esbuild": "0.16.8" } because of this problem.

@jsuryahyd
Copy link

This is happening to me in a react project, when I am using vite 4.0.2,

✘ [ERROR] The symbol "Vt" has already been declared

    node_modules/jspdf/dist/jspdf.es.min.js:236:40507:
      236 │ ...n,i),n[i+3]=255}function Vt(t,e){return 0>t?0:t>e?e:...
          ╵                             ~~

  The symbol "Vt" was originally declared here:

    node_modules/jspdf/dist/jspdf.es.min.js:236:18651:
      236 │ ...is.Ga=this.Vc=0}function Vt(t,e){return 0>t?0:t>e?e:...
          ╵                             ~~

  Duplicate lexically-declared names are not allowed in an ECMAScript
  module. This file is considered to be an ECMAScript module because
  of the "export" keyword here:

    node_modules/jspdf/dist/jspdf.es.min.js:331:35413:
      331 │ ...,e}();export default E;export{St as AcroForm,At as A...
          ╵                           ~~~~~~
/home/{user}/{project}/node_modules/esbuild/lib/main.js:1594
  let error = new Error(`${text}${summary}`);
              ^

Error: Build failed with 1 error:
node_modules/jspdf/dist/jspdf.es.min.js:236:40507: ERROR: The symbol "Vt" has already been declared
    at failureErrorWithLog (/home/jsurya/work/side/node_modules/esbuild/lib/main.js:1594:15)
    at /home/jsurya/work/side/node_modules/esbuild/lib/main.js:1050:28
    at runOnEndCallbacks (/home/jsurya/work/side/node_modules/esbuild/lib/main.js:1466:61)
    at buildResponseToResult (/home/jsurya/work/side/node_modules/esbuild/lib/main.js:1048:7)
    at /home/{user}/{project}/node_modules/esbuild/lib/main.js:1160:14
    at responseCallbacks.<computed> (/home/jsurya/work/side/node_modules/esbuild/lib/main.js:697:9)
    at handleIncomingPacket (/home/jsurya/work/side/node_modules/esbuild/lib/main.js:752:9)
    at Socket.readFromStdout (/home/jsurya/work/side/node_modules/esbuild/lib/main.js:673:7)
    at Socket.emit (node:events:390:28)
    at addChunk (node:internal/streams/readable:315:12)
    at readableAddChunk (node:internal/streams/readable:289:9)
    at Socket.Readable.push (node:internal/streams/readable:228:10)
    at Pipe.onStreamRead (node:internal/stream_base_commons:199:23) {
  errors: [
    {
      detail: undefined,
      id: '',
      location: {
        column: 40507,
        file: 'node_modules/jspdf/dist/jspdf.es.min.js',
        length: 2,
        line: 236,
        lineText: ' */function te(t,e){if(this.pos=0,this.buffer=t,this.datav=new DataView(t.buffer),this.is_with_alpha=!!e,this.bottom_up=!
        ....

@jsuryahyd
Copy link

jsuryahyd commented Dec 19, 2022

cnkbekir
I add "devDependencies": { "esbuild": "0.16.8" } because of this problem..

this fixes the issue

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

4 participants