Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
## Summary Adding `dayjs` to `opensource`, as it's needed by the translation framework. ## Test plan Place `experimental.PagePresence` on the testbed, hover on avatar of users who haven't been present in a long time, check the tooltip has the right subtitle ## Old summary, before Josh moved us to ESM This is the second attempt at this. The first one was reverted (#7592) because it crashed at runtime. The original PR (#7473) had some `@ts-ignore` and was using `require`, which is why the build succeeded even though it should have not. `import * as dayjs from 'dayjs';` is a valid import according to `tsc`. But then `dayjs(date)` errors ``` Type originates at this import. A namespace-style import cannot be called or constructed, and will cause a failure at runtime. Consider using a default import or import require here instead ``` It also **crashes at runtime**. Changing it to `dayjs.default(date)` doesn't crash at runtime, but `tsc` now complains about it ``` Property 'default' does not exist on type 'typeof import("/Users/albert/monorepo/opensource/sdk-js/node_modules/dayjs/index.d.ts")' ``` `import dayjs from 'dayjs';` is **not** a valid import according to `tsc` ``` This module is declared with 'export =', and can only be used with a default import when using the 'esModuleInterop' flag. ``` But **actually works** (i.e. no runtime crash). Peeking into `dayjs` codebase, I see an [export default dayjs](https://github.com/iamkun/dayjs/blob/f0c9a41c6ec91528f3790e442b0c5dff15a4e640/src/index.js#L467C21-L467C21), which is ESM syntax, which I would expect to just be able to import (`import dayjs from 'dayjs';`). My IDE is not complaining, the code is not crashing at runtime, but `npm run tsc-once` is yelling at me. [There is a long-standing issue in DayJS regarding Node.js ESM](iamkun/dayjs#1765)) which might be related. But I'm still confused 😬 Test Plan: Use the experimental.PresenceFacepile in the testbed, hover on an avatar, check the tooltip's subtitle is correct. Reviewers: Netceer, lazybean Reviewed By: lazybean Pull Request: getcord/monorepo#7750 monorepo-commit: 9ea55f11df0954eff1e344bcf12c1f9c2a474541
- Loading branch information