-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: refactor Webpack contexts in Fluent docs to improve treeshaking (
#14843) * chore: refactor Webpack contexts in Fluent docs to improve treeshaking * one more chunk * fix HMR for examples * fix lint issue
- Loading branch information
1 parent
4551771
commit 006119f
Showing
16 changed files
with
80 additions
and
84 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 2 additions & 1 deletion
3
...ages/fluentui/docs/src/components/ComponentDoc/ComponentSourceManager/getExampleModule.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 4 additions & 0 deletions
4
packages/fluentui/docs/src/contexts/exampleBestPracticesContext.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
/** | ||
* The Webpack Context for doc site example groups. | ||
*/ | ||
export const exampleBestPracticesContext = require.context('../examples/', true, /BestPractices.tsx$/); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
/** | ||
* The Webpack Context for doc site example groups. | ||
*/ | ||
export const exampleIndexContext = require.context('../examples/', true, /index.tsx$/); |
4 changes: 4 additions & 0 deletions
4
packages/fluentui/docs/src/contexts/examplePlaygroundContext.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
/** | ||
* The Webpack Context for component playgrounds. | ||
*/ | ||
export const examplePlaygroundContext = require.context('../examples/', true, /Playground.tsx$/); |
21 changes: 21 additions & 0 deletions
21
packages/fluentui/docs/src/contexts/exampleSourcesContext.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
/** | ||
* The Webpack Context for doc site example sources. | ||
*/ | ||
// It's required for a hot reload | ||
// eslint-disable-next-line import/no-mutable-exports | ||
export let exampleSourcesContext = require.context('../exampleSources/', true, /.source.json$/); | ||
|
||
// ---------------------------------------- | ||
// HMR | ||
// ---------------------------------------- | ||
|
||
if (__DEV__) { | ||
// When the application source code changes, re-render the whole thing. | ||
if (module.hot) { | ||
// We need this to catch cases unhandled by RHL | ||
// https://github.com/webpack/webpack/issues/834#issuecomment-76590576 | ||
module.hot.accept(exampleSourcesContext.id, () => { | ||
exampleSourcesContext = require.context('../exampleSources/', true, /.source.json$/); | ||
}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
/** | ||
* The Webpack Context for doc examples. | ||
*/ | ||
// It's required for a hot reload | ||
// eslint-disable-next-line import/no-mutable-exports | ||
export let examplesContext = require.context('../examples/', true, /(\w+Example(\w|\.)*|\w+.perf|\w+.bsize)\.tsx$/); | ||
|
||
// ---------------------------------------- | ||
// HMR | ||
// ---------------------------------------- | ||
|
||
if (__DEV__) { | ||
// When the application source code changes, re-render the whole thing. | ||
if (module.hot) { | ||
// We need this to catch cases unhandled by RHL | ||
// https://github.com/webpack/webpack/issues/834#issuecomment-76590576 | ||
module.hot.accept(examplesContext.id, () => { | ||
examplesContext = require.context('../examples/', true, /(\w+Example(\w|\.)*|\w+.perf|\w+.bsize)\.tsx$/); | ||
}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters