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

chore: move normalize-import to scripts so we can reuse it for new dx migration tool #18401

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type": "none",
"comment": "chore: move normalize-import to scripts so we can reuse it for new dx migration setup",
"packageName": "@fluentui/react-menu",
"email": "[email protected]",
"dependentChangeType": "none"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type": "none",
"comment": "fix(react-utilities): explicitly provide context for setTimeout call",
"packageName": "@fluentui/react-utilities",
"email": "[email protected]",
"dependentChangeType": "none"
}
2 changes: 1 addition & 1 deletion packages/react-menu/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"license": "MIT",
"scripts": {
"docs": "api-extractor run --config=config/api-extractor.local.json --local",
"build:local": "tsc -p . --module esnext --emitDeclarationOnly && node config/normalize-import --output dist/react-menu/src && yarn docs",
"build:local": "tsc -p . --module esnext --emitDeclarationOnly && node ../../scripts/typescript/normalize-import --output dist/react-menu/src && yarn docs",
"build": "just-scripts build",
"clean": "just-scripts clean",
"code-style": "just-scripts code-style",
Expand Down
2 changes: 1 addition & 1 deletion packages/react-utilities/src/hooks/useOnClickOutside.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ export const useOnClickOutside = (options: UseOnClickOrScrollOutsideOptions) =>
}

// Garbage collect this event after it's no longer useful to avoid memory leaks
timeoutId.current = setTimeout(() => {
timeoutId.current = window.setTimeout(() => {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

without being explicit regarding from what global context are we accessing props TS will fail (basically local api-extractor build for react-menu was broken because of this)

Copy link
Member

Choose a reason for hiding this comment

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

please use the canUseDom utility, otherwise this will crash during SSR.

cc @layershifter

Copy link
Contributor Author

@Hotell Hotell Jun 1, 2021

Choose a reason for hiding this comment

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

do we need to use that in this PR ? there are multiple other occurrences in other projects which are using window

canUseDom

where does it live ?

Copy link
Member

Choose a reason for hiding this comment

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

kudos to @layershifter for looking into this specifically and finding out that at least for Next.js window and document usages seem to not throw (??!!??)

It might still be better to be explicit about the SSR case. the utility function I mentioned in the same package:

https://github.com/microsoft/fluentui/blob/master/packages/react-utilities/src/ssr/canUseDOM.ts

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I just realised, all of this is happening within useEffect which AFAIR is not executed when SSR, thus I'd leave it as is and do the necessary changes in other PR. there are other uses of window directly within this file.

2021-06-02 at 12 31

Are we ok with this ? thx

currentEvent = undefined;
}, 1);

Expand Down
3 changes: 2 additions & 1 deletion scripts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@
"build": "echo no-op",
"bundlesize": "bundlesize --debug",
"clean": "",
"code-style": "node ./just-scripts.js code-style"
"code-style": "node ./just-scripts.js code-style",
"test": "jest"
},
"dependencies": {
"@babel/core": "^7.10.4",
Expand Down