Closed IngwiePhoenix closed 8 years ago
Hi @IngwiePhoenix,
Nice suggestion! I've now added this to PHPCore v3.5.0/Uniter v2.6.0.
I'm now also passing the ValueFactory
instance through as the fourth argument to the include transport, so you can use it like so:
phpEngine.configure({
include: function (path, promise, callerPath, valueFactory) {
promise.resolve(valueFactory.coerce(21)); // Or .createInteger(...)/.createFloat(...), etc.
}
});
Cheers, Dan
Amazing!
And with that, I should be all up and ready to port my backend code over, completely. I'll introduce a proper transport to uniter-node
and see how it goes. When that one works as expected, ill send a PR to introduce a register
script to Uniter, which behaves like babelo's registrar or CoffeeScript - but for PHP instead :).
Thanks for implementing that stuff! (:
So originally, the function that returns/resolves the result of an include or require statement was supposed to be either a wrapper function for the new compiled PHP code or the already compiled code.
Since we are urging the compiler itself out of the runtime, we will only be able to return the transpield PHP source as returned by phpToJS. However, what if we want to actually return a value itself? Say I want to tweak the require keyword to return node modules, I'd like to do something such as
I believe this should be possible.