-
Notifications
You must be signed in to change notification settings - Fork 47
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
(include "module")
doesn't seem to work as described.
#96
Comments
I think this may have to do with: (def create-context ()
(var context (vm.create-context))
(set module 'filename (pipe (process.cwd) (concat "/exec")))
(set context
'*sibilant sibilant
'module module
'require require)
(each-key key global (set context key (get global key)))
context) this is from the repl file, but it causes a similar kind of issue as what I see with inclusion for the require statement, in that it cannot find modules. It is looking from them from the directory that sibilant is installed, not from where it is run. I have fixed problems like this before in custom module systems I've build for http servers, I'll be seeing what I can do with this. |
(def create-context ()
(var context (vm.create-context)
cwd (process.cwd))
(set module 'filename (pipe cwd (concat "/exec")))
(var p "/")
(assign module.paths [
...module.paths
...(.map (.split cwd path.sep)
(lambda (el)
(var r (path.join p "node_modules"))
(assign p (path.join p el)) r))
cwd
(path.join cwd "node_modules")
])
(set context
'*sibilant sibilant
'module module
'require (modded-require (process.cwd)))
(each-key key global (set context key (get global key)))
context) I have made the following modifications to the create context function, it can find the modules properly inside of a repl context. Much better! now the repls actually useful. |
The above example is not what was used in the fork to fix this, I'd originally thought I could fix it like I had fixed another similar problem with requiring in dynamic contexts, and temporarily borrowed it. (macro add-to-module-lookup (path)
`(scoped (require! 'path)
(var p "/"
inc @(or path (process.cwd)))
(assign module.paths [
...module.paths
...(.map (.split inc path.sep)
(lambda (el)
(var r (path.join p "node_modules"))
(assign p (path.join p el)) r))
(path.join inc "node_modules")
]))) there is now a macro that can be used any where to add a new path to the require look up. |
I thought this would have fixed the inclusion issue as well, but its a no go.
|
Not sure why the above was happening... maybe I've now changed somthing else that magically fixed it, not sure. |
I attempted the example in the documentation for "sibilant-react", and on macro libs I'd written my self, and it does not seem to resolve.
The text was updated successfully, but these errors were encountered: