Davidobot / love.js

LÖVE ported to the web using Emscripten, updated to the latest Emscripten and LÖVE (v11.5)
MIT License
605 stars 27 forks source link

[BUG] Cannot import file with same name as game's parent folder #93

Open ChicknTurtle opened 4 months ago

ChicknTurtle commented 4 months ago

This issue only occurs when using love.js. I have a game, with a filetree like this:

game/
├── main.lua
└── game.lua

When I attempt to import game.lua from main.lua...

Game = require 'game'

I get the error:

Error: main.lua:1: module 'game' not found:
love.js:9   no field package.preload['game']
love.js:9   no 'game' in LOVE game directories.
love.js:9   no file 'game' in LOVE paths.
...

However, when I rename my game folder to something else (like src), it works fine. Took me forever to figure this out, now it's not much of a problem for me.

Here is how I packaged my game:

love.js game .packaged -t game -c
DocNITE commented 3 months ago

@Davidobot