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

refactor: mark a few client-side packages as side-effect-free #7085

Merged
merged 10 commits into from
Apr 9, 2022
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
1 change: 1 addition & 0 deletions packages/docusaurus-plugin-content-docs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion packages/docusaurus-theme-classic/src/theme-classic.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -857,7 +857,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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand Down
14 changes: 14 additions & 0 deletions packages/docusaurus-theme-common/Details.d.ts
Original file line number Diff line number Diff line change
@@ -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';
8 changes: 8 additions & 0 deletions packages/docusaurus-theme-common/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 0 additions & 2 deletions packages/docusaurus-theme-common/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
3 changes: 2 additions & 1 deletion packages/docusaurus-theme-common/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,6 @@
"declarationMap": true,
"rootDir": "src",
"outDir": "lib"
}
},
"include": ["src"]
}
3 changes: 3 additions & 0 deletions packages/docusaurus-theme-live-codeblock/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
},
Expand Down
3 changes: 3 additions & 0 deletions packages/docusaurus-theme-search-algolia/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
1 change: 1 addition & 0 deletions packages/docusaurus-utils-common/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down