-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
[TIMOB-7568] CommonJS in Core #1373
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -140,9 +140,21 @@ -(id) moduleNamed:(NSString*)name context:(id<TiEvaluator>)context | |
if (moduleClass!=nil) | ||
{ | ||
m = [[moduleClass alloc] _initWithPageContext:context]; | ||
[m setHost:self]; | ||
[modules setObject:m forKey:name]; | ||
[m release]; | ||
if (![m isJSModule]) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm starting to wonder if we should refactor this so that all of moduleNamed goes straight to Require, do not pass go, do not collect $200. For one, the krollbridge require handles path-based module names while this version does not. This is something we could revisit later, if needed. Something doesn't smell right about this, but I can't put my finger on it. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This does require that There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That was my intention, at least for this pass at solving the problem. Long term, I think it would be great to not have to precompile them to binary. It would be even greater if we could have a single common location for pure JS modules to be loaded by both Android and iOS. But for this pass, it's not necessary at all. Does that answer your question, @sptramer? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sure does. |
||
{ | ||
[m setHost:self]; | ||
[modules setObject:m forKey:name]; | ||
[m release]; | ||
} | ||
else | ||
{ | ||
[m release]; | ||
m = [[self krollBridge] require:context path:name]; | ||
if (m != nil) | ||
{ | ||
[modules setObject:m forKey:name]; | ||
} | ||
} | ||
} | ||
} | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A TiModule is a very different beast than a KrollObject. However, the best match is a KrollWrapper, but the relationships haven't been set up yet.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In this case, it would be best to change the method signature to return an
id
and avoid casting the module.