Skip to content

Support package.json "exports" when resolving tstl.luaPlugins #1731

Description

@jiwonz

luaPlugins tstl option with name field currently cannot resolve plugin packages that rely on package.json "exports" subpath mappings.

Example tsconfig:

{
  "tstl": {
    "luaPlugins": [
      {
        "name": "my-package/plugins"
      }
    ]
  }
}

This fails with a plugin resolution diagnostic like:

Could not resolve "my-package/plugins" plugin from "...".

However, the package is valid and works with Node resolution:

require("my-package/plugins")

I doubt because resolve library that currently tstl is using is old and unable to resolve the plugin package via package.json's "exports" properly

https://github.com/TypeScriptToLua/TypeScriptToLua/blob/master/src/transpilation/utils.ts#L54

resolved = resolve.sync(query, { basedir, extensions: [".js", ".ts", ".tsx"] });

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions