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

'Global name' feature could use more concise syntax #2331

Closed
eligrey opened this issue Jun 19, 2022 · 0 comments
Closed

'Global name' feature could use more concise syntax #2331

eligrey opened this issue Jun 19, 2022 · 0 comments

Comments

@eligrey
Copy link

eligrey commented Jun 19, 2022

In the docs, it's noted that echo 'module.exports = "test"' | esbuild --format=iife --global-name='example.versions["1.0"]' produces the following output:

var example = example || {};
example.versions = example.versions || {};
example.versions["1.0"] = (() => {
  ...
  var require_stdin = __commonJS((exports, module) => {
    module.exports = "test";
  });
  return require_stdin();
})();

This feature could use logical nullish assignment for more concise syntax:

var example;
((example ??= {}).versions ??= {})["1.0"] = (() => {
  ...
  var require_stdin = __commonJS((exports, module) => {
    module.exports = "test";
  });
  return require_stdin();
})();
@evanw evanw closed this as completed in f808dab Jun 19, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant