Skip to content
Open
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
35 changes: 35 additions & 0 deletions __tests__/__fixtures__/configureWebpack/index.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

36 changes: 36 additions & 0 deletions __tests__/plugin-types.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/**
* 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.
*/

import {describe, expect, it} from 'vitest';
import {fileURLToPath} from 'node:url';
import ts from 'typescript';

describe('plugin types', () => {
it('supports devServer without a consumer importing webpack-dev-server', () => {
const fixture = fileURLToPath(
new URL('./__fixtures__/configureWebpack/index.ts', import.meta.url),
);
// Compile separately: other tests import webpack-dev-server, which augments
// webpack Configuration and would hide missing imports in our public types.
const program = ts.createProgram([fixture], {
strict: true,
noEmit: true,
skipLibCheck: true,
types: [],
target: ts.ScriptTarget.ESNext,
module: ts.ModuleKind.ESNext,
moduleResolution: ts.ModuleResolutionKind.Bundler,
esModuleInterop: true,
});
const diagnostics = ts
.getPreEmitDiagnostics(program)
.map((diagnostic) =>
ts.flattenDiagnosticMessageText(diagnostic.messageText, '\n'),
);
expect(diagnostics).toEqual([]);
});
});
1 change: 1 addition & 0 deletions packages/docusaurus-types/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
"mdast-util-directive": "catalog:",
"utility-types": "catalog:",
"webpack": "catalog:",
"webpack-dev-server": "catalog:",
"webpack-merge": "catalog:"
},
"peerDependencies": {
Expand Down
2 changes: 2 additions & 0 deletions packages/docusaurus-types/src/plugin.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@

import type {CodeTranslations, TranslationFile} from './i18n';
import type {RuleSetRule, Configuration as WebpackConfiguration} from 'webpack';
// Load the devServer augmentation of webpack.Configuration.
import type {} from 'webpack-dev-server';
import type {CustomizeRuleString} from 'webpack-merge/dist/types';
import type {Command} from 'commander';
import type Joi from 'joi';
Expand Down
3 changes: 3 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.