netlify dev supports import() but building on Netlify doesn't
See original GitHub issueDescribe 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.
Issue Analytics
- State:
- Created 2 years ago
- Comments:5 (1 by maintainers)
Top Results From Across the Web
Netlify dev failing with "Cannot use import statement outside a ...
I'm new to your platform, but I've been using vercel for awhile, and haven't had any problems deploying on their site. I'm unable...
Read more >[Support Guide] Netlify app builds locally but fails on deploy ...
I'm having issues with one of my sites. The build seems to be failing on an import line in one of my JS...
Read more >Edge Functions netlify:edge include Doesn't Resolve Locally
The import from “netlify:edge” doesn't resolve locally. It does work with the Netlify CLI locally. But since one of the points of Typescript ......
Read more >How do I import the Context type for local development with ...
json({ hello: "world" }); }; The import from “netlify:edge” doesn't resolve locally. It does work with the Netlify CLI locally. But since one...
Read more >Sveltekit deployment doesn't seem to work - Support
My netlify site name: mellifluous-cranachan-5857d5.netlify.app Build problems? Link or paste the FULL build log & build settings screenshot ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

Hi @eduardoboucas , sounds great, I’ll send that over now. Thanks!
Possibly related #1036