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

Add support for globalThis #357

Open
jpoehnelt opened this issue Mar 5, 2024 · 1 comment
Open

Add support for globalThis #357

jpoehnelt opened this issue Mar 5, 2024 · 1 comment

Comments

@jpoehnelt
Copy link

Although global will likely always work in Apps Script, some developers may prefer to use globalThis because it abstracts environment away.

The globalThis property provides a standard way of accessing the global this value (and hence the global object itself) across environments. https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/globalThis

@fossamagna
Copy link
Owner

@jpoehnelt Thank you for your contribution. Now, Identifier of default global object is global.
I agree with using globalThis better than global as default.

you can specify Identifier name of global object as follows:

const fs = require('fs');
const { generate } = require('gas-entry-generator');

const fooSource = fs.readFileSync('foo.js', {encoding: 'utf8'});
const options = {
  globalIdentifierName: "globalThis"
};
const output = generate(fooSource, options);
console.log(output.entryPointFunctions);

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

2 participants