How to import and export modules in Typescript Runtime

Hello,

I am trying to import a TypeScript module into my main.ts file, but I am having trouble. Setting “module” to “System” or “AMD” in the tsconfig file does not work. Please help.

Below is my tsconfig file code:

{
  "compilerOptions": {
    "target": "es5",
    "esModuleInterop": true,
    "forceConsistentCasingInFileNames": true,
    "strict": true,
    "skipLibCheck": true,
    "outFile": "./build/index.js",
    "module": "None",
    "typeRoots": [
      "./node_modules"
    ],
    "lib": [
      "dom",
      "es7"
    ],
    "types": [
      "@types/node",
      "nakama-runtime"
    ]
  }
}

The errors I get when trying to run the server in docker are listed below:

nakama-1    | {"level":"info","ts":"2025-03-26T05:01:05.757Z","caller":"server/runtime_javascript.go:634","msg":"Initialising JavaScript runtime provider","path":"/nakama/data/modules","entrypoint":"build/index.js"}
nakama-1    | {"level":"error","ts":"2025-03-26T05:01:05.784Z","caller":"server/runtime_javascript.go:1694","msg":"Failed to eval JavaScript modules.","error":"ReferenceError: define is not defined at index.js:49:7(41)"}
nakama-1    | {"level":"error","ts":"2025-03-26T05:01:05.785Z","caller":"server/runtime.go:659","msg":"Error initialising JavaScript runtime provider","error":"ReferenceError: define is not defined at index.js:49:7(41)"}
nakama-1    | {"level":"fatal","ts":"2025-03-26T05:01:05.785Z","caller":"main.go:166","msg":"Failed initializing runtime modules","error":"ReferenceError: define is not defined at index.js:49:7(41)"}

Please mirror the settings on our template project.

If you need a more complex build pipeline, there should be a spe/rollup branch but it hasn’t been updated in a while so I cannot guarantee it is current.