Change entrypoint code
Server components only support a CommonJS definition, whereas edge component requires the component to be written in ESM.
Edge assumes that the component entrypoint contains a default export of an object with associated key:value pairs.
Each key denotes a component function and each key’s value being the component function handler.
In terms of the server component, the key is the function name defined in the manifest.json
, and the value is the function in the component entry file to which module.exports
is set.
Server
module.exports = async ({ text }) => {
return `<h1 class="hello-world">Hello World! ${text} </h1>`;
};
Edge
export default {
// Assuming in the `manifest.json` the function name is "main"
async main({ text }) {
return `<h1 class="hello-world">Hello World! ${text} </h1>`;
},
};