Skip to content

Lodash import issue in v4 #9388

@sebastien-f

Description

@sebastien-f

Astro Info

Astro                    v4.0.3
Node                     v18.16.1
System                   Windows (x64)
Package Manager          npm
Output                   static
Adapter                  none
Integrations             @astrojs/react
                         @astrojs/tailwind

If this issue only occurs in one browser, which browser is a problem?

All browsers

Describe the Bug

Updated astro to v4, run the project, got an immediate error :

TypeError: __vite_ssr_import_0__.isObject is not a function

isObject being imported through

import { isObject } from "lodash";

I also tried to remove node_modules and package-lock and reinstalling, same result. Also tried a new project, same result. Then tried on stackblitz, same result.

I tried to add lodash to my astro.config.mjs as such :

export default defineConfig({
  integrations: [react(), tailwind()],
  vite: {
    ssr: {
      external: ["lodash"]
    }
  }
});

No idea if that's supposed to work as I never dwelved into vite before.

Of course lodash is properly referenced in my package.json file and present in node_modules.

{
  "dependencies": {
    "lodash": "^4.17.21",
   }
}

Also :

PS G:\fo> npm list lodash
[email protected] G:\fo
└── [email protected]

What's the expected result?

I expect it to work properly.

Link to Minimal Reproducible Example

https://stackblitz.com/edit/github-duffch?file=src%2Fcomponents%2FCard.astro

Participation

  • I am willing to submit a pull request for this issue.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions