Skip to content

moduleMap does not appear to be applied correctly #1122

Description

@justarandomgeek

In Factorio, our require paths can take the form of require("__modname__/somefile.lua") or require("__modname__.somefile"), for loading files from another mod. For most mod devs, stripping the __ and .lua and looking for this in the ordinary fashion (in workspace or library paths, one of which will include the /mods tree) should be sufficient to make this actually resolve.

I have tried several variations of moduleMap rules

"moduleMap": [
      {
        "pattern": "^__(.*)__(.*)$",
        "replace": "$1$2"
      },
      {
        "pattern": "^(.*)\\.lua$",
        "replace": "$1"
      }
    ]
"moduleMap": [
      {
        "pattern": "__",
        "replace": ""
      },
    ]

but nothing seems able to make these able to resolve

emmylua understands these correctly, but they would not work in Factorio:
local sigstr = require("signalstrings/signalstrings")
local sigstr = require("signalstrings.signalstrings")

but not any of these, which are what would actually work in Factorio:
local sigstr = require("__signalstrings__/signalstrings.lua")
local sigstr = require("__signalstrings__.signalstrings")
local sigstr = require("__signalstrings__/signalstrings")

Metadata

Metadata

Assignees

Labels

No labels
No labels

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