Repository navigation
fix(gradle-plugin): dynamically resolve script filename for JS and Wasm targets - #117
Merged
Merged
Conversation
…sm targets - Add configurable scriptFileName Property to JsSourceGeneratorTask and WasmSourceGeneratorTask with fallback to SCRIPT_FILE_NAME. - Dynamically resolve script filename using target webpack configuration, outputModuleName, or project name instead of hardcoded composeApp.js. - Ensure storytale web run tasks are grouped under StorytaleGradlePlugin.STORYTALE_TASK_GROUP. - Add unit tests covering standard (composeApp), flat subproject (:shared), nested (:app:shared), custom outputModuleName, and webpack task resolution.
JSMonk
approved these changes
Oct 15, 2026
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.
Problem
The Gradle plugin hardcodes
composeApp.jsas the script filename inJsSourceGeneratorTaskandWasmSourceGeneratorTask. When Storytale is applied to projects using other module names (such as:sharedor nested:app:shared), the generatedindex.htmlreferences a non-existentcomposeApp.js, causing a 404 script loading failure in the browser.Solution
scriptFileName: Property<String>property toJsSourceGeneratorTaskandWasmSourceGeneratorTask, defaulting tocomposeApp.jsfor backwards compatibility.resolveScriptFileName(target)in the Gradle plugin to resolve the script bundle name dynamically:mainOutputFileName(if configured)target.outputModuleName${project.name}.js)storytale.ResolveScriptFileNameTestverifying resolution across:composeApp->composeApp.js):shared->shared.js):app:shared->root-app-shared.js)outputModuleNameoverride via KGP DSLmainOutputFileNameoverrideVerification
./gradlew spotlessCheck(passes)./gradlew -p modules/gradle-plugin test(5/5 unit tests pass inResolveScriptFileNameTest)./gradlew :examples:wasmJsBrowserStoriesDevelopmentRun(verifies existing:examplesapp)./gradlew :shared:wasmJsBrowserStoriesDevelopmentRun -PcmpProfile=1.10in aryapreetam/storytale-sample (verifies:sharedlibrary module)Visual Verification & Reproduction Steps
1. Internal Application (
:examples)Run the Wasm development server in the repository(
./gradlew :examples:wasmJsBrowserStoriesDevelopmentRun):2. External KMP Project with
:sharedmodule (aryapreetam/storytale-sample)Reproduction Steps:
git clone https://github.com/aryapreetam/storytale-sample.git cd storytale-sampleshared/build.gradle.kts, apply the local snapshot:plugins { ... - id("io.github.aryapreetam.storytale") version "0.0.6" + id("org.jetbrains.compose.storytale") version "0.0.4-SNAPSHOT" }settings.gradle.kts, set Kotlin to 2.3.10 under profile 1.10 (to match the current compiler plugin baseline):... versionCatalogs { create("libs") { when (profile) { "1.10" -> { - version("kotlin", "2.3.21") + version("kotlin", "2.3.10") ... } .... } } } ...Note: Verified against Kotlin 2.3.10 baseline to match the current compiler plugin registrar. (A separate PR will address IrGenerationExtension compatibility for Kotlin 2.3.20+ / 2.4+).
./gradlew :shared:wasmJsBrowserStoriesDevelopmentRun -PcmpProfile=1.10: