GeezerVison is showing github.com — Support `package.json` `"exports"` when resolving `tstl.luaPlugins` · Issue #1731 · TypeScriptToLua/TypeScriptToLua
Support package.json "exports" when resolving tstl.luaPlugins #1731
Description
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"] });Activity
Perryvw commented on Jul 13, 2026
What does the plugin with exports mapping look like, and why does it need to use it? Why is the plugin not just resolvable by generic means?
jiwonz commented on Jul 13, 2026
What does the plugin with exports mapping look like, and why does it need to use it? Why is the plugin not just resolvable by generic means?
Sorry for missing/less informations. The package exports look like:
{
"exports": {
"./plugins": {
"types": "dist/plugins.d.ts",
"default": "dist/plugins.js"
}
}
}
And i need to use "exports" to achieve these:
- one package containing and exporting multiple plugins
- in my case, i need to export plugin in specific route to export various other necessary features for the package user such as macro types, tsconfig files etc
- package encapsulation (very common and quite necessary)
"exports" field is more modern and regarded feature than "main"
BTW, there was a workaround by adding like plugins.js file that routes/re-exports the exports of dist/plugins.js (which is the way of fallback for commonjs/legacy)
pilaoda commented on Jul 20, 2026
jiwonz commented on Jul 20, 2026
Duplicated? #1389
Oh seems like there was an issue which was written very long time ago but it looks like related but mentioned very poorly especially about the luaPlugins at its second problem. That issue seems mainly talking about module resolution to me rather focused especially on the tstl lua plugins. So i'm bit not sure is it actually duplicated.
Metadata
Metadata
Development
No branches or pull requestsIssue actions