-
Notifications
You must be signed in to change notification settings - Fork 21
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
require() local JS files at runtime #42
Comments
What's the use case for needing to ast a required file? I don't think we need to go that far but I could be wrong |
Nah, you're right, AST would be overkill. I only really brought it up because acorn is already included and is fast. A regex, which I already added, would work. In any case, I'll likely tackle this, but if anyone else is planning to take a stab at it, please discuss it here first. I have short and long term plans for handling |
Initial implementation is in master. It treats the current working directory as though it was the root for the titanium app. So if you were in the $ triple
> var _ = require('node_modules/lodash/lodash')
undefined
> _.map([1,2,3],function(i){return i*3});
[ 3, 6, 9 ] It will also work with relative and absolute paths. This all needs a lot of testing to flush out the bugs and edge cases. |
Tests show |
This is for iOS simulator only correct? |
Yep, everything is only for ios sim at the moment. https://github.com/tonylukasavage/triple#support |
We should use
acorn
to parse the AST for each line and determine if it contains a require. We should allow it to run as is on the app, and if it fails with a "missing module" error, we should use the repl'srequire.resolve
to determine the potential local path of the file. If we find it, it should be added to the project (preferably using.include
as in #41) and then the line should be attempted to be executed again.The text was updated successfully, but these errors were encountered: