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

Don't rely on Nodejs global object #1692

Closed
wants to merge 1 commit into from
Closed

Don't rely on Nodejs global object #1692

wants to merge 1 commit into from

Conversation

jaylinski
Copy link
Member

@jaylinski jaylinski commented Jun 3, 2020

Description

If global is used and handlebars is compiled for browser
usage without a Node.js global polyfill, handlebars
fails with a global is undefined error.

Fixes #1593


  • Please don't start pull requests for security issues. Instead, file a report at https://www.npmjs.com/advisories/report?package=handlebars
  • Maintain the existing code style
  • Are focused on a single change (i.e. avoid large refactoring or style adjustments in untouched code if not the primary goal of the pull request)
  • Have good commit messages
  • Have tests
  • Have the typings (lib/handlebars.d.ts) updated on every API change. If you need help, updating those, please mention that in the PR description.
  • Don't significantly decrease the current code coverage (see coverage/lcov-report/index.html)
  • Currently, the 4.x-branch contains the latest version. Please target that branch in the PR.

package.json Outdated Show resolved Hide resolved
@jaylinski
Copy link
Member Author

jaylinski commented Jun 18, 2020

@nknapp I created an example to reproduce the issue: https://github.com/jaylinski/handlebars.js/tree/no-global-reproduce/reproduce

It isn't an issue with default webpack 4 and webpack 5 settings, because global is automatically polyfilled. Related: webpack/webpack#11054

But it saves 0,5KB of size when node is set to false in webpack.

@jaylinski jaylinski closed this Jul 8, 2020
@jaylinski jaylinski reopened this Jul 8, 2020
If `global` is used and handlebars is compiled for browser
usage without a Node.js `global` polyfill, handlebars
fails with a `global is undefined` error.

Fixes #1593
@jaylinski
Copy link
Member Author

@jbboehr @nknapp Is there anything I can do to get this merged and released?

@tonyobanon
Copy link

@jbboehr @nknapp I am experiencing this issue as well cc @jaylinski

@tonyobanon
Copy link

@jbboehr @nknapp Is there anything I can do to get this merged and released?

@jaylinski Were you able to find a workaround?

@jaylinski
Copy link
Member Author

@jaylinski Were you able to find a workaround?

Compiling handlebars with webpack will automatically polyfill global. If you don't use webpack, you have to polyfill global yourself.

@jaylinski jaylinski self-assigned this Nov 23, 2021
@jaylinski jaylinski added the bug label Nov 23, 2021
@jaylinski jaylinski added this to the 4.8 milestone Nov 23, 2021
@jaylinski
Copy link
Member Author

Closed in favor of #1776.

@jaylinski jaylinski closed this Dec 3, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants