Skip to content

Commit

Permalink
LPD-23371 - Add gradle script to add AMD dependency for react for fra…
Browse files Browse the repository at this point in the history
…gments
  • Loading branch information
bryceosterhaus authored and brianchandotcom committed Apr 30, 2024
1 parent cce6629 commit ad9a41c
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions modules/apps/fragment/fragment-renderer-react-impl/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,32 @@ dependencies {
compileOnly project(":apps:frontend-js:frontend-js-loader-modules-extender-api")
compileOnly project(":apps:portal-template:portal-template-react-renderer-api")
compileOnly project(":core:petra:petra-string")
}

task addReactAMDDependency

// This is to get around our build tooling until fragments can fully convert to ESM
addReactAMDDependency {
dependsOn packageRunBuild

doLast {
def packageJsonFile = file('build/node/packageRunBuild/resources/package.json')
def packageJson = [:]

if (packageJsonFile.exists()) {
packageJson = new groovy.json.JsonSlurper().parseText(packageJsonFile.text)
}

if (!packageJson.containsKey('dependencies')) {
packageJson.dependencies = [:]
}

packageJson.dependencies.'liferay!frontend-js-react-web$react' = '*'

packageJsonFile.text = new groovy.json.JsonBuilder(packageJson).toPrettyString()
}
}

classes {
dependsOn addReactAMDDependency
}

0 comments on commit ad9a41c

Please sign in to comment.