Skip to content

Commit

Permalink
[jsscripting] Fix bundling of global script & regression from openhab…
Browse files Browse the repository at this point in the history
…#14135

Fixes the regression from openhab#14135 (comment).

While working on this, I also noticed that the cache openhab-js does not work because of wrong webpack commandline args in the pom (wrong entrypoint).

Signed-off-by: Florian Hotze <florianh_dev@icloud.com>
  • Loading branch information
florian-h05 committed Jan 3, 2023
1 parent 8fcfa04 commit e390e25
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 5 deletions.
16 changes: 14 additions & 2 deletions bundles/org.openhab.automation.jsscripting/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
</bnd.importpackage>
<graal.version>22.0.0.2</graal.version> <!-- DO NOT UPGRADE: 22.0.0.2 is the latest version working on armv7l / OpenJDK 11.0.16 & armv7l / Zulu 17.0.5+8 -->
<oh.version>${project.version}</oh.version>
<ohjs.version>openhab@3.2.1</ohjs.version>
<ohjs.version>openhab@3.2.3</ohjs.version>
</properties>

<build>
Expand Down Expand Up @@ -66,11 +66,23 @@
<goal>npm</goal>
</goals>
<configuration>
<!--suppress UnresolvedMavenProperty -->
<arguments>install ${ohjs.version} webpack@5.75.0 webpack-cli@4.10.0</arguments> <!-- webpack-cli >= 5.0.0 doesn't properly process the given entrypoint -->
</configuration>
</execution>
<execution>
<id>npx webpack</id>
<id>npx webpack (openhab-js globals injection)</id>
<goals>
<goal>npx</goal>
</goals>
<configuration>
<!--suppress UnresolvedMavenProperty -->
<arguments>webpack -c ./node_modules/openhab/@globals-webpack.config.js --entry
./node_modules/openhab/@openhab-globals.js -o ./dist</arguments>
</configuration>
</execution>
<execution>
<id>npx webpack (openhab-js)</id>
<goals>
<goal>npx</goal>
</goals>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,6 @@ public class OpenhabGraalJSScriptEngine

private static final Logger LOGGER = LoggerFactory.getLogger(OpenhabGraalJSScriptEngine.class);
private static Source GLOBAL_SOURCE;

static {
try {
GLOBAL_SOURCE = Source.newBuilder("js", getFileAsReader("node_modules/@jsscripting-globals.js"),
Expand All @@ -82,7 +81,6 @@ public class OpenhabGraalJSScriptEngine
}

private static Source OPENHAB_JS_SOURCE;

static {
try {
OPENHAB_JS_SOURCE = Source
Expand All @@ -92,7 +90,7 @@ public class OpenhabGraalJSScriptEngine
throw new RuntimeException("Failed to load @openhab-globals.js", e);
}
}
private static String OPENHAB_JS_INJECTION_CODE = "Object.assign(this, require('openhab'));";
private static final String OPENHAB_JS_INJECTION_CODE = "Object.assign(this, require('openhab'));";

private static final String REQUIRE_WRAPPER_NAME = "__wraprequire__";
/** Final CommonJS search path for our library */
Expand Down

0 comments on commit e390e25

Please sign in to comment.