Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Add type module in package.json #2230

Merged
merged 13 commits into from
Jun 28, 2024
Merged

Conversation

ArthurGoupil
Copy link
Contributor

Description

There is a missing type: module in package.json making jest be lost when trying to use esm/cjs.

Capture d’écran 2024-06-24 à 16 29 39

Type of Change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update

Checklist

Before submitting your pull request, please make sure the following is done:

  • I have read the CONTRIBUTING doc
  • / I have added tests that prove my fix is effective or that my feature works
  • / I have added necessary documentation (if appropriate)
  • I have followed the coding guidelines in this project
  • I have tested my changes on different browsers and screen sizes

Linked Issues

No posted issue

Test Plan

Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration.

Screenshots (if appropriate)

Include screenshots or GIFs if relevant. This is especially important for UI-related changes.

Further Comments

If you have any additional comments or questions, please add them here.

@ArthurGoupil ArthurGoupil changed the title [FIX] Add type module in package.json fix: Add type module in package.json Jun 24, 2024
@gpbl
Copy link
Owner

gpbl commented Jun 26, 2024

Thanks! Now is docusaurus (so, webpack) to fail with:

Module not found: Error: Can't resolve './' in '/home/runner/work/react-day-picker/react-day-picker/dist/esm'
Did you mean 'index.js'?
BREAKING CHANGE: The request './' failed to resolve only because it was resolved as fully specified
(probably because the origin is strict EcmaScript Module, e. g. a module with javascript mimetype, a '*.mjs' file, or a '*.js' file where the package.json contains '"type": "module"').
The extension in the request is mandatory for it to be fully specified.

My understanding is that we need to update also the import statements to use index.js and the file extensions. How do we do this with the TypeScript compiler?

@guillaumewuip
Copy link

guillaumewuip commented Jun 27, 2024

Hello there! Jumping on this to help unlock this esm/cmjs issue.

What's the issue exactly here?

  1. we're bundling the code with raw tsc (tsc --project tsconfig-esm.json)
  2. with the current tsconfig.json config, we're not forcing the import/export paths to be fully specified (ie. my/path/index.js instead of my/path).
  3. tsc as no ability to transform the path in to fully specified version at build time (see for example this issue)
  4. so files in the dist/esm output dir don't have fully specified import/export paths, and this is an issue for tools that want to leverage strict ESM imports (here: docusaurus)
  5. with "type": "module", tools that can leverage ESM are more likely to do so. For example docusaurus is now trying to import the ESM files.

See also https://dev.to/ayc0/typescript-50-new-mode-bundler-esm-1jic

In the ECMAScript spec, they mention that imports need to have a file extension, so import { foo } from './foo'; is not valid (see in Node.js’s doc).

How to fix?

We need to output esm files that have fully specified imports. I think we have two options:

  1. make all paths fully specified

    Here we need to transform lines like import "./my/path/" into import "./my/path/index.js" in all source files (note the .jseven in.ts` source files.

  2. add a bundler to do this fully specified transformation for us, for example rollup

    No change to do on the source files. We will let the bundler do this for us.

Are you opened in adding a bundler like rollup to output common js and esm files @gpbl? We can propose a PR for that with @ArthurGoupil

@gpbl
Copy link
Owner

gpbl commented Jun 27, 2024

Hi @guillaumewuip, thanks for the suggestions!

I really prefer adding the extension to the import rather than introducing rollup.js again. There should be an extension for eslint as well.

@guillaumewuip
Copy link

Ok, so the next steps is to update this PR by updating each import lines, right?

Basically @ArthurGoupil :

-import {} from './toto'
+import {} from './toto.js'
-import {} from './tata'
+import {} from './tata/index.js'

@gpbl
Copy link
Owner

gpbl commented Jun 27, 2024

Ok, so the next steps is to update this PR by updating each import lines, right?

Yes - that should work for everyone.

@ArthurGoupil
Copy link
Contributor Author

@gpbl I think there is a blocker here, looks like your testing environment doesn't accept the explicit .js imports

@gpbl
Copy link
Owner

gpbl commented Jun 27, 2024

@ArthurGoupil thanks for looking at it , and sorry for the hassle. Will check it out asap.

@gpbl
Copy link
Owner

gpbl commented Jun 28, 2024

@ArthurGoupil it looks like now it pass 🎉

How to add a test to the build pipeline to avoid issues like these? 🤔

Could you maybe try to install main branch

npm install git+https://github.com/gpbl/react-day-picker.git

and confirm it works now for you? Thanks.

@gpbl gpbl merged commit d810ec8 into gpbl:main Jun 28, 2024
8 checks passed
gpbl added a commit that referenced this pull request Jun 28, 2024
gpbl added a commit that referenced this pull request Jun 28, 2024
@ArthurGoupil
Copy link
Contributor Author

Thanks for the updates @gpbl !
I'll test shortly and tell you if I still have issues. But it should be alright now.

@ArthurGoupil
Copy link
Contributor Author

It's working now @gpbl, do you have any idea when you'll release this?
Thanks !

Brooooooklyn referenced this pull request in toeverything/AFFiNE Sep 3, 2024
This PR contains the following updates:

| Package | Change | Age | Adoption | Passing | Confidence |
|---|---|---|---|---|---|
| [react-day-picker](https://daypicker.dev) ([source](https://redirect.github.com/gpbl/react-day-picker)) | [`^8.10.1` -> `^9.0.0`](https://renovatebot.com/diffs/npm/react-day-picker/8.10.1/9.0.8) | [![age](https://developer.mend.io/api/mc/badges/age/npm/react-day-picker/9.0.8?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![adoption](https://developer.mend.io/api/mc/badges/adoption/npm/react-day-picker/9.0.8?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![passing](https://developer.mend.io/api/mc/badges/compatibility/npm/react-day-picker/8.10.1/9.0.8?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![confidence](https://developer.mend.io/api/mc/badges/confidence/npm/react-day-picker/8.10.1/9.0.8?slim=true)](https://docs.renovatebot.com/merge-confidence/) |

---

### Release Notes

<details>
<summary>gpbl/react-day-picker (react-day-picker)</summary>

### [`v9.0.8`](https://redirect.github.com/gpbl/react-day-picker/releases/tag/v9.0.8)

[Compare Source](https://redirect.github.com/gpbl/react-day-picker/compare/v9.0.7...v9.0.8)

This release fixes a regression in v9.0.7 affecting range mode.

#### What's Changed

-   fix: update the displayed month only if start/end month change by [@&#8203;gpbl](https://redirect.github.com/gpbl) in [https://github.com/gpbl/react-day-picker/pull/2358](https://redirect.github.com/gpbl/react-day-picker/pull/2358)

**Full Changelog**: gpbl/react-day-picker@v9.0.7...v9.0.8

### [`v9.0.7`](https://redirect.github.com/gpbl/react-day-picker/releases/tag/v9.0.7)

[Compare Source](https://redirect.github.com/gpbl/react-day-picker/compare/v9.0.6...v9.0.7)

This release improves compatibility with v8 and fix an issue with the calendar navigation.

#### What's Changed

-   fix: update calendar state when `startMonth` or `endMonth` change by [@&#8203;gpbl](https://redirect.github.com/gpbl) in [https://github.com/gpbl/react-day-picker/pull/2343](https://redirect.github.com/gpbl/react-day-picker/pull/2343)
-   feat: allow partial locales, export `defaultLocale` by [@&#8203;gpbl](https://redirect.github.com/gpbl) in [https://github.com/gpbl/react-day-picker/pull/2348](https://redirect.github.com/gpbl/react-day-picker/pull/2348)
-   feat: allow `undefined` as initially selected value, as it was in v8 by [@&#8203;gpbl](https://redirect.github.com/gpbl) in [https://github.com/gpbl/react-day-picker/pull/2341](https://redirect.github.com/gpbl/react-day-picker/pull/2341)
-   docs: changed class name `calendar` to  `root` in the examples by [@&#8203;gpbl](https://redirect.github.com/gpbl) in [https://github.com/gpbl/react-day-picker/pull/2347](https://redirect.github.com/gpbl/react-day-picker/pull/2347)
-   docs: replaced deprecated props by [@&#8203;josephmarkus](https://redirect.github.com/josephmarkus) in [https://github.com/gpbl/react-day-picker/pull/2336](https://redirect.github.com/gpbl/react-day-picker/pull/2336)\*

#### New Contributors

-   [@&#8203;josephmarkus](https://redirect.github.com/josephmarkus) made their first contribution in [https://github.com/gpbl/react-day-picker/pull/2336](https://redirect.github.com/gpbl/react-day-picker/pull/2336)

**Full Changelog**: gpbl/react-day-picker@v9.0.6...v9.0.7

### [`v9.0.6`](https://redirect.github.com/gpbl/react-day-picker/releases/tag/v9.0.6)

[Compare Source](https://redirect.github.com/gpbl/react-day-picker/compare/v9.0.5...v9.0.6)

This release addresses the failed import of the common-js module for some app builder and add new `data-` attributes to help the integration with Tailwind. Thanks for your feedback!

#### What's Changed

-   fix(build): add package.json to dist/cjs module by [@&#8203;gpbl](https://redirect.github.com/gpbl) in [https://github.com/gpbl/react-day-picker/pull/2330](https://redirect.github.com/gpbl/react-day-picker/pull/2330)
-   feat: add new data-attributes to the day cells by [@&#8203;gpbl](https://redirect.github.com/gpbl) in [https://github.com/gpbl/react-day-picker/pull/2331](https://redirect.github.com/gpbl/react-day-picker/pull/2331)

#### New Contributors

-   [@&#8203;lesleh](https://redirect.github.com/lesleh) made their first contribution in [https://github.com/gpbl/react-day-picker/pull/2329](https://redirect.github.com/gpbl/react-day-picker/pull/2329)

**Full Changelog**: gpbl/react-day-picker@v9.0.5...v9.0.6

### [`v9.0.5`](https://redirect.github.com/gpbl/react-day-picker/releases/tag/v9.0.5)

[Compare Source](https://redirect.github.com/gpbl/react-day-picker/compare/v9.0.4...v9.0.5)

This release improves the range mode behavior (see the [updated docs](https://daypicker.dev/docs/selection-modes#range-mode)) and address some styling issues.

#### What's Changed

-   fix: improved range mode to work with min / required props by [@&#8203;gpbl](https://redirect.github.com/gpbl) in [https://github.com/gpbl/react-day-picker/pull/2326](https://redirect.github.com/gpbl/react-day-picker/pull/2326)
-   fix(style): typo in css rdp-hidden module css breaking CSS builds by [@&#8203;ayuhito](https://redirect.github.com/ayuhito) in [https://github.com/gpbl/react-day-picker/pull/2307](https://redirect.github.com/gpbl/react-day-picker/pull/2307)
-   fix(style): borders grid are not collapsed by [@&#8203;gpbl](https://redirect.github.com/gpbl) in [https://github.com/gpbl/react-day-picker/pull/2323](https://redirect.github.com/gpbl/react-day-picker/pull/2323)
-   fix(style): week numbers are now centered by [@&#8203;gpbl](https://redirect.github.com/gpbl) in gpbl/react-day-picker@c919ad8

#### New Contributors

-   [@&#8203;ayuhito](https://redirect.github.com/ayuhito) made their first contribution in [https://github.com/gpbl/react-day-picker/pull/2307](https://redirect.github.com/gpbl/react-day-picker/pull/2307)
-   [@&#8203;rishabh-ink](https://redirect.github.com/rishabh-ink) made their first contribution in [https://github.com/gpbl/react-day-picker/pull/2311](https://redirect.github.com/gpbl/react-day-picker/pull/2311)

**Full Changelog**: gpbl/react-day-picker@v9.0.4...v9.0.5

### [`v9.0.4`](https://redirect.github.com/gpbl/react-day-picker/releases/tag/v9.0.4)

[Compare Source](https://redirect.github.com/gpbl/react-day-picker/compare/v9.0.3...v9.0.4)

This release fixes some bugs and improves compatibility with v8.10. Thanks for your feedback and patience! 🤖

#### What's Changed

-   fix(css): typo in `.rdp-range_end` by [@&#8203;AlessioDP](https://redirect.github.com/AlessioDP) in [https://github.com/gpbl/react-day-picker/pull/2298](https://redirect.github.com/gpbl/react-day-picker/pull/2298)
-   fix(css): dropdown is transparent in Windows OS by [@&#8203;gpbl](https://redirect.github.com/gpbl) in [https://github.com/gpbl/react-day-picker/pull/2300](https://redirect.github.com/gpbl/react-day-picker/pull/2300)
-   fix: `endMonth` date not working as expected by [@&#8203;gpbl](https://redirect.github.com/gpbl) in [https://github.com/gpbl/react-day-picker/pull/2301](https://redirect.github.com/gpbl/react-day-picker/pull/2301)
-   feat: added back `onDayMouseEnter` and `onDayMouseLeave` by [@&#8203;gpbl](https://redirect.github.com/gpbl) in [https://github.com/gpbl/react-day-picker/pull/2304](https://redirect.github.com/gpbl/react-day-picker/pull/2304)

#### New Contributors

-   [@&#8203;AlessioDP](https://redirect.github.com/AlessioDP) made their first contribution in [https://github.com/gpbl/react-day-picker/pull/2298](https://redirect.github.com/gpbl/react-day-picker/pull/2298)

**Full Changelog**: gpbl/react-day-picker@v9.0.3...v9.0.4

### [`v9.0.3`](https://redirect.github.com/gpbl/react-day-picker/releases/tag/v9.0.3)

[Compare Source](https://redirect.github.com/gpbl/react-day-picker/compare/v9.0.2...v9.0.3)

This release fixes two issues found with the grid style and the range mode.

#### What's Changed

-   fix: alignment of grid elements by [@&#8203;gpbl](https://redirect.github.com/gpbl) in [https://github.com/gpbl/react-day-picker/pull/2294](https://redirect.github.com/gpbl/react-day-picker/pull/2294)
-   fix: range mode not updating when selected prop changes by [@&#8203;gpbl](https://redirect.github.com/gpbl) in [https://github.com/gpbl/react-day-picker/pull/2295](https://redirect.github.com/gpbl/react-day-picker/pull/2295)

**Full Changelog**: gpbl/react-day-picker@v9.0.2...v9.0.3

### [`v9.0.2`](https://redirect.github.com/gpbl/react-day-picker/releases/tag/v9.0.2)

[Compare Source](https://redirect.github.com/gpbl/react-day-picker/compare/v9.0.1...v9.0.2)

This update improves backward compatibility with v8.10.1 for range selection mode.

#### What's Changed

-   feat: add `excludeDisabled` prop for range mode by [@&#8203;gpbl](https://redirect.github.com/gpbl) in [https://github.com/gpbl/react-day-picker/pull/2290](https://redirect.github.com/gpbl/react-day-picker/pull/2290)

**Full Changelog**: gpbl/react-day-picker@v9.0.1...v9.0.2

### [`v9.0.1`](https://redirect.github.com/gpbl/react-day-picker/releases/tag/v9.0.1)

[Compare Source](https://redirect.github.com/gpbl/react-day-picker/compare/v9.0.0...v9.0.1)

This update improves backward compatibility with v8.10.1.

#### What's Changed

-   fix: prop types not being correctly interpreted by TS by [@&#8203;gpbl](https://redirect.github.com/gpbl) in [https://github.com/gpbl/react-day-picker/pull/2283](https://redirect.github.com/gpbl/react-day-picker/pull/2283)
-   feat: add `DeprecatedUI` enum by [@&#8203;gpbl](https://redirect.github.com/gpbl) in [https://github.com/gpbl/react-day-picker/pull/2284](https://redirect.github.com/gpbl/react-day-picker/pull/2284)

**Full Changelog**: gpbl/react-day-picker@v9.0.0...v9.0.1

### [`v9.0.0`](https://redirect.github.com/gpbl/react-day-picker/releases/tag/v9.0.0)

[Compare Source](https://redirect.github.com/gpbl/react-day-picker/compare/v8.10.1...v9.0.0)

DayPicker v9 is a major release including significant updates related to accessibility, customization and localization.

-   See the updated docs at https://daypicker.dev and the [upgrading Guide](https://daypicker.dev/upgrading) for more details.

##### Install the Latest Version

```bash
npm install react-day-picker@latest
```

#### What’s New

-   Moved `date-fns` from peer dependencies to dependencies.
-   Added support for [UTC dates](https://daypicker.dev/docs/localization#utc-dates) and [Jalali Calendar](https://daypicker.dev/docs/localization#jalali-calendar).
-   [Enhanced accessibility](https://daypicker.dev/docs/accessibility) to better comply with [WCAG 2.1](https://www.w3.org/TR/WCAG21/) recommendations.
-   [Simplified styles](https://daypicker.dev/docs/styling) and new CSS variables for easier customization.
-   Improved selection logic for [range mode](https://daypicker.dev/docs/selection-modes.mdx).
-   New `dropdown-years` and `dropdown-months` caption layouts.
-   New `hideWeekdayRow` and `hideNavigation` props.
-   Updated for a complete [custom components](https://daypicker.dev/guides/custom-components) support.
-   Improved typings and props for better compatibility in TypeScript `strict` mode.

#### Breaking Changes

While we tried to keep the API as stable as possible, some breaking changes were necessary to improve the library:

-   The updated ARIA labels could require new translations or updated unit tests selectors.
-   Custom CSS styles will likely break, due to the updated CSS classes and simplified styles.
-   Custom Components have new API and may break.
-   Some typings have been renamed or deprecated.
-   The `useInput` hook has been removed. See [Input fields](https://daypicker.dev/guides/input-fields) guide for more details.
-   `onWeekNumberClick` has been removed. Use a custom component to handle week number clicks.
-   The updated build system to ESM and CommonJS could break some custom bundler.

##### Upgrading Guide

We prepared a [Upgrading guide](https://daypicker.dev/upgrading) for help upgrading your app to v9. We welcome [feedback](https://redirect.github.com/gpbl/react-day-picker/discussions) about the upgrade process, to ensure it's smooth for everyone.

#### Compatibility

DayPicker v9 is compatible with React 16.8+.

#### Get Support and Report Issues

Get support, report issues, and provide feedback on the [Discussion forums](https://redirect.github.com/gpbl/react-day-picker/discussions). Thanks.

#### New Contributors

-   [@&#8203;grzegorzpokorski](https://redirect.github.com/grzegorzpokorski) made their first contribution in [https://github.com/gpbl/react-day-picker/pull/2124](https://redirect.github.com/gpbl/react-day-picker/pull/2124)
-   [@&#8203;zaaakher](https://redirect.github.com/zaaakher) made their first contribution in [https://github.com/gpbl/react-day-picker/pull/2137](https://redirect.github.com/gpbl/react-day-picker/pull/2137)
-   [@&#8203;ArthurGoupil](https://redirect.github.com/ArthurGoupil) made their first contribution in [https://github.com/gpbl/react-day-picker/pull/2230](https://redirect.github.com/gpbl/react-day-picker/pull/2230)
-   [@&#8203;johnnysedh3lllo](https://redirect.github.com/johnnysedh3lllo) made their first contribution in [https://github.com/gpbl/react-day-picker/pull/2252](https://redirect.github.com/gpbl/react-day-picker/pull/2252)
-   [@&#8203;xardit](https://redirect.github.com/xardit) made their first contribution in [https://github.com/gpbl/react-day-picker/pull/2254](https://redirect.github.com/gpbl/react-day-picker/pull/2254)
-   [@&#8203;dave-meyer](https://redirect.github.com/dave-meyer) made their first contribution in [https://github.com/gpbl/react-day-picker/pull/2231](https://redirect.github.com/gpbl/react-day-picker/pull/2231)
-   [@&#8203;benasher44](https://redirect.github.com/benasher44) made their first contribution in [https://github.com/gpbl/react-day-picker/pull/2249](https://redirect.github.com/gpbl/react-day-picker/pull/2249)
-   [@&#8203;RyanCavanaugh](https://redirect.github.com/RyanCavanaugh) made their first contribution in [https://github.com/gpbl/react-day-picker/pull/2275](https://redirect.github.com/gpbl/react-day-picker/pull/2275)
-   [@&#8203;kesoji](https://redirect.github.com/kesoji) made their first contribution in [https://github.com/gpbl/react-day-picker/pull/2281](https://redirect.github.com/gpbl/react-day-picker/pull/2281)

</details>

---

### Configuration

📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined).

🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied.

♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about this update again.

---

 - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box

---

This PR was generated by [Mend Renovate](https://mend.io/renovate/). View the [repository job log](https://developer.mend.io/github/toeverything/AFFiNE).
<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNy40MzEuNCIsInVwZGF0ZWRJblZlciI6IjM4LjU5LjIiLCJ0YXJnZXRCcmFuY2giOiJjYW5hcnkiLCJsYWJlbHMiOlsiZGVwZW5kZW5jaWVzIl19-->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants