@ParvathiSo1 The root cause of your issue is that browsers cannot directly resolve bare module specifiers like @apollo/client. Unlike Node.js, which has a built-in module resolution system that understands npm package names, browsers require either:
- Relative paths (./, ../)
- Absolute paths (/)
- URLs (https://...)
For Edge Delivery Services (EDS) projects, the best approach is to use a module bundler in your build process:
# Add bundling dependencies
npm install --save-dev rollup @rollup/plugin-node-resolve @rollup/plugin-commonjs
Then create a rollup configuration file (rollup.config.js
import resolve from '@rollup/plugin-node-resolve';
import commonjs from '@rollup/plugin-commonjs';
export default {
input: 'src/scripts.js',
output: {
file: 'scripts/scripts.js',
format: 'es'
},
plugins: [
resolve(),
commonjs()
]
};
Add a build script to your package.json:
"scripts": {
"build": "rollup -c",
"watch": "rollup -c -w"
}
Note that the "rollup.config.js" needs to be placed in your project root folder.