Skip to content
Advertisement

Integrating npm module into a plain Javascript app, don’t know how to fix error

I apologize, my lack of knowledge of how to build modern Javascript apps is showing.

We have a Capacitor app that uses plain Javascript, without any build tools. This works fine. We’re trying to add Microsoft Code Push support, via https://github.com/mapiacompany/capacitor-codepush, and we’re running into a problem with how to integrate it into our app.

For Capacitor and its plugins, we use tags to include the plugin.js files from the various node_modules/…/dist directories.

If we do this with node_modules/capacitor-codepush/dist/plugin.js, we get an error about missing acquisitionSdk. Including node_modules/code-push/script/acquisition-sdk.js doesn’t help.

Ok, so maybe there are a bunch of dependencies? We tried using rollup to see if we could get that to work, but cannot. Using this simple input file:

import { codePush } from 'capacitor-codepush';

console.log("hello");

we get [!] Error: Invalid value "iife" for option "output.format" - UMD and IIFE output formats are not supported for code-splitting builds.

Any help would be appreciated.

Advertisement

Answer

The only way I was able to get it working was to switch to using webpack. For reasons I don’t understand, my initial attempts using rollup did not work. webpack was the key.

User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement