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

Deno.bundle() generates (calls) function name that is not defined #9055

Closed
greenya opened this issue Jan 8, 2021 · 4 comments · Fixed by #9085
Closed

Deno.bundle() generates (calls) function name that is not defined #9055

greenya opened this issue Jan 8, 2021 · 4 comments · Fixed by #9085
Labels
bug Something isn't working correctly swc related to swc (bundling/transpiling)

Comments

@greenya
Copy link

greenya commented Jan 8, 2021

Hello!

I have a small module, which has a function named "int". The function is exported and is used in other modules. Deno runs code as expected. But for some reason, Deno.bundle() doesn't generate correct Javascript. In browser I'm getting Uncaught ReferenceError: __int is not defined.

I dont know when this issue started to happen (what exact Deno version, but i can say that in 1.5.6 it was ok, and now, in 1.6.3, it is not ok). So the issue is:

  • [OK] int -- is a name of the function
  • [NOT OK] __int is a name that is used to call the function in this module (for some reason it adds double underscores, and this call is not valid ofcause -- no function with this name)
  • [OK] __default1.int -- is a name how it is called from other modules (this is correct reference, it has correct definition const __default1 = { int, ... };)

I have attached image that shows the comparison of what is generated.
image

P.S.: Thank you for your support and work on such awesome project <3

@greenya
Copy link
Author

greenya commented Jan 8, 2021

One more place (detail).

This part is generated incorrectly too. Here this is no call to any int() fucntion, its a property from the object above. Instead of __int it should be int1 (in older version generated correctly).
image

@lucacasonato
Copy link
Member

cc @kdy1

@lucacasonato lucacasonato added bug Something isn't working correctly swc related to swc (bundling/transpiling) labels Jan 9, 2021
@greenya
Copy link
Author

greenya commented Jan 20, 2021

Hello!
This issue not fixed. Checking in 1.7.0, it is fixed partially, but property destructure is broken.
Here is a small example that reproduce the bug; maybe add this as a test case for future, so its known if it passes it.

const x = {
    n: 123,
    t: 'text',
    int: '==INT=='
}

const { n, t, int } = x

console.log(n, t, int)

// "deno run x.ts" output (correct):
// 123 text ==INT==

// "deno bundle x.ts" output (incorrect):
// const x = {
//     n: 123,
//     t: 'text',
//     int: '==INT=='
// };
// const { n , t , __int  } = x;
// console.log(n, t, __int);

// __int is undefined :(

Thank you for your hard work <3

@bartlomieju bartlomieju reopened this Jan 20, 2021
kdy1 added a commit to kdy1/swc that referenced this issue Jan 21, 2021
kdy1 added a commit to kdy1/swc that referenced this issue Jan 21, 2021
@bartlomieju
Copy link
Member

Should be fixed in #9374

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working correctly swc related to swc (bundling/transpiling)
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants