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

Bundler issue with the logical nullish assignment (x ??= y) operator #8627

Closed
jveres opened this issue Dec 5, 2020 · 6 comments
Closed

Bundler issue with the logical nullish assignment (x ??= y) operator #8627

jveres opened this issue Dec 5, 2020 · 6 comments
Labels
bug Something isn't working correctly swc related to swc (bundling/transpiling)

Comments

@jveres
Copy link
Contributor

jveres commented Dec 5, 2020

Deno version 1.5.4

echo "let a = null, b = 2; console.log(a ??= b);" > test.ts
deno run test.ts
2
deno bundle test.ts test.bundle.js
deno run test.bundle.js
error: Unexpected token `=`. Expected this, import, async, function, [ for array literal, { for object literal, @ for decorator, function, class, null, true, false, number, bigint, string, regexp, ` for template literal, (, or an identifier at file:///Users/U715864/temp/test.bundle.js:2:16

cc @kdy1

@kdy1 kdy1 mentioned this issue Dec 6, 2020
7 tasks
@kitsonk kitsonk added bug Something isn't working correctly swc related to swc (bundling/transpiling) labels Dec 6, 2020
@kdy1
Copy link

kdy1 commented Dec 9, 2020

@kitsonk This seems like a bug of deno run. It works well with fixture testing, but it errors on deno run.

kdy1 added a commit to kdy1/swc that referenced this issue Dec 9, 2020
kdy1 added a commit to kdy1/swc that referenced this issue Dec 9, 2020
kdy1 added a commit to kdy1/swc that referenced this issue Dec 9, 2020
@kdy1
Copy link

kdy1 commented Dec 9, 2020

Ah.. I found the root cause.
??= is typescript-only extension.

I'll transform it from typescript::strip.

@kitsonk
Copy link
Contributor

kitsonk commented Dec 9, 2020

@kdy1 no it is Stage 4 proposal for ECMAScript: https://github.com/tc39/proposal-logical-assignment. It is valid JavaScript in most greenfield browsers: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Logical_nullish_assignment

@kdy1
Copy link

kdy1 commented Dec 9, 2020

Oh, thanks! I didn't know it. Then I'll simply allow ??= in js files.

@kitsonk
Copy link
Contributor

kitsonk commented Dec 9, 2020

It is also ||= and &&= that are being added.

kdy1 added a commit to swc-project/swc that referenced this issue Dec 9, 2020
swc_bundler:
 - Handle indirect wrapped es modules. (denoland/deno#8597, denoland/deno#8625)
 - Respect `export { foo }`. (denoland/deno#8626)

swc_ecma_parser:
- Allow `??=`, `||=`, `??=` in non-ts modules. (denoland/deno#8627)

swc_ecma_transforms:
 - Make `hygiene` check if a variable with expanded name exists. (denoland/deno#8620)
 - Handle `??=` correctly.
@jveres
Copy link
Contributor Author

jveres commented Dec 23, 2020

Fixed in deno v1.6.2.

@jveres jveres closed this as completed Dec 23, 2020
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

No branches or pull requests

3 participants