Skip to content
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

Specifying modules issue #509

Closed
becvert opened this issue Nov 20, 2023 · 5 comments
Closed

Specifying modules issue #509

becvert opened this issue Nov 20, 2023 · 5 comments

Comments

@becvert
Copy link

becvert commented Nov 20, 2023

Hello,
What should be the expected behavior when specifying modules in config.xml like that <preference name="cordova.plugins.diagnostic.modules" value="CAMERA MICROPHONE" /> ?
Because from what I can see, source files are still included for other modules, and initialize is called on all of them on iOS at least.
I would expect only the core module and specified modules should be present and initialized.
Thank you.

@becvert
Copy link
Author

becvert commented Nov 20, 2023

I read this note

It's vital that the preference be added to your config.xml before you install the plugin, otherwise the preference will not be applied and all modules will be added

I always rebuild my app from scratch:
1- platforms & plugins folders are removed from my cordova project directory
2- npm i --package-lock-only
3- cordova platform add
4- cordova prepare

@becvert becvert changed the title Specifying modules on iOS does not seem to work Specifying modules issue Nov 20, 2023
@becvert
Copy link
Author

becvert commented Nov 20, 2023

It looks like the postinstall script is not called

@becvert
Copy link
Author

becvert commented Nov 20, 2023

Could it be because I use a local copy of this plugin. In my package.json:

"dependencies": {
        "cordova.plugins.diagnostic": "../cordova/cordova.plugins.diagnostic"
}

@dpa99c
Copy link
Owner

dpa99c commented Nov 20, 2023

Could it be because I use a local copy of this plugin. In my package.json:

"dependencies": {
        "cordova.plugins.diagnostic": "../cordova/cordova.plugins.diagnostic"
}

npm might not be running the post_install script if the dependency target is local.

If the local version is a fork, presumably you have it backed up remotely such as in a github/bitbucket repo, in which case you should update the target to the remote repo URL:

"dependencies": {
        "cordova.plugins.diagnostic": "github:username/cordova.plugins.diagnostic"
}

if the local version is not forked, just change it the npm release version:

"dependencies": {
        "cordova.plugins.diagnostic": "cordova.plugins.diagnostic^x.y.z"
}

after this running, npm install should run the post_install script and apply the module selection mechanism

@becvert
Copy link
Author

becvert commented Nov 20, 2023

npm might not be running the post_install script if the dependency target is local.

OK that was it.
I use a cordova base project just to fetch plugins I need. I then copy those to another destination. What I need to do is to add the modules preference in this base project too
Sorry for the inconvenience.
Thank you very much

@becvert becvert closed this as completed Nov 20, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants