Skip to content

TSTL forgets to define "lualib_bundle" in certain situations #1071

Description

@Zamiell

In a brand new TSTL project, I import a helper function from an external Lua module from NPM:

import { foo } from "my-npm-module";

foo();

This compiles successfully but results in a runtime error:

module 'lualib_bundle' not found:

Upon inspecting the compiled Lua output, I find that there are N instances of the following line:

require("lualib_bundle");

However, there is no definition of lualib_bundle anywhere.

Realizing this, I manually tweak the TypeScript code in an effort to try to make TypeScriptToLua define it:

import { foo } from "my-npm-module";

foo();

// Force TSTL to include the definition for "concat" in the compiled output
const someArray = [];
someArray.concat();

Sure enough, this removes the runtime error.

So the problem is that TSTL isn't defining lualib_bundle in programs that only have external dependencies or whatever.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugscope: transpileAny transpilation not directly related to code transforms

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions