Skip to content

sourcemap.json is ignored in string requires #1141

Description

@HappySunChild

I've noticed that string requires seem to be based exclusively off of the file system regardless of luau-lsp.platform.type or the presence of a sourcemap file. This means that using a default.project.json that points elsewhere doesn't actually do anything and lints an error like so:

file structure:
Image

exampleModule/default.project.json

{
	"name": "exampleModule",
	"tree": {
		"$path": "src"
	}
}

main.luau

-- TypeError: Unknown require: [...]\repro\exampleModule\init.lua
local exampleModule = require("./exampleModule")

This is especially problematic since this makes using git submodules that are formatted this way very impractical and irritating.
I suppose that DataModel based requires still work fine like so:

local exampleModule = require(script.Parent.exampleModule)

...but I feel like this should also just be supported, since technically the first example I gave would run perfectly well in a Roblox environment.

sourcemap.json (generated with Rojo)

{
	"name": "repro",
	"className": "DataModel",
	"filePaths": [
		"default.project.json"
	],
	"children": [
		{
			"name": "ServerScriptService",
			"className": "ServerScriptService",
			"children": [
				{
					"name": "exampleModule",
					"className": "ModuleScript",
					"filePaths": [
						"repro\\exampleModule\\src\\init.luau",
						"repro\\exampleModule\\default.project.json"
					]
				},
				{
					"name": "main",
					"className": "ModuleScript",
					"filePaths": [
						"repro\\main.luau"
					]
				}
			]
		}
	]
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions