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

Fix the error when importing Handlebars as ESM module #1696

Closed
wants to merge 1 commit into from

Conversation

ursm
Copy link

@ursm ursm commented Jun 30, 2020

Strict ESM loaders such as Rollup make a strict distinction between the properties of the default exported object and the named export, so importing Handlebars as ESM using Rollup will result in the following error:

$ cat main.js 
import 'handlebars/lib/handlebars.runtime';

$ node_modules/.bin/rollup main.js -p node-resolve > /dev/null

main.js → stdout...
(!) Missing exports
https://rollupjs.org/guide/en/#error-name-is-not-exported-by-module
../src/github.com/handlebars-lang/handlebars.js/lib/handlebars/internal/proto-access.js
log is not exported by ../src/github.com/handlebars-lang/handlebars.js/lib/handlebars/logger.js
55:   if (loggedProperties[propertyName] !== true) {
56:     loggedProperties[propertyName] = true;
57:     logger.log(
               ^
58:       'error',
59:       `Handlebars: Access has been denied to resolve the property "${propertyName}" because it is not an "own property" of its parent.\n` +

  • 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.

@KevinCarnaille2
Copy link

KevinCarnaille2 commented May 10, 2021

+1 for this fix.
Any update about this issue ? I'm using version 4.7.7 and I still have ve got the same error with webpack strictExportPresence property.

@jaylinski jaylinski added this to the 4.8.0 milestone Nov 23, 2021
@jaylinski jaylinski added the bug label Nov 23, 2021
jaylinski added a commit that referenced this pull request Dec 23, 2021
@jaylinski
Copy link
Member

@ursm Thank you for your PR. This will be fixed as part of 0bfb22d.

@jaylinski jaylinski closed this in 03d387b Dec 29, 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.

3 participants