-
-
Notifications
You must be signed in to change notification settings - Fork 3
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-27206] Unable to require files under node_modules #131
base: master
Are you sure you want to change the base?
Conversation
@ewanharris - Is this PR waiting on anything? LiveView doesn't work without it if you use npm modules at all. |
@brentonhouse, I just haven't had time to review it yet. I gave preference to Ebenezer's PRs as he will be finishing on our team at the start of next week and I wanted to get him some product development before switching. What ticket is this PR associated with? |
associated with: https://jira.appcelerator.org/browse/TIMOB-27206 |
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.
Took an initial run through the code changes, need to pull this down and test it
file = Ti.Filesystem.getFile(path); | ||
const idPath = path.parse(id); | ||
|
||
// TIBUG: Fix for path.parse bug |
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.
Is there a ticket for this bug? I'd prefer to schedule a fix alongside this change to liveview rather than add fixes in liveview
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.
Not sure if there is a ticket for this. It probably involves replacing our custom "path" module with the open-source path module.
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.
Filed TIMOB-27899 to fix this in 9.1.0
// want to add these into a classic apps Resources dir | ||
const buildNodeModulesPath = join(RESOURCE_DIR, '..', 'build', 'node_modules', uri); | ||
const buildNodeModulesPath = join(RESOURCE_DIR, '..', 'build', 'node_modules', uri + urlPath.ext); |
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.
I need to double check but I think we can remove this now as we're bundling the sdk core JS code
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.
ok. I can remove it.
lib/fserver.js
Outdated
} else { | ||
|
||
let filename = join(RESOURCE_DIR, uri); | ||
let filename = join(RESOURCE_DIR, uri + urlPath.ext); | ||
log('[LiveView]'.green, 'filename: ' + filename); |
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.
I assume these will be removed before merge?
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.
done
Co-Authored-By: Ewan Harris <[email protected]>
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.
Testing locally it seems like KS-v2 is erroring out on startup on Android with these changes, need to dig in to find the problem.
@brentonhouse, is your sample app working fine on Android?
const platformFilepath = join(RESOURCE_DIR, requestPlatform, uri + urlPath.ext); | ||
const platformFilepath2 = join(RESOURCE_DIR, requestPlatform, uri, 'index' + urlPath.ext); | ||
const overridePath = join(__dirname, 'overrides', uri + urlPath.ext); | ||
const projectNodeModulesMainPath = join(RESOURCE_DIR, requestPlatform, 'node_modules', uri + urlPath.ext); |
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.
Looking up under Resources/<platform>
is only correct for Alloy apps, we need to ensure this works for both Classic and Alloy.
Also, after testing this out I think only going on node_modules
level deep might also be problematic, seeing as the algorithm we use in the SDK is pretty much the same as node (minus the loading of .node
files) I think we could maybe use require.resolve with the paths
set to the directory name
Co-authored-by: Ewan Harris <[email protected]>
…w into node_modules_update
@brentonhouse I've been trying this out in classic and there seems to be some issues around requiring files. If I create However if I then rebuild I haven't tested yet but I'm going to guess that'll extend to alloy libs too |
@ewanharris - I have had to change this around significantly in order for it to work with all the latest code. I ended up just doing the changes in the combined file instead of the split code files so I would work faster and test things easier. I would have to back track this to each of the separate files unless we are finally ready to get rid of those. |
@brentonhouse, I think I'm fine with removing the multiple files + concat build process. However I don't think it should be done in this PR as it would just add a ton of noise and make it difficult to review the require resolution changes |
@brentonhouse, if you want. Send me the |
There are several areas that I need to investigate to improve performance of this. Right now, it is checking to see if a file exists but is having to do it multiple times for each request because it doesn't know what files exists. I need to get access to (or create) a cache of JS files and native modules so that LiveView can just check this instead of the more time consuming check I implemented.