Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't fail builds when using require() for Lua standard library files #5649

Closed
britzl opened this issue Mar 13, 2021 · 1 comment · Fixed by #5861
Closed

Don't fail builds when using require() for Lua standard library files #5649

britzl opened this issue Mar 13, 2021 · 1 comment · Fixed by #5861
Assignees
Labels
bob Issues related to the bob command line build tool feature request A suggestion for a new feature lua Issues related to the use of Lua
Projects

Comments

@britzl
Copy link
Contributor

britzl commented Mar 13, 2021

Is your feature request related to a problem? Please describe (REQUIRED):
The build process picks up all calls to require() to detect which files that are required by the engine to make sure they are included in the application build. This can sometimes be a problem when using code from third-parties that are calling require() on Lua language namespaces such as "debug", "string" and "math" or for that matter calling require for commonly used Lua extensions such as "socket" or "lfs".

Describe the solution you'd like (REQUIRED):
Defold should still search for all calls to require() and include any Lua files matching these calls. Defold should however not fail a build if a file is missing. This should at most generate a warning.

Describe alternatives you've considered (REQUIRED):
It is sometimes possible to modify the third-party code that calls require() on a module, but it is not always convenient.

Additional context (OPTIONAL):
Most recent discussion around this: https://forum.defold.com/t/defold-1-2-180-has-been-released/67743/61?u=britzl

@britzl britzl added feature request A suggestion for a new feature bob Issues related to the bob command line build tool lua Issues related to the use of Lua labels Mar 13, 2021
@britzl britzl added this to To do in 1.2.183 via automation Mar 30, 2021
@britzl britzl removed this from To do in 1.2.183 May 31, 2021
@britzl britzl added this to To do in 1.2.184 via automation May 31, 2021
@britzl
Copy link
Contributor Author

britzl commented Jun 7, 2021

This issue definitely poses a problem to users that include third-party Lua modules where it is not uncommon to see things such as:

local debug = require("debug")

It is not always the case that the Lua debug namespace is loaded from the start and you may in other engines or Lua integrations actually have to require it to load it.

We do not wish to force users to make a copy of the code and remove the require() call and we also do not want our users to add a debug.lua in the root of the project just to satisfy our build pipeline.

For commonly used Lua modules such as "socket" and "lfs" it is also common to see code that does require("socket).

In the cases above we may wish to ignore the missing require. But do we really want this in other scenarios for game related code. Example:

local enemy = require("game.enmy") 

What if this is a typo and it should actually read "game.enemy"? Letting that through and only logging a warning is not great either.

@britzl britzl moved this from To do to In progress in 1.2.184 Jun 7, 2021
@britzl britzl self-assigned this Jun 7, 2021
1.2.184 automation moved this from In progress to Done Jun 14, 2021
@britzl britzl changed the title Don't fail builds because of missing Lua files Don't fail builds when using require() for Lua standard library files Jun 14, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bob Issues related to the bob command line build tool feature request A suggestion for a new feature lua Issues related to the use of Lua
Projects
No open projects
1.2.184
  
Done
Development

Successfully merging a pull request may close this issue.

1 participant