Describe the bug
In development, the following code works as expected:
exports.handler = async function (event) {
const myValue = await import('my-package');
// ...
};
But when deploying to production, my-package doesn't get bundled, resulting in 500 errors when the function tries to run (Cannot find package 'my-package' imported from /var/task/my-function.js)
To Reproduce
Steps to reproduce the behavior:
- Write a Netlify function with a dynamic import
- Run
netlify dev
- See that the function runs properly
- Deploy to Netlify
- See that the deployed function doesn't run
Expected behavior
Either Netlify's production function bundling should support this case, or netlify dev should not. The behavior should match between the two.