khamake
khamake copied to clipboard
require() is not working for local scripts
Currently it's not possible to require local scripts from within khafile.js.
khafile.js
const myscript = require('./myscript.js');
let project = new Project('xxx');
...
Creating Kha project.
{ Error: Cannot find module './myscript.js'
...
I guess this is due to how the projectfile is run in https://github.com/KTXSoftware/khamake/blob/master/src/ProjectFile.ts#L24 as it only gets very limited access to anything from the executing script.
I guess it's because the current script dir is something else when the code executes. But should be possible to fix that...
Found a workaround for now: just create a node_modules folder in your project root drop myscript.js there and then you can require('myscript.js') in khafile.js and it gets picked up.