Skip to content

Commit dae29a2

Browse files
authored
refactor(core): remove clean-webpack-plugin (#11037)
* remove clean-webpack-plugin * refactor: apply lint autofix * remove clean-webpack-plugin --------- Co-authored-by: slorber <749374+slorber@users.noreply.github.com>
1 parent 37d8844 commit dae29a2

File tree

8 files changed

+31
-270
lines changed

8 files changed

+31
-270
lines changed

packages/docusaurus/package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,6 @@
4747
"combine-promises": "^1.1.0",
4848
"commander": "^5.1.0",
4949
"core-js": "^3.31.1",
50-
"del": "^6.1.1",
5150
"detect-port": "^1.5.1",
5251
"escape-html": "^1.0.3",
5352
"eta": "^2.2.0",

packages/docusaurus/src/commands/build/buildLocale.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ import type {
2626
} from '@docusaurus/types';
2727
import type {SiteCollectedData} from '../../common';
2828
import {BuildCLIOptions} from './build';
29+
import clearPath from '../utils/clearPath';
2930

3031
export type BuildLocaleParams = {
3132
siteDir: string;
@@ -77,6 +78,11 @@ export async function buildLocale({
7778
props,
7879
configureWebpackUtils,
7980
}),
81+
82+
// We also clear website/build dir
83+
// returns void, no useful result needed before compilation
84+
// See also https://github.com/facebook/docusaurus/pull/11037
85+
clearPath(outDir),
8086
]),
8187
);
8288

packages/docusaurus/src/commands/clear.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,14 @@ import {
1212
DEFAULT_BUILD_DIR_NAME,
1313
GENERATED_FILES_DIR_NAME,
1414
} from '@docusaurus/utils';
15+
import clearPath from './utils/clearPath';
1516

1617
async function removePath(entry: {path: string; description: string}) {
1718
if (!(await fs.pathExists(entry.path))) {
1819
return;
1920
}
2021
try {
21-
await fs.remove(entry.path);
22+
await clearPath(entry.path);
2223
logger.success`Removed the ${entry.description} at path=${path.relative(
2324
process.cwd(),
2425
entry.path,
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
/**
2+
* Copyright (c) Facebook, Inc. and its affiliates.
3+
*
4+
* This source code is licensed under the MIT license found in the
5+
* LICENSE file in the root directory of this source tree.
6+
*/
7+
8+
import path from 'path';
9+
import {rm} from 'fs/promises';
10+
import {PerfLogger} from '@docusaurus/logger';
11+
12+
/**
13+
* @param pathToClear
14+
*/
15+
export default async function clearPath(pathToClear: string): Promise<void> {
16+
return PerfLogger.async(
17+
`clearPath ${path.relative(process.cwd(), pathToClear)}`,
18+
async () => {
19+
await rm(pathToClear, {recursive: true, force: true});
20+
},
21+
);
22+
}

packages/docusaurus/src/webpack/client.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ import HtmlWebpackPlugin from 'html-webpack-plugin';
1313
import {getProgressBarPlugin} from '@docusaurus/bundler';
1414
import {createBaseConfig} from './base';
1515
import ChunkAssetPlugin from './plugins/ChunkAssetPlugin';
16-
import CleanWebpackPlugin from './plugins/CleanWebpackPlugin';
1716
import ForceTerminatePlugin from './plugins/ForceTerminatePlugin';
1817
import {createStaticDirectoriesCopyPlugin} from './plugins/StaticDirectoriesCopyPlugin';
1918
import type {
@@ -164,8 +163,6 @@ export async function createBuildClientConfig({
164163
{
165164
plugins: [
166165
new ForceTerminatePlugin(),
167-
// Remove/clean build folders before building bundles.
168-
new CleanWebpackPlugin({verbose: false}),
169166
// Visualize size of webpack output files with an interactive zoomable
170167
// tree map.
171168
bundleAnalyzer && new BundleAnalyzerPlugin(),

packages/docusaurus/src/webpack/plugins/CleanWebpackPlugin.ts

Lines changed: 0 additions & 263 deletions
This file was deleted.

project-words.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
# Project Words - DO NOT TOUCH - This is updated through CI
22
abernathyca
33
Adriaan
4-
Agan
54
alexbdebrie
65
Alexey
76
algoliasearch

yarn.lock

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7339,7 +7339,7 @@ define-properties@^1.1.3, define-properties@^1.1.4, define-properties@^1.2.0, de
73397339
has-property-descriptors "^1.0.0"
73407340
object-keys "^1.1.1"
73417341

7342-
del@^6.0.0, del@^6.1.1:
7342+
del@^6.0.0:
73437343
version "6.1.1"
73447344
resolved "https://registry.yarnpkg.com/del/-/del-6.1.1.tgz#3b70314f1ec0aa325c6b14eb36b95786671edb7a"
73457345
integrity sha512-ua8BhapfP0JUJKC/zV9yHHDW/rDoDxP4Zhn3AkA6/xT6gY7jYXJiaeyBZznYVujhZZET+UgcbZiQ7sN3WqcImg==

0 commit comments

Comments
 (0)