Repository navigation
Build with rolldown so that require() works - #38
Merged
NullVoxPopuli merged 1 commit intoOct 7, 2026
Merged
NullVoxPopuli merged 1 commit into
NullVoxPopuli merged 1 commit into
Conversation
The package has "type": "module", and the CommonJS build was
dist/cjs/*.js. Node read those files as ES modules, and each
require('@handlebars/parser') threw "exports is not defined in ES
module scope".
rolldown now writes dist/cjs/index.cjs and dist/esm/index.js. The
"main" field and the "require" and "default" export conditions point
to the .cjs file.
rolldown does not run on Node 18. The CI test job builds on Node 22
and then runs the tests on each Node version of the matrix.
Fixes handlebars-lang#33
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
NullVoxPopuli-ai-agent
force-pushed
the
nvp/fix-cjs-build
branch
from
October 7, 2026 16:19
6954a4a to
a1ed9d6
Compare
NullVoxPopuli
approved these changes
Oct 7, 2026
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
require('@handlebars/parser')works again. Fixes #33. This PR replaces #34.Cause
The package has
"type": "module", and the CommonJS build wasdist/cjs/*.js. Node read those files as ES modules and threw:Changes
tscbuilds. It writesdist/cjs/index.cjsanddist/esm/index.js.mainand therequireanddefaultexport conditions point todist/cjs/index.cjs.spec/cjs.cjsis a new test. It loads the package by name withrequire. The test fails onmasterwith the error above.Why #34 failed on Node 18
rolldown imports
styleTextfromnode:util. Node 18 does not have that export, sopnpm teststopped in the build step.The package still supports Node 18. Only the build needs a newer Node.
Behavior changes
@handlebars/parser/dist/cjs/parse.jsdo not exist now. Theexportsmap did not permit them before this PR.tsccompiled to ES5. rolldown keeps the syntax of the source, which is ES2015 and later.Checks
requireand withimport.pnpm lintpasses.🤖 Generated with Claude Code