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

Unable to use "??=" in SSR #2526

Closed
3 tasks done
Liamolucko opened this issue Mar 16, 2021 · 0 comments
Closed
3 tasks done

Unable to use "??=" in SSR #2526

Liamolucko opened this issue Mar 16, 2021 · 0 comments
Labels
bug: upstream Bug in a dependency of Vite

Comments

@Liamolucko
Copy link

Liamolucko commented Mar 16, 2021

⚠️ IMPORTANT ⚠️ Please do not ignore this template. If you do, your issue will be closed immediately.

Describe the bug

Vite throws a syntax error (from acorn) when loading a module using ??= for SSR.

Reproduction

// index.js
let foo = null;
foo ??= 5;
// server.js
const vite = require("vite");
const server = vite.createServer().then((server) =>
  server.ssrLoadModule("/index.js")
);

System Info

  • vite version: 2.1.0
  • Operating System: Manjaro Linux
  • Node version: 15.10.0
  • Package manager (npm/yarn/pnpm) and version: pnpm 3.18.7

Logs (Optional if provided reproduction)

/home/liam/src/playground/vite-project/node_modules/.pnpm/vite@2.1.0/node_modules/vite/dist/node/chunks/dep-6f1d3d8c.js:35234
  var err = new SyntaxError(message);
            ^

SyntaxError: Unexpected token (2:6)
    at Object.pp$4.raise (/home/liam/src/playground/vite-project/node_modules/.pnpm/vite@2.1.0/node_modules/vite/dist/node/chunks/dep-6f1d3d8c.js:35234:13)
    at Object.pp.unexpected (/home/liam/src/playground/vite-project/node_modules/.pnpm/vite@2.1.0/node_modules/vite/dist/node/chunks/dep-6f1d3d8c.js:32926:8)
    at Object.pp$3.parseExprAtom (/home/liam/src/playground/vite-project/node_modules/.pnpm/vite@2.1.0/node_modules/vite/dist/node/chunks/dep-6f1d3d8c.js:34633:10)
    at Object.pp$3.parseExprSubscripts (/home/liam/src/playground/vite-project/node_modules/.pnpm/vite@2.1.0/node_modules/vite/dist/node/chunks/dep-6f1d3d8c.js:34436:19)
    at Object.pp$3.parseMaybeUnary (/home/liam/src/playground/vite-project/node_modules/.pnpm/vite@2.1.0/node_modules/vite/dist/node/chunks/dep-6f1d3d8c.js:34413:17)
    at Object.parseMaybeUnary (/home/liam/src/playground/vite-project/node_modules/.pnpm/vite@2.1.0/node_modules/vite/dist/node/chunks/dep-6f1d3d8c.js:42955:29)
    at Object.pp$3.parseExprOp (/home/liam/src/playground/vite-project/node_modules/.pnpm/vite@2.1.0/node_modules/vite/dist/node/chunks/dep-6f1d3d8c.js:34373:41)
    at Object.pp$3.parseExprOps (/home/liam/src/playground/vite-project/node_modules/.pnpm/vite@2.1.0/node_modules/vite/dist/node/chunks/dep-6f1d3d8c.js:34350:91)
    at Object.pp$3.parseMaybeConditional (/home/liam/src/playground/vite-project/node_modules/.pnpm/vite@2.1.0/node_modules/vite/dist/node/chunks/dep-6f1d3d8c.js:34331:19)
    at Object.pp$3.parseMaybeAssign (/home/liam/src/playground/vite-project/node_modules/.pnpm/vite@2.1.0/node_modules/vite/dist/node/chunks/dep-6f1d3d8c.js:34299:19) {
  pos: 29,
  loc: Position { line: 2, column: 6 },
  raisedAt: 30
}

I think this should be fixed by updating acorn's ecmaVersion from 2020 to 2021 (or "latest").

@yyx990803 yyx990803 added bug: upstream Bug in a dependency of Vite and removed pending triage labels Mar 16, 2021
@github-actions github-actions bot locked and limited conversation to collaborators Jul 16, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug: upstream Bug in a dependency of Vite
Projects
None yet
Development

No branches or pull requests

2 participants