[Capacitor 3] Custom plugin doesn't have dist folder after installation

Hi,

I migrated my app and a custom plugin to Capacitor 3 and facing one last problem.
When installing the custom plugin from gitlab with:

npm install gitlab:path-to-plugin-at-gitlab

the plugin is added to the node_modules folder.

custom-plugin-name
-android
-ios
-package.json
-CustomPlugin.podspec
-Readme.md

The problem is that there is no dist folder which contains the interface for the methods signatures, …
The dist folder should be created when running npm install or am I wrong?

In the plugin dev folder the dist folder exists after running the build and is listed on the .gitignore but I think that’s ok or should it be comitted to the repo?
I also migrated the rollup.config.js that it looks the same like at the official plugins (excepted the plugin name)

Hope you could help me. Thanks in advance!

Max

if you want to install from github you’ll have to commit the dist folder or add a postinstall script in your plugin that runs npm run build (not 100% sure this will work)

2 Likes

This makes sense, but for example the Capacitor 3 Status-Bar plugin has neither the dist-folder in the repo nor a postinstall script in its package.json
How does it work for this plugin?

You can’t install any of the official plugins from GitHub, not only because of dist not being committed, but because it’s a monorepo and installing from GitHub only works if the package.json is at the root.

We publish the plugins in npm and the publish script runs build command and build folder is in the files object of the package.json so it’s sent to npm.

3 Likes

Makes also sense. I added a postinstall script which simply runs tsc but this already fails because the app is dependant of the plugin and the compiler throws someting like a dependency missing error.

Any idea how to fix this?

but did you add the postinstall script in your app or in the plugin?
it should be in the plugin

I’ve tried in a sample plugin and seems to work, but if it doesn’t work for you, then try committing dist folder

1 Like

I added it to the plugin. When running tsc directly in the plugin (dev folder) it works properly, when installing it from git/gitlab (node_modules) it doesn’t.

Hey there, did you happen to resolve this? I’m running into the same issue.

  • Tried commiting the dist folder but our docker build server still doesnt recognize it
  • Our build server can’t resolve its type declarations

Did you get this to work?

307: Cannot find module 'capacitor-plugin-crisp' or its corresponding type declarations.

#24 111.0 @xxx/react: Child html-webpack-plugin for "index.html":

Just add “prepare”: “npm run build” to your scripts part of your package.json