diff --git a/packages/docusaurus-plugin-content-docs/package.json b/packages/docusaurus-plugin-content-docs/package.json index ef4f5ee27a0e..fe80c80e5038 100644 --- a/packages/docusaurus-plugin-content-docs/package.json +++ b/packages/docusaurus-plugin-content-docs/package.json @@ -3,6 +3,7 @@ "version": "2.0.0-beta.18", "description": "Docs plugin for Docusaurus.", "main": "lib/index.js", + "sideEffects": false, "exports": { "./client": "./lib/client/index.js", "./server": "./lib/server-export.js", diff --git a/packages/docusaurus-theme-classic/src/theme-classic.d.ts b/packages/docusaurus-theme-classic/src/theme-classic.d.ts index 08475210a920..ec5584897480 100644 --- a/packages/docusaurus-theme-classic/src/theme-classic.d.ts +++ b/packages/docusaurus-theme-classic/src/theme-classic.d.ts @@ -879,7 +879,7 @@ declare module '@theme/ThemedImage' { } declare module '@theme/Details' { - import {Details, type DetailsProps} from '@docusaurus/theme-common'; + import {Details, type DetailsProps} from '@docusaurus/theme-common/Details'; export interface Props extends DetailsProps {} export default Details; diff --git a/packages/docusaurus-theme-classic/src/theme/Details/index.tsx b/packages/docusaurus-theme-classic/src/theme/Details/index.tsx index 724863d73088..188729351494 100644 --- a/packages/docusaurus-theme-classic/src/theme/Details/index.tsx +++ b/packages/docusaurus-theme-classic/src/theme/Details/index.tsx @@ -7,7 +7,7 @@ import React from 'react'; import clsx from 'clsx'; -import {Details as DetailsGeneric} from '@docusaurus/theme-common'; +import {Details as DetailsGeneric} from '@docusaurus/theme-common/Details'; import type {Props} from '@theme/Details'; import styles from './styles.module.css'; diff --git a/packages/docusaurus-theme-common/Details.d.ts b/packages/docusaurus-theme-common/Details.d.ts new file mode 100644 index 000000000000..61dab97e7363 --- /dev/null +++ b/packages/docusaurus-theme-common/Details.d.ts @@ -0,0 +1,14 @@ +/** + * Copyright (c) Facebook, Inc. and its affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */ + +// `Details` is a separate export entry because of side-effects messing with CSS +// insertion order. See https://github.com/facebook/docusaurus/pull/7085. +// However, because TS doesn't recognize `exports` (also a problem in +// `content-docs`), we have to manually create a stub. + +// eslint-disable-next-line import/named +export {Details, type DetailsProps} from './lib/components/Details'; diff --git a/packages/docusaurus-theme-common/package.json b/packages/docusaurus-theme-common/package.json index 9c77f8eb95b9..23e0625a1e31 100644 --- a/packages/docusaurus-theme-common/package.json +++ b/packages/docusaurus-theme-common/package.json @@ -4,6 +4,14 @@ "description": "Common code for Docusaurus themes.", "main": "./lib/index.js", "types": "./lib/index.d.ts", + "sideEffects": [ + "lib/components/Details/*", + "*.css" + ], + "exports": { + ".": "./lib/index.js", + "./Details": "./lib/components/Details/index.js" + }, "scripts": { "build": "node copyUntypedFiles.mjs && tsc", "watch": "node copyUntypedFiles.mjs && tsc --watch" diff --git a/packages/docusaurus-theme-common/src/index.ts b/packages/docusaurus-theme-common/src/index.ts index 97b0de33a583..804de23703bb 100644 --- a/packages/docusaurus-theme-common/src/index.ts +++ b/packages/docusaurus-theme-common/src/index.ts @@ -63,8 +63,6 @@ export {useLocationChange} from './utils/useLocationChange'; export {useCollapsible, Collapsible} from './components/Collapsible'; -export {Details, type DetailsProps} from './components/Details'; - export { useDocsPreferredVersion, useDocsPreferredVersionByPluginId, diff --git a/packages/docusaurus-theme-common/tsconfig.json b/packages/docusaurus-theme-common/tsconfig.json index 074e3894b4d0..20c3d66f6411 100644 --- a/packages/docusaurus-theme-common/tsconfig.json +++ b/packages/docusaurus-theme-common/tsconfig.json @@ -8,5 +8,6 @@ "declarationMap": true, "rootDir": "src", "outDir": "lib" - } + }, + "include": ["src"] } diff --git a/packages/docusaurus-theme-live-codeblock/package.json b/packages/docusaurus-theme-live-codeblock/package.json index ffdcbb6ca6b0..04f9125977a9 100644 --- a/packages/docusaurus-theme-live-codeblock/package.json +++ b/packages/docusaurus-theme-live-codeblock/package.json @@ -4,6 +4,9 @@ "description": "Docusaurus live code block component.", "main": "lib/index.js", "types": "src/theme-live-codeblock.d.ts", + "sideEffects": [ + "lib/theme/Playground/*" + ], "publishConfig": { "access": "public" }, diff --git a/packages/docusaurus-theme-search-algolia/package.json b/packages/docusaurus-theme-search-algolia/package.json index e2cd35f6bdf6..7637c85dcde1 100644 --- a/packages/docusaurus-theme-search-algolia/package.json +++ b/packages/docusaurus-theme-search-algolia/package.json @@ -3,6 +3,9 @@ "version": "2.0.0-beta.18", "description": "Algolia search component for Docusaurus.", "main": "lib/index.js", + "sideEffects": [ + "*.css" + ], "exports": { "./client": "./lib/client/index.js", ".": "./lib/index.js" diff --git a/packages/docusaurus-utils-common/package.json b/packages/docusaurus-utils-common/package.json index ee7156d5b08b..a544907d5ea0 100644 --- a/packages/docusaurus-utils-common/package.json +++ b/packages/docusaurus-utils-common/package.json @@ -4,6 +4,7 @@ "description": "Common (Node/Browser) utility functions for Docusaurus packages.", "main": "./lib/index.js", "types": "./lib/index.d.ts", + "sideEffects": false, "scripts": { "build": "tsc", "watch": "tsc --watch"