Now thinking about the sequencing, it makes sense: on code upload, IDE parses the source looking for all the require()... Since the module is nowhere to be found because it will be created on execution dynamically by the code itself and the IDE is not executing code, pushing out a warning is the best - and most friendly - the IDE can do...
Using @DrAzzy's approach - using a variable for the module name - 'hides' the module for the IDE... and the IDE is not checking for the module... (variable name in the source is not a literal String).
@DrAzzy, since IDE's parse is obviously a simple implementation, no variable is required (which in the above 1v72 Person class example costs 4 variable slots). Putting the string in parenthesis - as an expression - works just as fine and does not give away any variable slots: ...require(("Person"))...
is all it needs... ;-)
What I try to achieve - in general - is get rid also of warnings... Warnings are not really an issue, but they are a great (gut) indicator that something is about to go bad... ;-). Adding some sort of directives/annotations for the uploader could help here to get rid of the warning... - @Gordon: this is the second-to-last thing on your to-do list, in case it even makes it on the list... the last thing is still be discovered ;-)
Espruino is a JavaScript interpreter for low-power Microcontrollers. This site is both a support community for Espruino and a place to share what you are working on.
@Gordon, I came across this while working on returning a 'class' definition as module (see How to create a module that is a 'Class' - aka a function usable with new - or: How to make require() return a function and not an object and 'playing' with the Modules object (modules cache) to make it happen. So no real-world goal at first sight... but keep reading.
Now thinking about the sequencing, it makes sense: on code upload, IDE parses the source looking for all the require()... Since the module is nowhere to be found because it will be created on execution dynamically by the code itself and the IDE is not executing code, pushing out a warning is the best - and most friendly - the IDE can do...
Using @DrAzzy's approach - using a variable for the module name - 'hides' the module for the IDE... and the IDE is not checking for the module... (variable name in the source is not a literal String).
@DrAzzy, since IDE's parse is obviously a simple implementation, no variable is required (which in the above 1v72 Person class example costs 4 variable slots). Putting the string in parenthesis - as an expression - works just as fine and does not give away any variable slots:
...require(("Person"))...
is all it needs... ;-)
What I try to achieve - in general - is get rid also of warnings... Warnings are not really an issue, but they are a great (gut) indicator that something is about to go bad... ;-). Adding some sort of directives/annotations for the uploader could help here to get rid of the warning... - @Gordon: this is the second-to-last thing on your to-do list, in case it even makes it on the list... the last thing is still be discovered ;-)