Closed Maksss2018 closed 4 years ago
Please can you post up a simple code example that exhibits the problem?
I just tried this and it works:
modules/bar.js
exports = 42;
foo.js
var a = require("bar");
print(a);
Command (so without connecting to a board):
espruino --board PUCKJS foo.js -o out.js
And yes, you can use webpack or other tools like that if you want, but you need to be careful that they don't add loads of 'wrapper' code which will eat up all your RAM
here it's
module.exports = function(trg){
var result;
switch (trg) {
case "0100010101111111111111111000101111": result = "power";break;
case "10001010111111111111111100011111": result = "minus";break;
.........
case "100011111111111111110000010001111": result = "z";break;
default: result = null;
}
return result;
};
and to connecting it use this way :
var s = require("./ir-code-names")
try removing ./
in the name?
I've tried that. it's not working
what is your ir-code-names
filename?
~/some-dir/ir-code-names.js
Tried:
//t.js
var s = require("ir-code-names")
// modules/ir-code-names.js
module.exports = function(trg){
var result;
switch (trg) {
case "0100010101111111111111111000101111": result = "power";break;
case "10001010111111111111111100011111": result = "minus";break;
case "100011111111111111110000010001111": result = "z";break;
default: result = null;
}
return result;
};
works great. closing
Good day I have wrote some small module to make IRreciver code readeble , and then export it with all known methods (module.exports). But result is ERROR cannot find module "./some_module". To save code on board I'm using command
espruino --port /dev/somePort -w ~/code/dir/code.js
orespruino --port /dev/somePort -m ~/code/dir/code.js -e "save()"
. Do I need to load both files or only one of them ? Can I use webpack to generate code writen in es6,8,10 to generate bundle.js - witch I will load on board?