Capacitor v7.0.1
package.json dependencies
“@capacitor/cli”: “7.0.1”,
“@rollup/plugin-commonjs”: “^28.0.3”,
“@rollup/plugin-json”: “^6.1.0”,
“@rollup/plugin-node-resolve”: “^16.0.0”,
“@rollup/plugin-terser”: “^0.4.4”,
“@capacitor/android”: “^7.0.1”,
“@capacitor/app”: “^7.0.0”,
“@capacitor/core”: “^7.0.1”,
“@capacitor/ios”: “^7.0.1”,
“@rollup/plugin-replace”: “^6.0.2”,
“npm”: “^11.2.0”,
“rollup”: “^4.21.0”,
“rollup-plugin-copy”: “^3.5.0”,
“rollup-plugin-minify”: “^1.0.3”,
“rollup-plugin-node-builtins”: “^2.0.0”,
“rollup-plugin-url-resolve”: “^0.2.0”,
Problem:
Adding @capacitor/core works as expected, running a Android build will push to an android device and run correctly, however when adding @capacitor/app the following warning when built and deployed to an android device is shown:
“TypeError: Failed to resolve module specifier “@capacitor/core”. Relative references must start with either “/”, “./”, or “../”.”
Rollup:
The following below is the output for the build for mobile. Using relative paths were required due to Rollup’s ‘node-resolve’ not actually resolving anything when run. This works for @capacitor/core but @capacitor/app has issues primarily due to it’s internal reference to core, that it is unable to resolve.
output: {
paths: {
‘@capacitor/core’ : ‘../../../node_modules/@capacitor/core/dist/index.js’,
‘@capacitor/app’: ‘../../../node_modules/@capacitor/app/dist/esm/index.js’
},
file: dist,
format: ‘es’,
}
}
Build file:
The following output below from the output from Rollup.js is correct:
import{Capacitor as e}from"../../../node_modules/@capacitor/core/dist/index.js";import{App as t}from"../../../node_modules/@capacitor/app/dist/esm/index.js";
The imported files exist and are accessible, however Capacitor throws the same error above stating:
“TypeError: Failed to resolve module specifier “@capacitor/core”. Relative references must start with either “/”, “./”, or “../”.” and this is from @Capacitor/App
What specifically is causing this hangup with Capacitor that it won’t respect the path to it’s associated files? Do we only need to call Capacitor instead of App, do we need to include both, the example I saw did not show adding Capacitor, only App so there’s some confusion there as well.