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
Support destructuring #14800
Comments
This issue had no activity for at least three months. It's subject to automatic issue closing if there is no activity in the next 15 days. |
6 other issues were redirected to this one, let's not make it die |
Issue was closed because of inactivity. If you think this is still a valid issue, please file a new issue with additional information. |
@vankop this piece is already supported now correct? |
@TheLarkInn webpack doesnt support destructing.. so what actually happens right now: const { a } = process.env; webpack renders to: const { a } = {...all envs here...}; issue is about providing only required properties: const { a } = { a: 1 }; main reason why it didn't solved yet, as we discussed with @sokra we need to support <es2015 ( mainly babel version ) as well to make build result independent to const { a } = { a: 1 }; for >=es2015 and var _b = {...all envs...},
a = _b.a; but supporting babel version is tricky.. I would vote to drop this and support only destructing |
Last time I tried, |
that is a correct usage.. not sure what you mean.. if you define |
"Correct" but far from ideal since |
yes, api is not optimal, but breaking change could lead to security leaks like: webpack.config.js const define = new DefinePlugin({'env': {..blabla}, 'env.SECRET': 1});
module.exports = [{
name: 'my-awesome-backend',
entry: 'backend.js',
plugins: [define]
}, {
name: 'my-awesome-frontend',
entry: 'frontend.js',
plugins: [define]
}]; backend.js // I love to use secrets on backend since it is quite save
const { SECRET } = env;
// or case that works right now
env.SECRET; frontend.js // I dont like secrets in my frontend to be exposed
const { data } = env; Thats why we cant fix api right now |
For the record, I don't care about The argument in #5392 is that I would expect: new EnvironmentPlugin(['NAME']) to support both Lint rules like The only security argument I see is against allowing I posted my own repos/tests in: |
This doesn't account for the following though : const {
env: {
a
}
} = process; |
Could we try and implement these scenarios behind |
Feature request
support destructuring in:
import * as b from 'b';const {a} = b;
import b from '1.json'; const {a} = b;
What is the expected behavior?
Webpack should support destructuring on parser level
What is motivation or use case for adding/changing the behavior?
Modern versions of runtime environments (browsers, Node.js, Deno) support destructuring
How should this be implemented in your opinion?
JavascriptParser
should be improvedAre you willing to work on this yourself?
yes
The text was updated successfully, but these errors were encountered: