X Tutup
Skip to content

Module resolution resolves lua files in node_modules relative to wrong root location #1307

@Zamiell

Description

@Zamiell

Steps to reproduce:

git clone git@github.com:Zamiell/tstl-bug.git
cd tstl-bug
npm ci
npx tstl
vim dist/main.lua

For reference, you can look at the minimal TSTL module here: https://github.com/Zamiell/tstl-module

The bugged code is here:

["lua_modules.@zamiell.tstl-module.dist.feature.feature"] = function(...) 
local ____exports = {}
local ____constants = require("lua_modules.@zamiell.tstl-module.dist.feature.constants") -- BUG HERE
local BASE_CONSTANT = ____constants.BASE_CONSTANT
local ____constants = require("lua_modules.@zamiell.tstl-module.dist.feature.constants")
local FEATURE_CONSTANT = ____constants.FEATURE_CONSTANT

Instead of this, TSTL should be outputting this:

["lua_modules.@zamiell.tstl-module.dist.feature.feature"] = function(...) 
local ____exports = {}
local ____constants = require("lua_modules.@zamiell.tstl-module.dist.constants") -- FIX HERE
local BASE_CONSTANT = ____constants.BASE_CONSTANT
local ____constants = require("lua_modules.@zamiell.tstl-module.dist.feature.constants")
local FEATURE_CONSTANT = ____constants.FEATURE_CONSTANT

This is a very nasty bug!

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugscope: transpileAny transpilation not directly related to code transforms

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      X Tutup