I'm running a small angular application, with capacitor enabled for ios/android, and everything worked fine until I import this plugin.
Context : I'm totally new to the capacitor/cordova development but I have a significant angular app running. I'm making a small test app with cordova edit: Capacitor to investigate the possibility to add capacitor & in-app purchases to build my app for native markets. I can't remove or disable some angular features like SSR, because they are critical for my application.
Observed behavior
When I'm in a .ts file, when I add any of those two imports :
import 'cordova-plugin-purchase';
import 'cordova-plugin-purchase/www/store'
I can't build my application anymore :
> ng build
An unhandled exception occurred: Cannot destructure property 'routes' of '(intermediate value)' as it is undefined.
See "/tmp/ng-hmbK49/angular-errors.log" for further details.
> cat /tmp/ng-hmbK49/angular-errors.log
[error] TypeError: Cannot destructure property 'routes' of '(intermediate value)' as it is undefined.
at getAllRoutes (/home/[...]/node_modules/@angular/build/src/utils/server-rendering/prerender.js:185:21)
at async prerenderPages (/home/[...]/node_modules/@angular/build/src/utils/server-rendering/prerender.js:52:84)
at async executePostBundleSteps (/home/[...]/node_modules/@angular/build/src/builders/application/execute-post-bundle.js:62:83)
at async executeBuild (/home/[...]/node_modules/@angular/build/src/builders/application/execute-build.js:115:24)
at async watch (/home/[...]/node_modules/@angular/build/src/builders/application/index.js:70:24)
at async Task.task [as taskFn] (/home/[...]/node_modules/@angular/build/src/tools/esbuild/utils.js:126:26)
at async Task.run (/home/[...]/node_modules/listr2/dist/index.cjs:2143:11)
(Removing this import allows the build to complete without errors)
Note : When using ng serve, the code compiles as expected.
Expected behavior
no errors during build
System Info
my (simplified) package.json :
{
"name": "XXX",
"version": "0.0.0",
"scripts": {
"ng": "ng",
"start": "ng serve",
"build": "ng build",
"watch": "ng build --watch --configuration development",
"test": "ng test",
"build-and-serve-android": "ng build --configuration development && npx cap sync && npx cap run android",
"build-and-serve-ios": "ng build --configuration development && npx cap sync && npx cap run ios"
},
"private": true,
"dependencies": {
"@angular/animations": "^18.2.0",
"@angular/common": "^18.2.0",
"@angular/compiler": "^18.2.0",
"@angular/core": "^18.2.0",
"@angular/forms": "^18.2.0",
"@angular/platform-browser": "^18.2.0",
"@angular/platform-browser-dynamic": "^18.2.0",
"@angular/platform-server": "^18.2.0",
"@angular/router": "^18.2.0",
"@angular/service-worker": "^18.2.0",
"@angular/ssr": "^18.2.5",
"@capacitor/android": "^6.1.2",
"@capacitor/angular": "^2.0.3",
"@capacitor/core": "latest",
"@capacitor/ios": "^6.1.2",
"cordova-plugin-purchase": "^13.11.1",
"express": "^4.18.2",
"rxjs": "~7.8.0",
"tslib": "^2.3.0",
"zone.js": "~0.14.10"
},
"devDependencies": {
"@angular-devkit/build-angular": "^18.2.5",
"@angular/cli": "^18.2.5",
"@angular/compiler-cli": "^18.2.0",
"@capacitor/cli": "latest",
"@types/express": "^4.17.17",
"@types/jasmine": "~5.1.0",
"@types/node": "^18.18.0",
"jasmine-core": "~5.2.0",
"karma": "~6.4.0",
"karma-chrome-launcher": "~3.2.0",
"karma-coverage": "~2.2.0",
"karma-jasmine": "~5.1.0",
"karma-jasmine-html-reporter": "~2.1.0",
"typescript": "~5.5.2"
}
}
Output of cordova info.
> cordova info
cordova: command not found
> node -v
v20.13.1
> npm -v
10.9.0
> ng --version
18.2.7
I'm running a small angular application, with capacitor enabled for ios/android, and everything worked fine until I import this plugin.
Context : I'm totally new to the capacitor/cordova development but I have a significant angular app running. I'm making a small test app with
cordovaedit: Capacitor to investigate the possibility to add capacitor & in-app purchases to build my app for native markets. I can't remove or disable some angular features like SSR, because they are critical for my application.Observed behavior
When I'm in a .ts file, when I add any of those two imports :
I can't build my application anymore :
(Removing this import allows the build to complete without errors)
Note : When using ng serve, the code compiles as expected.
Expected behavior
no errors during build
System Info
my (simplified) package.json :
Output of
cordova info.