-
Notifications
You must be signed in to change notification settings - Fork 66
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
Link node_modules
during platform creation if it exists
#32
Comments
node_modules
during platform creationnode_modules
during platform creation if it exists
I believe project creations is typically performed with Cordova CLI. I am not sure how many people actually create a project from the platform package. Purpose of the questionThe originating problems backgroundOnce bundled dependencies were removed, when a platform is added, all of the dependencies are installed into the projects root directory, flattened. Therefore the copy command fails because the Removing the bugYes, the best solution is to remove the copy command but there are still test failures to resolve. The test failuresThe failures are coming from If I attempt to copy the https://travis-ci.org/erisu/cordova-ios/jobs/433949167#L3190 The questionBasically, there were two options that I can think of. If CLI If we want to maintain this option, we can update the binary to pass in a flag within the options argument. The flag could be called Alternative flags could be: I am thinking the binaries can be removed and the tests using the binaries as well can be removed. If you have any confusion let me know and I will try to clear it up. |
@erisu Usually I'm all in favor of reducing the surface of Cordova's public API. However, there are people that actually use platforms on their own (see one of the old open PRs in cordova-lib) and while I myself never have users it before, this actually seems like a good feature to me. In any case, I think it would be best to not remove any more stuff in next major. That's all just a first impression. I really need to take a closer look to make an informed decision. I hope I'll be able to do that this weekend. And please note the updates to the issue description I recently made. |
An interesting problem (that we can defer for the moment) is that our dist packages won't have bundled node_modules anymore, so they won't run out-of-the-box. Our release process is to generate tarballs and vote on them, and then publish those to npm, so we don't really want the node_modules folder to be in those packages at publish time, but we do want node_modules in the tarball that we make available for download from the website. |
Is the tarball really a fully a supported distribution method (besides npm)? Does anybody use that? Why? |
To work a project that consists of a single platform, using the |
OK. |
From the description of this issue:
The recent PRs by @erisu seem to ignore this fact. This is mandatory to not break module resolution. Or did you consider this and I am mistaken here? IMO, we need something like this in the create scripts: // ROOT is the platform module root
const platformDependencies = path.join(ROOT, 'node_modules');
if (fs.existsSync(platformDependencies)) {
const localPlatformDependencies = path.join(project_path, 'cordova/node_modules');
fs.ensureSymlinkSync(platformDependencies, localPlatformDependencies, 'junction');
} That should fix things until we find time to do it the right way (just my opinion):
|
There are a bunch of similar-sounding problems here, and I think you've identified one and @erisu handled one, but they're not quite the same problem and it probably makes sense to try to identify all the problems:
The PRs from @erisu solve part of case 4, but we probably need to always copy node_modules if they exist to handle case 5. Are there any additional edge cases that I've missed? Doing this "the right way", and running the platform API scripts from the node_modules folder itself is definitely something we should eventually try to move towards, but we would still need to account for case 4 that requires copying everything. |
Currently installing a platform from a local folder (e.g. |
@raphinesse @dpogue Can this ticket be closed or are there still edge cases missing? |
I don't really have a good grasp of the current state of things. But if all platforms behave like Android (if Adding a platform straight from a tarball is probably still broken for any platforms without bundled dependencies. However, I believe we should not support that workflow anymore. But that should be discussed in another issue targeting a future major release. |
@raphinesse If I am correct, you're referring to the standalone non-CLI usage workflow? If I am correct, I believe we mentioned somewhere that an extra step to the current workflow is now required. For users who use the tarball or GH repo for the standalone approach (non-CLI) must run
|
After removing bundled
node_modules
from platforms in #6, I noticed that the platforms unconditionally copy their (now potentially missing) bundlednode_modules
in theircreate
scripts. Since they all useshelljs
for that, it currently does not break the creation ifnode_modules
but only causes an error message to be displayed.Example from
cordova-android
:https://github.com/apache/cordova-android/blob/8dfddef6f9f5d00fba591a2fbe8837ccebea49a7/bin/lib/create.js#L171
A recent conversation with @erisu made me realize that we actually still need to either copy or preferably link
<PROJECT>/node_modules/cordova-<PLATFORM>/node_modules
to<PROJECT>/platforms/<PLATFORM>/node_modules
if the former exists. Otherwise Node's module resolution would not pick up the correct dependency versions for the platform in case of version conflicts.Task List
Note
In the long run, we should probably try to have only native projects in
platforms
and keep the platforms' build scripts in the project'snode_modules
and run them from there. That should make things easier and cleaner IMHO.The text was updated successfully, but these errors were encountered: