-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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 object literals for define #581
Comments
The reason this isn't supported is that doing this is an anti-pattern. The For example, replacing If you still want to replace an identifier with an object literal, you should probably use the |
That is a good point that I didn't really give a lot of thought to. Still it seems like something that could be warned about in the documentation, rather than prohibited altogether. The same issue does also apply to long strings. For my use case, I only really reference the identifier twice, and one of them is a typeof expression that could theoretically be optimized out: Still, I agree that the behavior of inject is better, though it is slightly less convenient to have to write a temporary file. It seems that there could be a variant of |
@evanw , for my use case it's need to pass a simple structures inside bundled code (AWS CDK + Lambda@Edge which highly restricted in terms of configuration). There are 3 ways to handle this:
Now I prefer option 2, but code is still not ideal. |
Currently the
define
transform only supports identifiers, strings, numbers, boolean, and null. It would be convenient to also support object literals, or ideally arbitrary JavaScript expressions. Object literals in particular are an important use case for me.Is there a reason that can't be supported?
The text was updated successfully, but these errors were encountered: