Edoardo Luppi
11/24/2023, 3:03 PMBig Chungus
11/24/2023, 7:02 PMBig Chungus
11/24/2023, 7:03 PMEdoardo Luppi
11/24/2023, 7:06 PMBig Chungus
11/24/2023, 7:07 PMBig Chungus
11/24/2023, 7:10 PMexternal fun require(module: String): dynamic
val jsModule = require("./subpath/file.js")
Edoardo Luppi
11/24/2023, 7:11 PMBig Chungus
11/24/2023, 7:11 PMEdoardo Luppi
11/24/2023, 7:12 PMBig Chungus
11/24/2023, 7:12 PMEdoardo Luppi
11/24/2023, 7:13 PM// The local package with the generated parsers
val localPackage = rootProject.layout.projectDirectory.dir("generated-packages/${project.name}-js")
implementation(npm("parsers-js", "link:${localPackage.asFile.canonicalPath}"))
Edoardo Luppi
11/24/2023, 7:18 PMfile.js
exports default
a MyClass
, I could just write
public external fun require(module: String): (ctorArg: Any?) -> MyClass
Big Chungus
11/24/2023, 7:18 PMBig Chungus
11/24/2023, 7:18 PMBig Chungus
11/24/2023, 7:19 PMBig Chungus
11/24/2023, 7:19 PMEdoardo Luppi
11/24/2023, 7:20 PMresources
, as you suggested, would it be possible to use @JsModule
?
Or am I stuck with require
in that case?Big Chungus
11/24/2023, 7:21 PMEdoardo Luppi
11/24/2023, 7:21 PMBig Chungus
11/24/2023, 7:22 PMEdoardo Luppi
11/24/2023, 7:23 PMJsModule
will be translated to a require
call anyway in the end, correct?Big Chungus
11/24/2023, 7:23 PMEdoardo Luppi
11/24/2023, 7:23 PMBig Chungus
11/24/2023, 7:23 PMBig Chungus
11/24/2023, 7:25 PMEdoardo Luppi
11/24/2023, 7:25 PMEdoardo Luppi
11/24/2023, 7:33 PM@file:JsModule("./antlr-gen/JsFaultReportLexer")
package com.hcl.mainframe.proto.parser
@JsName("default")
public external class JsFaultReportLexer(input: Any?)
With this directory layoutBig Chungus
11/24/2023, 7:34 PMBig Chungus
11/24/2023, 7:35 PMEdoardo Luppi
11/24/2023, 7:36 PMresources
-way a try!
And btw, the test works because I manually copied the antlr-gen
directory.
It seems like when executing tests, resources are not copied under the testDevelopmentExecutable/kotlin
directory.Edoardo Luppi
11/24/2023, 7:36 PMBig Chungus
11/24/2023, 7:36 PMBig Chungus
11/24/2023, 7:37 PMEdoardo Luppi
11/24/2023, 7:37 PMBig Chungus
11/24/2023, 7:37 PMEdoardo Luppi
11/24/2023, 7:38 PMEdoardo Luppi
11/24/2023, 7:41 PMsrc/jsMain/resources
and src/jsTest/resources
3. verify what's the best way to write externalsBig Chungus
11/24/2023, 7:43 PMBig Chungus
11/24/2023, 7:43 PMEdoardo Luppi
11/24/2023, 7:45 PMEdoardo Luppi
11/24/2023, 7:45 PM