Skip to content
This repository was archived by the owner on May 22, 2024. It is now read-only.

netlify dev supports import() but building on Netlify doesn't #1025

@mjswensen

Description

@mjswensen

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:

  1. Write a Netlify function with a dynamic import
  2. Run netlify dev
  3. See that the function runs properly
  4. Deploy to Netlify
  5. 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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    type: bugcode to address defects in shipped code

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions