kutsme
November 10, 2021, 6:07pm
1
Hi. Nakama 3.9.0, typescript. Maybe anyone know how to pass param to typescript module like idFlags in go modules?
For example I want to read package.json file and pass the values to the TS module.
kutsme
November 11, 2021, 10:15pm
2
Any ideas? Just pass any vars to JS module like go idFlags
I’m unfamiliar with idFlags
- can you point me to some resources that explain what it is? Maybe a GitHub repo or documentation?
kutsme
December 22, 2021, 12:39pm
4
## Copyright 2018 The Nakama Authors
##
## Licensed under the Apache License, Version 2.0 (the "License");
## you may not use this file except in compliance with the License.
## You may obtain a copy of the License at
##
## http://www.apache.org/licenses/LICENSE-2.0
##
## Unless required by applicable law or agreed to in writing, software
## distributed under the License is distributed on an "AS IS" BASIS,
## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
## See the License for the specific language governing permissions and
## limitations under the License.
# docker build "$PWD" --build-arg commit="$(git rev-parse --short HEAD)" --build-arg version=v2.1.1 -t heroiclabs/nakama:2.1.1
# docker build "$PWD" --build-arg commit="$(git rev-parse --short HEAD)" --build-arg version="$(git rev-parse --short HEAD)" -t heroiclabs/nakama-prerelease:"$(git rev-parse --short HEAD)"
FROM golang:1.17.5-buster as builder
ARG commit
This file has been truncated. show original
-ldflags “-s -w -X main.version=$version -X main.commitID=$commit”
You cannot pass command line arguments to the TS virtual machine. Instead you should use the runtime env variable to pass info through;
kutsme
December 22, 2021, 2:10pm
6
So I should use YAML config for this?
kutsme
December 22, 2021, 5:20pm
7
I solved this using ‘@rollup /plugin-replace’ plugin:
rollup.config.js
import replace from '@rollup/plugin-replace';
import pkg from '../package.json';
...
plugins: [
replace({
__SERVER_VERSION__: JSON.stringify(pkg.version)
})
]
...
index.d.ts
declare const __SERVER_VERSION__;
main.ts
logger.info('Server version ' + __SERVER_VERSION__)
Thanks