Skip to content

fix: preserve jsparser CommonJS package boundary#1984

Merged
edusperoni merged 1 commit into
NativeScript:mainfrom
tannerlinsley:taren/preserve-jsparser-commonjs-boundary
Jul 21, 2026
Merged

fix: preserve jsparser CommonJS package boundary#1984
edusperoni merged 1 commit into
NativeScript:mainfrom
tannerlinsley:taren/preserve-jsparser-commonjs-boundary

Conversation

@tannerlinsley

@tannerlinsley tannerlinsley commented Jul 21, 2026

Copy link
Copy Markdown
Contributor

Problem

The Android runtime package copies js_parser.js into an app's generated platform directory without its package boundary. When the app (or an ancestor workspace) declares "type": "module", Node treats that bundled CommonJS parser as ESM and the static binding generator fails with ReferenceError: require is not defined in ES module scope.

Fix

  • Declare the parser package as CommonJS explicitly.
  • Copy its package.json alongside js_parser.js in the runtime package.
  • Verify the packaged parser boundary during the Gradle packaging graph.

Verification

  • ./gradlew help --no-daemon --console=plain
  • Built, installed, and exercised an API 35 NativeScript Android app under a type: module package boundary. The static binding generator completed and the native app launched successfully.

Summary by CodeRabbit

  • Bug Fixes
    • Improved distribution packaging for the JavaScript parser by including its package metadata.
    • Added validation to ensure the packaged parser uses the correct CommonJS module format.
    • Updated build verification to catch packaging issues before project templates are created.

@coderabbitai

coderabbitai Bot commented Jul 21, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 084101b4-5bb5-4e0b-a82c-133d63baef2a

📥 Commits

Reviewing files that changed from the base of the PR and between 04d143f and 4d89621.

📒 Files selected for processing (2)
  • build.gradle
  • test-app/build-tools/jsparser/package.json

📝 Walkthrough

Walkthrough

The jsparser distribution now includes its package manifest, declares CommonJS semantics, and validates the packaged manifest before completing project template copying.

Changes

JS parser package validation

Layer / File(s) Summary
CommonJS package contract
test-app/build-tools/jsparser/package.json
The package manifest declares "type": "commonjs".
Packaging and verification
build.gradle
The distribution copies package.json, validates its existence and type field, and wires verification into project template copying.

Estimated code review effort: 2 (Simple) | ~10 minutes

Poem

I’m a rabbit with a manifest bright,
CommonJS tucked in just right.
Copy, check, then hop along,
The parser’s package now belongs.
Build trails sparkle in the night!

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the main change: preserving the jsparser CommonJS package boundary.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@edusperoni
edusperoni merged commit e6d0d3d into NativeScript:main Jul 21, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants