Skip to content

Commit

Permalink
fix types
Browse files Browse the repository at this point in the history
  • Loading branch information
slorber committed Nov 14, 2024
1 parent 61b4bdb commit 992ea81
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 20 deletions.
15 changes: 1 addition & 14 deletions packages/docusaurus-plugin-svgr/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,27 +9,14 @@ import {createLoader} from './svgrLoader';
import type {LoadContext, Plugin} from '@docusaurus/types';
import type {PluginOptions, Options} from './options';

export type {SVGRConfig, SVGOConfig} from './types';

export default function pluginSVGR(
context: LoadContext,
_context: LoadContext,
options: PluginOptions,
): Plugin {
return {
name: 'docusaurus-plugin-svgr',
configureWebpack: (config, isServer) => {
return {
mergeStrategy: {
module: {
rules: {
test: 'match',
use: {
loader: 'match',
options: 'replace',
},
},
},
},
module: {
rules: [createLoader({isServer, svgrConfig: options.svgrConfig})],
},
Expand Down
8 changes: 7 additions & 1 deletion packages/docusaurus-plugin-svgr/src/options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,13 @@
*/
import {Joi} from '@docusaurus/utils-validation';
import type {OptionValidationContext} from '@docusaurus/types';
import type {Config as SVGRConfig} from '@svgr/core';

// TODO unfortunately there's a SVGR TS error when skipLibCheck=false
// related to prettier, see https://github.com/gregberge/svgr/issues/904
// import type {Config as SVGRConfig} from '@svgr/core';
// export type {SVGRConfig};
export type SVGRConfig = any;
export type SVGOConfig = NonNullable<SVGRConfig['svgoConfig']>;

export type PluginOptions = {
svgrConfig: SVGRConfig;
Expand Down
2 changes: 1 addition & 1 deletion packages/docusaurus-plugin-svgr/src/svgrLoader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

import {getFileLoaderUtils} from '@docusaurus/utils';

import type {SVGRConfig, SVGOConfig} from './types';
import type {SVGRConfig, SVGOConfig} from './options';
import type {RuleSetRule} from 'webpack';

// TODO Docusaurus v4: change these defaults?
Expand Down
4 changes: 0 additions & 4 deletions packages/docusaurus-plugin-svgr/src/types.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,3 @@
*/

/// <reference types="@docusaurus/module-type-aliases" />

export type {Config as SVGRConfig} from '@svgr/core';

export type SVGOConfig = NonNullable<SVGRConfig['svgoConfig']>;

0 comments on commit 992ea81

Please sign in to comment.