From 4d896212407425bfd9ea575eaae9cc17c2950cc4 Mon Sep 17 00:00:00 2001 From: Tanner Linsley Date: Tue, 21 Jul 2026 14:17:52 -0600 Subject: [PATCH] fix: preserve jsparser CommonJS package boundary --- build.gradle | 24 ++++++++++++++++++++-- test-app/build-tools/jsparser/package.json | 1 + 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/build.gradle b/build.gradle index 93be4ace6..9c401ae8d 100644 --- a/build.gradle +++ b/build.gradle @@ -269,7 +269,12 @@ task copyFilesToProjectTemeplate { into "$DIST_FRAMEWORK_PATH/build-tools" } copy { - from "$BUILD_TOOLS_PATH/jsparser/build/js_parser.js" + from("$BUILD_TOOLS_PATH/jsparser/build") { + include "js_parser.js" + } + from("$BUILD_TOOLS_PATH/jsparser") { + include "package.json" + } into "$DIST_FRAMEWORK_PATH/build-tools/jsparser" } copy { @@ -343,6 +348,20 @@ task copyProjectTemplate(type: Copy) { into "$DIST_FRAMEWORK_PATH" } +task verifyJsParserPackage { + doLast { + def packageFile = new File("$DIST_FRAMEWORK_PATH/build-tools/jsparser/package.json") + if (!packageFile.exists()) { + throw new GradleException("The packaged JavaScript parser is missing its package.json boundary.") + } + + def packageJson = new JsonSlurper().parseText(packageFile.text) + if (packageJson.type != "commonjs") { + throw new GradleException("The packaged JavaScript parser must run as CommonJS.") + } + } +} + task copyPackageJson(type: Copy) { from "$rootDir/package.json" into "$DIST_PATH" @@ -394,7 +413,8 @@ if (generateRegularRuntimePackage) { } copyFilesToProjectTemeplate.dependsOn(buildJsParser) -copyProjectTemplate.dependsOn(copyFilesToProjectTemeplate) +verifyJsParserPackage.dependsOn(copyFilesToProjectTemeplate) +copyProjectTemplate.dependsOn(verifyJsParserPackage) copyPackageJson.dependsOn(copyProjectTemplate) setPackageVersionInPackageJsonFile.dependsOn(copyPackageJson) copyReadme.dependsOn(setPackageVersionInPackageJsonFile) diff --git a/test-app/build-tools/jsparser/package.json b/test-app/build-tools/jsparser/package.json index 4ba4a5776..b84de9e3c 100644 --- a/test-app/build-tools/jsparser/package.json +++ b/test-app/build-tools/jsparser/package.json @@ -1,6 +1,7 @@ { "name": "js-parser", "version": "1.0.0", + "type": "commonjs", "description": "javascript static analysis tool", "main": "js_parser.js", "scripts": {