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

Update dependencies #575

Merged
merged 17 commits into from
Oct 25, 2021
Merged

Update dependencies #575

merged 17 commits into from
Oct 25, 2021

Conversation

eemeli
Copy link
Member

@eemeli eemeli commented Sep 14, 2021

This updates almost all of the project's dependencies, including the following major dev dependency updates:

  • rollup v1 → v2
  • typedoc v0.20 → v0.22
  • typescript v4.2 → v4.4
  • sinon v4 → v11 (fluent-bundle)
  • jsdom v15 → v17 (fluent-dom)
  • jest v24 → v27 (fluent-react)
  • react v16 → v17 (fluent-react)

Some of those require a few changes in code; these are also applied. The following externally visible changes are made:

  • The updated typedoc's default theme uses dark mode if that's the user's preference; this can be toggled at the bottom of the page.
  • fluent-bundle: the type of caught errors is validated at runtime
  • fluent-react: prop-types is dropped as a dependency

The version of commander that's used in tools/ is not updated here, as the distance in its updates (v2 → v8) is so great, and the tools aren't covered by any tests.

Copy link
Member

@gregtatum gregtatum left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The upgrades all look reasonable to me, but I found an issue I would like to push back on before approving. I'm concerned about the removal of PropTypes from fluent-react, so I'm marking this as "Request changes".

fluent-bundle/src/bundle.ts Show resolved Hide resolved
fluent-react/package.json Show resolved Hide resolved
props.children
);
}

LocalizationProvider.propTypes = {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Question: Is this a behavior change for our users? Not everyone uses TypeScript, and this could provide valuable runtime checks if users are relying on the added safety here.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The prop-types methods are effectively no-ops in production, so I don't think that this should be considered a change in behaviour. It's removed here because issues like facebook/prop-types#354 make it difficult to support react@17 while keeping it as a dependency.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would somewhat disagree with the change in behavior, as it's still used in development mode. However, I won't block on this change if you feel the dependency management is too complex.

@@ -25,18 +25,4 @@ describe("LocalizationProvider - validation", () => {
);
expect(renderer.toJSON()).toMatchInlineSnapshot(`<div />`);
});

test("without a child", () => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggestion (blocking): I'm nervous about this change, since we can't do this with TypeScript type checks, but our users might. For instance in Firefox DevTools this is used without type checks.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This PR drops two tests. They expected these to throw:

<LocalizationProvider l10n={new ReactLocalization([])} />
<LocalizationProvider />

I don't think there's any actual benefit from throwing for these, and doing so is in fact surprising. A LocalizationProvider is a Context.Provider, which normally does not require its children to be non-empty. It just does nothing in that case.

The second checks that the l10n prop is defined. This will continue to throw in actual use, as the users of the context get its value with the TS type ReactLocalization | null, and handle the latter by throwing. This is already effectively checked by tests in fluent-react/test/localized_valid.test.js.

@gregtatum Would you like me to add a more specific test to the Localized test suite covering the missing-prop case?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think there is some value in exercising these code paths as users of this package could do surprising things with it. Without the throws, I'm less opinionated if the tests stay or if they go.

@@ -13,3 +13,6 @@ Object.keys(document.defaultView).forEach(property => {
global.navigator = {
userAgent: 'node.js'
};

// silence console logging during tests
console.warn = () => {}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggestion: I don't think this is a good change. It would be better to add suppressions per-test. This is a global change for every test, and it could be very surprising as to why this function doesn't work. I generally treat console as a public API, and one that should be handled explicitly, and asserted in tests.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, will change. I'll bump up sinon to the root package.json and use that in these tests as well.

fluent-bundle/package.json Outdated Show resolved Hide resolved
Copy link
Member

@gregtatum gregtatum left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Marking as approved since we talked through my blocking comments. Feel free to re-request if you want me to look at the sinon changes, or feel free to merge without me looking at that.

@eemeli eemeli merged commit 35c4560 into projectfluent:master Oct 25, 2021
@eemeli eemeli deleted the update-deps branch October 25, 2021 08:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants