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

DefinePlugin process with object shorthand property incorrectly #16764

Closed
lwr opened this issue Mar 1, 2023 · 2 comments · Fixed by #17231
Closed

DefinePlugin process with object shorthand property incorrectly #16764

lwr opened this issue Mar 1, 2023 · 2 comments · Fixed by #17231

Comments

@lwr
Copy link

lwr commented Mar 1, 2023

Bug report

What is the current behavior?

  • config
module.exports = {
    plugins : [
        new webpack.DefinePlugin({foo : 'aFoo', bar : 'aBar', crash : 'other.prop'})
    ]
}
  • source code
console.log({foo : foo, bar : bar}); // correct
console.log({foo, bar}); // incorrect
console.log({crash}); // SyntaxError: Unexpected token '.'
  • translated code
console.log({foo : aFoo, bar : aBar}); // correct
console.log({aFoo, aBar}); // incorrect
console.log({other.prop}); // SyntaxError: Unexpected token '.'

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

What is the expected behavior?

the shorthand property should expand before translate with DefinePlugin,
and only property value can be translated

Other relevant information:
webpack version: 5.75.0
Node.js version: 19.6.1
Operating System: macOs 13.2.1 (22D68)
Additional tools:

@alexander-akait
Copy link
Member

Yeah, thank you for an issue, duplicate of #14800, we have a PR, so let's close in favor #14800 and I will put a link on this PR to not lose your cases and add them to test cases

@vankop
Copy link
Member

vankop commented Mar 10, 2023

@alexander-akait I guess this is another issue, it affects only DefinePlugin

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants