⚠️ 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/[email protected]/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/[email protected]/node_modules/vite/dist/node/chunks/dep-6f1d3d8c.js:35234:13)
at Object.pp.unexpected (/home/liam/src/playground/vite-project/node_modules/.pnpm/[email protected]/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/[email protected]/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/[email protected]/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/[email protected]/node_modules/vite/dist/node/chunks/dep-6f1d3d8c.js:34413:17)
at Object.parseMaybeUnary (/home/liam/src/playground/vite-project/node_modules/.pnpm/[email protected]/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/[email protected]/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/[email protected]/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/[email protected]/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/[email protected]/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").
Describe the bug
Vite throws a syntax error (from acorn) when loading a module using
??=for SSR.Reproduction
System Info
viteversion: 2.1.0Logs (Optional if provided reproduction)
I think this should be fixed by updating acorn's
ecmaVersionfrom 2020 to 2021 (or "latest").