This is an automated email from the ASF dual-hosted git repository.
thiagohp pushed a commit to branch feature/requirejs-less
in repository https://gitbox.apache.org/repos/asf/tapestry-5.git
The following commit(s) were added to refs/heads/feature/requirejs-less by this
push:
new b538e77d6 TAP5-2810: handling lack of module imports better
b538e77d6 is described below
commit b538e77d69e0b59af6a8c6343bf9a882eefd178a
Author: Thiago H. de Paula Figueiredo <[email protected]>
AuthorDate: Sat Aug 2 17:52:57 2025 -0300
TAP5-2810: handling lack of module imports better
---
build.gradle | 2 +-
.../services/javascript/EsModuleManagerImpl.java | 23 +++++++++++++++++-----
.../app1/ModuleConfigurationCallbackTests.groovy | 8 ++++++--
.../tapestry5/integration/app1/App1TestCase.java | 8 ++++++++
4 files changed, 33 insertions(+), 8 deletions(-)
diff --git a/build.gradle b/build.gradle
index 4a4e5f07f..384375f87 100755
--- a/build.gradle
+++ b/build.gradle
@@ -538,12 +538,12 @@ task combinedJacocoReport(type:JacocoReport){
}
task continuousIntegration {
- // tapestry-javadoc doesn't work with Java 8 anymore. That's why it's only
added if != 8.
def dependants = [subprojects.build,
'tapestry-core:testWithJqueryAndRequireJsDisabled',
'tapestry-core:testWithPrototypeAndRequireJsEnabled',
'tapestry-core:testWithPrototypeAndRequireJsDisabled',
combinedJacocoReport]
+ // tapestry-javadoc doesn't work with Java 8 anymore. That's why it's only
added if != 8.
if (JavaVersion.current() != JavaVersion.VERSION_1_8) {
dependants << aggregateJavadoc
}
diff --git
a/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/javascript/EsModuleManagerImpl.java
b/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/javascript/EsModuleManagerImpl.java
index d826467d6..de8e9982f 100644
---
a/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/javascript/EsModuleManagerImpl.java
+++
b/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/javascript/EsModuleManagerImpl.java
@@ -272,13 +272,26 @@ public class EsModuleManagerImpl implements
EsModuleManager
public void writeInitialization(Element body, List<String> libraryURLs,
List<JSONArray> inits)
{
- if (!requireJsEnabled || !libraryURLs.isEmpty() || !inits.isEmpty())
+ final boolean noInits = !requireJsEnabled && libraryURLs.isEmpty() &&
inits.isEmpty();
+
+ if (noInits)
{
- Element element = body.element("script", "type", "module", "id",
"__tapestry-es-module-pageinit__");
-
- element.raw(String.format("import pageinit from
\"t5/core/pageinit\";\npageinit(%s, %s, false);",
- convert(libraryURLs), convert(inits)));
+ body.forceAttributes("data-page-initialized", "true");
+ Element script = body.element("script", "type", "text/javascript");
+ script.raw("document.querySelector(\"body >
div.pageloading-mask\").remove()");
+ }
+ else
+ {
+ if (!requireJsEnabled || !libraryURLs.isEmpty() ||
!inits.isEmpty())
+ {
+ Element element = body.element("script", "type", "module",
"id", "__tapestry-es-module-pageinit__");
+
+ element.raw(String.format("import pageinit from
\"t5/core/pageinit\";\npageinit(%s, %s, false);",
+ convert(libraryURLs), convert(inits)));
+ }
+
}
+
}
private String convert(List<?> input)
diff --git
a/tapestry-core/src/test/groovy/org/apache/tapestry5/integration/app1/ModuleConfigurationCallbackTests.groovy
b/tapestry-core/src/test/groovy/org/apache/tapestry5/integration/app1/ModuleConfigurationCallbackTests.groovy
index c305d71a3..879a24c7c 100644
---
a/tapestry-core/src/test/groovy/org/apache/tapestry5/integration/app1/ModuleConfigurationCallbackTests.groovy
+++
b/tapestry-core/src/test/groovy/org/apache/tapestry5/integration/app1/ModuleConfigurationCallbackTests.groovy
@@ -23,9 +23,13 @@ class ModuleConfigurationCallbackTests extends App1TestCase {
@Test
void simple() {
- openLinks "ModuleConfigurationCallback Demo"
+ if (isRequireJsEnabled()) {
- assert getHtmlSource().contains("\"waitSeconds\" : \"13\"");
+ openLinks "ModuleConfigurationCallback Demo"
+
+ assert getHtmlSource().contains("\"waitSeconds\" : \"13\"");
+
+ }
}
diff --git
a/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/App1TestCase.java
b/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/App1TestCase.java
index 6ca5457bb..ce0640d51 100644
---
a/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/App1TestCase.java
+++
b/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/App1TestCase.java
@@ -10,4 +10,12 @@ import org.apache.tapestry5.test.TapestryTestConfiguration;
@TapestryTestConfiguration(webAppFolder = "src/test/app1")
public abstract class App1TestCase extends TapestryCoreTestCase
{
+ protected boolean isRequireJsEnabled()
+ {
+ if (!isElementPresent("require-js-enabled-value"))
+ {
+ openBaseURL();
+ }
+ return Boolean.valueOf(getText("require-js-enabled-value"));
+ }
}