Switch to compiler support v4 in FluenceJS (#566)

This commit is contained in:
Pavel 2022-10-09 16:45:10 +03:00 committed by GitHub
parent befa534c57
commit 5b2e08920c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 16 additions and 14 deletions

View File

@ -3,21 +3,23 @@ package aqua.backend
object Header {
def header(isJs: Boolean, isCommonJS: Boolean): String = {
val callParams = if (isJs) "" else "CallParams,"
val callParams =
if (isJs) ""
else
"import type { CallParams$$ } from '@fluencelabs/fluence/dist/internal/compilerSupport/v4'"
val imports = if (isCommonJS) {
"""const { Fluence, FluencePeer } = require('@fluencelabs/fluence');
"""const { FluencePeer } = require('@fluencelabs/fluence');
|const {
| callFunction,
| registerService,
| CallParams
|} = require('@fluencelabs/fluence/dist/internal/compilerSupport/v3${if (isJs) ".js" else ""}');""".stripMargin
| callFunction$$,
| registerService$$,
|} = require('@fluencelabs/fluence/dist/internal/compilerSupport/v4${if (isJs) ".js" else ""}');""".stripMargin
} else {
s"""import { Fluence, FluencePeer } from '@fluencelabs/fluence';
s"""import { FluencePeer } from '@fluencelabs/fluence';
|$callParams
|import {
| $callParams
| callFunction,
| registerService,
|} from '@fluencelabs/fluence/dist/internal/compilerSupport/v3${if (isJs) ".js"
| callFunction$$$$,
| registerService$$$$,
|} from '@fluencelabs/fluence/dist/internal/compilerSupport/v4${if (isJs) ".js"
else ""}';""".stripMargin
}
s"""/**

View File

@ -37,7 +37,7 @@ case class OutputFunc(func: FuncRes, types: Types) {
| let script = `
|$script
| `
| return callFunction(
| return callFunction$$$$(
| args,
| ${funcDef.asJson.deepDropNullValues.spaces4},
| script

View File

@ -27,7 +27,7 @@ case class OutputService(srv: ServiceRes, types: Types) {
|${serviceTypes.generate}
|
|export function register${srv.name}(${typed("...args", "any")}) {
| registerService(
| registerService$$$$(
| args,
| ${serviceDef.asJson.deepDropNullValues.spaces4}
| );

View File

@ -81,5 +81,5 @@ object TypeScriptCommon {
} else {
"null"
}
s"callParams: CallParams<${generic}>"
s"callParams: CallParams$$$$<${generic}>"
}