Skip to content
This repository has been archived by the owner on Oct 7, 2024. It is now read-only.

Capacitor: running @nxext/capacitor:cap sync causes prepare script of installed capacitor plugins to trigger #4

Open
pct-cclausen opened this issue Oct 18, 2023 · 0 comments
Labels
bug Something isn't working

Comments

@pct-cclausen
Copy link

Describe the bug
We are using @nxext/capacitor 16.3.0
We have installed https://github.com/capacitor-community/file-opener
This capacitor plugin has a prepare step in its package scripts, which causes:

  • a build
  • which causes a clean
  • which causes the deletion of the dist directory in node_modules/@capacitor-community/file-opener
  • the build of that lib at least in this situation does not re-build the dist directory, it is just gone after this

So running sync effectively causes the file-opener plugin to self-destruct.

To Reproduce
I suspect this is due to our project level package.json usage with relative paths to the global node_modules:

So in the package.json in apps/, we insert capacitor plugins like this:

"@capacitor-community/file-opener": "../../node_modules/@capacitor-community/file-opener"

And in our global package.json in the nx workspace we include the plugin with the version we want.
We've done this to prevent duplicate version definitions and not having to deal with project level package definitions/installations.
I think this is also why we have never had this issue: #6
Maybe we ended up doing this because of that issue, I do not remember.

This relative link setup works great for 15 other capacitor plugins already and now that prepare step in file-opener breaks it.

If I instead just put the version in the project level file this bug goes away, but obviously that can cause that issue 978 and is just not very pretty in general, having an extra project level installed lib just for this one case.

Expected behavior
@nxext/capacitor should not causes the prepare step to trigger. I guess it calls that step because it tries to npm install the project level dependencies? Maybe there could be an option to skip that entirely? At least there is nothing really it needs to npm install in our setup, that is handled by the global node_modules

I'll also report this in file-opener, as it seems to be a bit of a unicorn with having a prepare step, many other capacitor plugins do not have it and work fine for our setup.

@pct-cclausen pct-cclausen added the bug Something isn't working label Oct 18, 2023
@DominikPieper DominikPieper transferred this issue from nxext/nx-extensions Oct 23, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant