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

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

* fix

* fix again

* fix...

* revert sideeffect

* revert

* fix again...

* properly fix

* fix

* properly fix
This commit is contained in:
Joshua Chen 2022-04-09 09:08:18 +08:00 committed by GitHub
parent 53f531edbf
commit e5bf59fd9b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
10 changed files with 34 additions and 5 deletions

View file

@ -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",

View file

@ -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;

View file

@ -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';

View file

@ -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';

View file

@ -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"

View file

@ -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,

View file

@ -8,5 +8,6 @@
"declarationMap": true,
"rootDir": "src",
"outDir": "lib"
}
},
"include": ["src"]
}

View file

@ -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"
},

View file

@ -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"

View file

@ -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"