dayjs.extend() and dayjs.locale() result in an error when dayjs is imported from ESM bundle
- Dominant language
- JavaScript
- Stars
- 48.7k
- Forks
- 2.8k
- PR merge metrics
- No merged PRs in 30d
Description
**Describe the bug**
Extending with plugins and setting locale doesn't seem to work when using ESM bundle.
Following code produces following errors when used in Angular Typescript project.
```ts
import * as dayjs from 'dayjs/esm';
import 'dayjs/esm/locale/en-gb';
import * as customParseFormat from 'dayjs/esm/plugin/customParseFormat';
dayjs.locale('en-gb');
dayjs.extend(customParseFormat);
```
```
"export 'extend' (imported as 'dayjs') was not found in 'dayjs/esm'
"export 'locale' (imported as 'dayjs') was not found in 'dayjs/esm'
```
The code above works fine when importing directly from `dayjs` instead of `dayjs/esm`.
**Information**
- Day.js Version 1.9.6
- Angular v10
Contributor guide
Research direction
Reproduce the Angular v10 TypeScript example using the dayjs/esm entry point, the en-gb locale, and the customParseFormat plugin. Inspect the ESM bundle exports first; done means dayjs.locale() and dayjs.extend() work without the reported missing-export errors, while the regular dayjs import remains unaffected.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- angular, javascript, typescript
- Domain
- build-system
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100