Skip to content

Locale Default Imports Resolving Incorrectly with Vite 8 #704

@zokioki

Description

@zokioki

Hello, and thank you for your work on this library 👋

There appears to be an issue with importing locales as documented when using this library with the latest Vite 8 setup. For example, the following would result in the default ru locale being used even though the en locale is explicitly specified:

import AirDatepicker from 'air-datepicker';
import localeEn from 'air-datepicker/locale/en';

new AirDatepicker('#el', {
  locale: localeEn
});

The locale import seems to be resolving with the entire module.exports object rather than the default value, so a workaround of using localeEn.default in the above example addresses the issue.

A reproduction with a basic Vite 8 setup can be found here:
https://stackblitz.com/edit/vitejs-vite-hqegby8b?file=src%2Fmain.js

It looks like Vite 8 introduced consistent CommonJS interop handling via Rolldown which appears to affect this library, see:

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions