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

[webpack 5] Identifier of ?. is not correctly parsed #11186

Closed
SunriseFox opened this issue Jul 17, 2020 · 2 comments · Fixed by #11221
Closed

[webpack 5] Identifier of ?. is not correctly parsed #11186

SunriseFox opened this issue Jul 17, 2020 · 2 comments · Fixed by #11221

Comments

@SunriseFox
Copy link

Bug report

What is the current behavior?

acorn's ChainExpression is not correctly parsed. Variables are not correctly resolved to imports when optional chaining is used.

import test from './test';

console.log(test.a)
console.log(test?.a)

compiles to

/* harmony import */ var _test__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./test */ "./src/test.js");


console.log(_test__WEBPACK_IMPORTED_MODULE_0__.default.a)
console.log(test?.a)

If the current behavior is a bug, please provide the steps to reproduce.

https://github.com/SunriseFox/webpack-bug-optional-chaining

yarn && yarn start

What is the expected behavior?

should be

/* harmony import */ var _test__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./test */ "./src/test.js");


console.log(_test__WEBPACK_IMPORTED_MODULE_0__.default.a)
console.log(_test__WEBPACK_IMPORTED_MODULE_0__.default?.a)

Other relevant information:
webpack version: 5.0.0-beta.22
Node.js version: v12.16.3
Operating System: MacOS 10.15.5
Additional tools: none

@alexander-akait
Copy link
Member

@vankop
Copy link
Member

vankop commented Jul 17, 2020

@sokra FYI working on this..

This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants