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(v2): TypeScript, use isolatedModules #4790

Merged
merged 4 commits into from
May 14, 2021
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
3 changes: 3 additions & 0 deletions admin/verdaccio.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,6 @@ packages:
# Log settings
logs:
- {type: stdout, format: pretty, level: http}

# Fix 413 errors in e2e CI
max_body_size: 1000mb
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
*/

import {useLocation} from '@docusaurus/router';
import {
useAllPluginInstancesData,
import useGlobalData, {
// useAllPluginInstancesData,
usePluginData,
} from '@docusaurus/useGlobalData';

Expand All @@ -24,8 +24,11 @@ import {
GetActivePluginOptions,
} from '../../client/docsClientUtils';

// Not using useAllPluginInstancesData() because in blog-only mode, docs hooks are still used by the theme
// We need a fail-safe fallback when the docs plugin is not in use
export const useAllDocsData = (): Record<string, GlobalPluginData> =>
useAllPluginInstancesData('docusaurus-plugin-content-docs');
// useAllPluginInstancesData('docusaurus-plugin-content-docs');
useGlobalData()['docusaurus-plugin-content-docs'] ?? {};

export const useDocsData = (pluginId: string | undefined): GlobalPluginData =>
usePluginData('docusaurus-plugin-content-docs', pluginId) as GlobalPluginData;
Expand Down
28 changes: 4 additions & 24 deletions packages/docusaurus-theme-classic/src/theme/hooks/useDocs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,27 +5,7 @@
* LICENSE file in the root directory of this source tree.
*/

// See https://github.com/facebook/docusaurus/issues/3360
// TODO find a better solution, this shouldn't be needed

// TODO this is not ideal and produce a warning!
// see https://github.com/webpack/webpack/issues/7713#issuecomment-467888437
// note: warning can be filtered: https://github.com/facebook/docusaurus/pull/3382#issuecomment-684966924
try {
// eslint-disable-next-line global-require
module.exports = require('@theme-init/hooks/useDocs');
} catch (e) {
// In case the docs plugin is not available, might be useful to stub some methods here
// https://github.com/facebook/docusaurus/issues/3947
const Empty = {};
module.exports = {
useAllDocsData: () => Empty,
useActivePluginAndVersion: () => undefined,
};
}

/*
throw new Error(
"The docs plugin is not used, so you can't require the useDocs hooks. ",
);
*/
// Re-expose useDocs
// Ensure it's always statically available even if user is not using the docs plugin
// Problem reported for the blog-only mode: https://github.com/facebook/docusaurus/issues/3360
export * from '@docusaurus/plugin-content-docs/lib/theme/hooks/useDocs';
5 changes: 3 additions & 2 deletions packages/docusaurus-theme-common/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@
* LICENSE file in the root directory of this source tree.
*/

export {
useThemeConfig,
export {useThemeConfig} from './utils/useThemeConfig';

export type {
ThemeConfig,
Navbar,
NavbarItem,
Expand Down
1 change: 1 addition & 0 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
"moduleResolution": "node",
"allowSyntheticDefaultImports": true,
"esModuleInterop": true,
"isolatedModules": true,

/* Advanced Options */
"resolveJsonModule": true,
Expand Down