NanosWorld Imports Transpiler
raw JSON → 0.0.7 verified Fri May 01 auth: no javascript
A tstl (TypeScript to Lua) compiler plugin that transforms standard TypeScript import statements into Package.Require calls compatible with the NanosWorld Lua sandbox. Version 0.0.7 is the latest stable release; the package has no formal release cadence and is likely in early development. It differentiates itself by bridging TypeScript's module system with NanosWorld's custom loading mechanism, enabling developers to write imports naturally while transpiling to package-relative requires.
Common errors
error Cannot find module 'nanosts-imports-transpiler' ↓
cause Package not installed or incorrect path in tstl config.
fix
Run 'npm install --save-dev nanosts-imports-transpiler' and ensure the transform path in tsconfig.json is exactly the package name.
error Error: The transformer 'nanosts-imports-transpiler' is not a valid transformer ↓
cause The module does not export a default function (transformer) expected by tstl.
fix
Verify that the package's default export is a transformer function. Check that you are using the correct version.
Warnings
breaking The plugin expects .ts extension in import paths (e.g., './myModule.ts') to correctly rewrite to .lua. ↓
fix Always include the .ts extension in import statements; the plugin removes it and appends .lua.
gotcha Only default and named imports are supported; re-exports (export/import from) may not work correctly. ↓
fix Use explicit imports. Chain of re-exports is untested.
gotcha The plugin does not handle import side effects (import 'module') or dynamic imports (import()). ↓
fix Avoid these patterns if using NanosWorld Package.Require; use explicit variable assignment.
breaking Package name 'nanosts-imports-transpiler' is different from the npm scope 'nanosworld' (if any); ensure correct spelling. ↓
fix Double-check package name in package.json and import.
Install
npm install nanosts-imports-transpiler yarn add nanosts-imports-transpiler pnpm add nanosts-imports-transpiler Imports
- default wrong
const plugin = require('nanosts-imports-transpiler')correctimport { default as plugin } from 'nanosts-imports-transpiler' - transformer wrong
import { transformer } from 'nanosts-imports-transpiler'correctimport transformer from 'nanosts-imports-transpiler' - TypeScript transformer
// In tstl config (tsconfig.json or lua-transformers): "nanosts-imports-transpiler"
Quickstart
// Ensure typescript-to-lua and nanosts-imports-transpiler are installed:
// npm install --save-dev typescript-to-lua nanosts-imports-transpiler
// In tsconfig.json:
{
"compilerOptions": {
"types": ["typescript-to-lua"],
"plugins": [
{
"transform": "nanosts-imports-transpiler",
"import": "transform"
}
]
}
}
// Example .ts file:
import myModule from "./myModule.ts";
myModule.doSomething();
// Compile with tstl. The import becomes:
// local ____importmap_1 = Package.Require("./myModule.lua")
// local myModule = ____importmap_1.default
// myModule.doSomething()