Closed B2F closed 9 years ago
You should raise this issue with the actual slimerjs binary: https://github.com/laurentj/slimerjs/issues
But it looks to me like it's by design.
http://docs.slimerjs.org/0.9/script-execution.html#modules-and-main-script-context
When you're testing things you should browserify it into one file then run that.
You should probably not depend on that behaviour
use:
# a.js
import fileB from "b"
function somFunc () {
...
let data = { prop: ... };
fileB.mutateWhatever(data)
...
}
# b.js
let B = {
mutateWhatever(data){
this.whatever = data.prop
}
}
export default B
This will then work on any platform with Babel+Browserify
You are right it's more of a design issue on y side of things. Thanks.
Currently, variables defined in the function scope can be accessed by modules, in both nodejs and phantom require implementation but in slimerjs modules seems to be completely isolated from the function scope.
E.g.
From file A (function scope root):
From file B (module file):
Anything can be done to fix this ?