From 4c7519f364c4299f4a6e428bd32acf42fea0df8f Mon Sep 17 00:00:00 2001 From: sebastien Date: Thu, 14 Nov 2024 15:31:51 +0100 Subject: [PATCH 01/21] restore no-unused-vars _ ignore pattern --- .eslintrc.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/.eslintrc.js b/.eslintrc.js index edfbf50d97eb..50453b0ada69 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -380,7 +380,14 @@ module.exports = { // We don't provide any escape hatches for this rule. Rest siblings and // function placeholder params are always ignored, and any other unused // locals must be justified with a disable comment. - '@typescript-eslint/no-unused-vars': [ERROR, {ignoreRestSiblings: true}], + '@typescript-eslint/no-unused-vars': [ + ERROR, + { + ignoreRestSiblings: true, + argsIgnorePattern: '^_', + varsIgnorePattern: '^_', + }, + ], '@typescript-eslint/prefer-optional-chain': ERROR, '@docusaurus/no-html-links': ERROR, '@docusaurus/prefer-docusaurus-heading': ERROR, From b25475433761ef79c91bae19cecb4ba74abe5007 Mon Sep 17 00:00:00 2001 From: sebastien Date: Thu, 14 Nov 2024 15:32:04 +0100 Subject: [PATCH 02/21] scaffold svgr plugin --- packages/docusaurus-plugin-svgr/.npmignore | 3 + packages/docusaurus-plugin-svgr/README.md | 7 ++ packages/docusaurus-plugin-svgr/package.json | 33 ++++++ .../src/__tests__/options.test.ts | 100 ++++++++++++++++++ packages/docusaurus-plugin-svgr/src/index.ts | 25 +++++ .../docusaurus-plugin-svgr/src/options.ts | 36 +++++++ .../docusaurus-plugin-svgr/src/types.d.ts | 8 ++ packages/docusaurus-plugin-svgr/tsconfig.json | 8 ++ 8 files changed, 220 insertions(+) create mode 100644 packages/docusaurus-plugin-svgr/.npmignore create mode 100644 packages/docusaurus-plugin-svgr/README.md create mode 100644 packages/docusaurus-plugin-svgr/package.json create mode 100644 packages/docusaurus-plugin-svgr/src/__tests__/options.test.ts create mode 100644 packages/docusaurus-plugin-svgr/src/index.ts create mode 100644 packages/docusaurus-plugin-svgr/src/options.ts create mode 100644 packages/docusaurus-plugin-svgr/src/types.d.ts create mode 100644 packages/docusaurus-plugin-svgr/tsconfig.json diff --git a/packages/docusaurus-plugin-svgr/.npmignore b/packages/docusaurus-plugin-svgr/.npmignore new file mode 100644 index 000000000000..03c9ae1e1b54 --- /dev/null +++ b/packages/docusaurus-plugin-svgr/.npmignore @@ -0,0 +1,3 @@ +.tsbuildinfo* +tsconfig* +__tests__ diff --git a/packages/docusaurus-plugin-svgr/README.md b/packages/docusaurus-plugin-svgr/README.md new file mode 100644 index 000000000000..27b865208d4d --- /dev/null +++ b/packages/docusaurus-plugin-svgr/README.md @@ -0,0 +1,7 @@ +# `@docusaurus/plugin-svgr` + +[SVGR](https://react-svgr.com/) plugin for Docusaurus. + +## Usage + +See [plugin-svgr documentation](https://docusaurus.io/docs/api/plugins/@docusaurus/plugin-svgr). diff --git a/packages/docusaurus-plugin-svgr/package.json b/packages/docusaurus-plugin-svgr/package.json new file mode 100644 index 000000000000..756c7c7bf59c --- /dev/null +++ b/packages/docusaurus-plugin-svgr/package.json @@ -0,0 +1,33 @@ +{ + "name": "@docusaurus/plugin-svgr", + "version": "3.6.1", + "description": "SVGR plugin for Docusaurus.", + "main": "lib/index.js", + "types": "lib/index.d.ts", + "scripts": { + "build": "tsc --build", + "watch": "tsc --build --watch" + }, + "publishConfig": { + "access": "public" + }, + "repository": { + "type": "git", + "url": "https://github.com/facebook/docusaurus.git", + "directory": "packages/docusaurus-plugin-svgr" + }, + "license": "MIT", + "dependencies": { + "@docusaurus/core": "3.6.1", + "@docusaurus/types": "3.6.1", + "@docusaurus/utils-validation": "3.6.1", + "tslib": "^2.6.0" + }, + "peerDependencies": { + "react": "^18.0.0", + "react-dom": "^18.0.0" + }, + "engines": { + "node": ">=18.0" + } +} diff --git a/packages/docusaurus-plugin-svgr/src/__tests__/options.test.ts b/packages/docusaurus-plugin-svgr/src/__tests__/options.test.ts new file mode 100644 index 000000000000..af5b454cab7c --- /dev/null +++ b/packages/docusaurus-plugin-svgr/src/__tests__/options.test.ts @@ -0,0 +1,100 @@ +/** + * 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 {normalizePluginOptions} from '@docusaurus/utils-validation'; +import { + validateOptions, + type PluginOptions, + type Options, + DEFAULT_OPTIONS, +} from '../options'; +import type {Validate} from '@docusaurus/types'; + +function validate(options?: Options) { + return validateOptions({ + validate: normalizePluginOptions as Validate< + Options | undefined, + PluginOptions + >, + options, + }); +} + +function result(options?: Options) { + return { + id: 'default', + ...DEFAULT_OPTIONS, + ...options, + }; +} + +describe('validateOptions', () => { + it('accepts undefined', () => { + expect(validate(undefined)).toEqual(result(DEFAULT_OPTIONS)); + }); + + it('accepts empty object', () => { + expect(validate({})).toEqual(result(DEFAULT_OPTIONS)); + }); + + it('accepts defaults', () => { + expect(validate(DEFAULT_OPTIONS)).toEqual(result(DEFAULT_OPTIONS)); + }); + + it('rejects null', () => { + expect( + // @ts-expect-error: TS should error + () => validate(null), + ).toThrowErrorMatchingInlineSnapshot(`""value" must be of type object"`); + }); + + it('rejects number', () => { + expect( + // @ts-expect-error: TS should error + () => validate(42), + ).toThrowErrorMatchingInlineSnapshot(`""value" must be of type object"`); + }); + + describe('svgrOptions', () => { + it('accepts undefined', () => { + expect(validate({svgrOptions: undefined})).toEqual( + result(DEFAULT_OPTIONS), + ); + }); + + it('accepts empty', () => { + expect(validate({svgrOptions: {}})).toEqual(result(DEFAULT_OPTIONS)); + }); + + it('accepts any record', () => { + expect(validate({svgrOptions: {any: 'value', evenNumbers: 42}})).toEqual( + result({ + ...DEFAULT_OPTIONS, + svgrOptions: { + any: 'value', + evenNumbers: 42, + }, + }), + ); + }); + + it('accepts default', () => { + expect(validate({svgrOptions: DEFAULT_OPTIONS.svgrOptions})).toEqual( + result(DEFAULT_OPTIONS), + ); + }); + + it('rejects number values', () => { + expect(() => + // @ts-expect-error: invalid type + validate({svgrOptions: 42}), + ).toThrowErrorMatchingInlineSnapshot( + `""svgrOptions" must be of type object"`, + ); + }); + }); +}); diff --git a/packages/docusaurus-plugin-svgr/src/index.ts b/packages/docusaurus-plugin-svgr/src/index.ts new file mode 100644 index 000000000000..c2fbb5f490f9 --- /dev/null +++ b/packages/docusaurus-plugin-svgr/src/index.ts @@ -0,0 +1,25 @@ +/** + * 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 type {LoadContext, Plugin} from '@docusaurus/types'; +import type {PluginOptions, Options} from './options'; + +export default function pluginSVGR( + _context: LoadContext, + _options: PluginOptions, +): Plugin { + return { + name: 'docusaurus-plugin-svgr', + configureWebpack: () => { + return {}; + }, + }; +} + +export {validateOptions} from './options'; + +export type {PluginOptions, Options}; diff --git a/packages/docusaurus-plugin-svgr/src/options.ts b/packages/docusaurus-plugin-svgr/src/options.ts new file mode 100644 index 000000000000..9aef22a12d32 --- /dev/null +++ b/packages/docusaurus-plugin-svgr/src/options.ts @@ -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 {Joi} from '@docusaurus/utils-validation'; +import type {OptionValidationContext} from '@docusaurus/types'; + +type SVGROptions = Record; + +export type PluginOptions = { + svgrOptions: SVGROptions; +}; + +export type Options = { + svgrOptions?: Partial; +}; + +export const DEFAULT_OPTIONS: Partial = { + svgrOptions: {}, +}; + +const pluginOptionsSchema = Joi.object({ + svgrOptions: Joi.object() + .pattern(Joi.string(), Joi.any()) + .optional() + .default(DEFAULT_OPTIONS.svgrOptions), +}).default(DEFAULT_OPTIONS); + +export function validateOptions({ + validate, + options, +}: OptionValidationContext): PluginOptions { + return validate(pluginOptionsSchema, options); +} diff --git a/packages/docusaurus-plugin-svgr/src/types.d.ts b/packages/docusaurus-plugin-svgr/src/types.d.ts new file mode 100644 index 000000000000..6f6f99f12793 --- /dev/null +++ b/packages/docusaurus-plugin-svgr/src/types.d.ts @@ -0,0 +1,8 @@ +/** + * 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. + */ + +/// diff --git a/packages/docusaurus-plugin-svgr/tsconfig.json b/packages/docusaurus-plugin-svgr/tsconfig.json new file mode 100644 index 000000000000..343f87c70bdc --- /dev/null +++ b/packages/docusaurus-plugin-svgr/tsconfig.json @@ -0,0 +1,8 @@ +{ + "extends": "../../tsconfig.base.json", + "compilerOptions": { + "noEmit": false + }, + "include": ["src"], + "exclude": ["**/__tests__/**"] +} From 438dd5adaf42ad6af6c12df87a038a04a9b38969 Mon Sep 17 00:00:00 2001 From: sebastien Date: Thu, 14 Nov 2024 16:24:00 +0100 Subject: [PATCH 03/21] poc of SVGR plugin --- packages/docusaurus-plugin-svgr/package.json | 6 +- .../src/__tests__/options.test.ts | 16 ++--- packages/docusaurus-plugin-svgr/src/index.ts | 24 +++++-- .../docusaurus-plugin-svgr/src/options.ts | 13 ++-- .../docusaurus-plugin-svgr/src/svgrLoader.ts | 70 +++++++++++++++++++ packages/docusaurus-types/src/plugin.d.ts | 14 ++-- packages/docusaurus-utils/package.json | 1 - packages/docusaurus-utils/src/webpackUtils.ts | 40 ----------- packages/docusaurus/src/webpack/base.ts | 1 - 9 files changed, 117 insertions(+), 68 deletions(-) create mode 100644 packages/docusaurus-plugin-svgr/src/svgrLoader.ts diff --git a/packages/docusaurus-plugin-svgr/package.json b/packages/docusaurus-plugin-svgr/package.json index 756c7c7bf59c..aea47b5a2095 100644 --- a/packages/docusaurus-plugin-svgr/package.json +++ b/packages/docusaurus-plugin-svgr/package.json @@ -20,8 +20,12 @@ "dependencies": { "@docusaurus/core": "3.6.1", "@docusaurus/types": "3.6.1", + "@docusaurus/utils": "3.6.1", "@docusaurus/utils-validation": "3.6.1", - "tslib": "^2.6.0" + "@svgr/core": "8.1.0", + "@svgr/webpack": "^8.1.0", + "tslib": "^2.6.0", + "webpack": "^5.88.1" }, "peerDependencies": { "react": "^18.0.0", diff --git a/packages/docusaurus-plugin-svgr/src/__tests__/options.test.ts b/packages/docusaurus-plugin-svgr/src/__tests__/options.test.ts index af5b454cab7c..63edff7dd217 100644 --- a/packages/docusaurus-plugin-svgr/src/__tests__/options.test.ts +++ b/packages/docusaurus-plugin-svgr/src/__tests__/options.test.ts @@ -59,22 +59,22 @@ describe('validateOptions', () => { ).toThrowErrorMatchingInlineSnapshot(`""value" must be of type object"`); }); - describe('svgrOptions', () => { + describe('svgrConfig', () => { it('accepts undefined', () => { - expect(validate({svgrOptions: undefined})).toEqual( + expect(validate({svgrConfig: undefined})).toEqual( result(DEFAULT_OPTIONS), ); }); it('accepts empty', () => { - expect(validate({svgrOptions: {}})).toEqual(result(DEFAULT_OPTIONS)); + expect(validate({svgrConfig: {}})).toEqual(result(DEFAULT_OPTIONS)); }); it('accepts any record', () => { - expect(validate({svgrOptions: {any: 'value', evenNumbers: 42}})).toEqual( + expect(validate({svgrConfig: {any: 'value', evenNumbers: 42}})).toEqual( result({ ...DEFAULT_OPTIONS, - svgrOptions: { + svgrConfig: { any: 'value', evenNumbers: 42, }, @@ -83,7 +83,7 @@ describe('validateOptions', () => { }); it('accepts default', () => { - expect(validate({svgrOptions: DEFAULT_OPTIONS.svgrOptions})).toEqual( + expect(validate({svgrConfig: DEFAULT_OPTIONS.svgrConfig})).toEqual( result(DEFAULT_OPTIONS), ); }); @@ -91,9 +91,9 @@ describe('validateOptions', () => { it('rejects number values', () => { expect(() => // @ts-expect-error: invalid type - validate({svgrOptions: 42}), + validate({svgrConfig: 42}), ).toThrowErrorMatchingInlineSnapshot( - `""svgrOptions" must be of type object"`, + `""svgrConfig" must be of type object"`, ); }); }); diff --git a/packages/docusaurus-plugin-svgr/src/index.ts b/packages/docusaurus-plugin-svgr/src/index.ts index c2fbb5f490f9..53e34ecdf3fb 100644 --- a/packages/docusaurus-plugin-svgr/src/index.ts +++ b/packages/docusaurus-plugin-svgr/src/index.ts @@ -5,17 +5,33 @@ * LICENSE file in the root directory of this source tree. */ +import {createLoader} from './svgrLoader'; import type {LoadContext, Plugin} from '@docusaurus/types'; import type {PluginOptions, Options} from './options'; export default function pluginSVGR( - _context: LoadContext, - _options: PluginOptions, + context: LoadContext, + options: PluginOptions, ): Plugin { return { name: 'docusaurus-plugin-svgr', - configureWebpack: () => { - return {}; + configureWebpack: (config, isServer) => { + return { + mergeStrategy: { + module: { + rules: { + test: 'match', + use: { + loader: 'match', + options: 'replace', + }, + }, + }, + }, + module: { + rules: [createLoader({isServer, svgrConfig: options.svgrConfig})], + }, + }; }, }; } diff --git a/packages/docusaurus-plugin-svgr/src/options.ts b/packages/docusaurus-plugin-svgr/src/options.ts index 9aef22a12d32..c9448e1999d5 100644 --- a/packages/docusaurus-plugin-svgr/src/options.ts +++ b/packages/docusaurus-plugin-svgr/src/options.ts @@ -6,26 +6,25 @@ */ import {Joi} from '@docusaurus/utils-validation'; import type {OptionValidationContext} from '@docusaurus/types'; - -type SVGROptions = Record; +import type {Config as SVGRConfig} from '@svgr/core'; export type PluginOptions = { - svgrOptions: SVGROptions; + svgrConfig: SVGRConfig; }; export type Options = { - svgrOptions?: Partial; + svgrConfig?: Partial; }; export const DEFAULT_OPTIONS: Partial = { - svgrOptions: {}, + svgrConfig: {}, }; const pluginOptionsSchema = Joi.object({ - svgrOptions: Joi.object() + svgrConfig: Joi.object() .pattern(Joi.string(), Joi.any()) .optional() - .default(DEFAULT_OPTIONS.svgrOptions), + .default(DEFAULT_OPTIONS.svgrConfig), }).default(DEFAULT_OPTIONS); export function validateOptions({ diff --git a/packages/docusaurus-plugin-svgr/src/svgrLoader.ts b/packages/docusaurus-plugin-svgr/src/svgrLoader.ts new file mode 100644 index 000000000000..4c3d502f8d55 --- /dev/null +++ b/packages/docusaurus-plugin-svgr/src/svgrLoader.ts @@ -0,0 +1,70 @@ +/** + * 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 {getFileLoaderUtils} from '@docusaurus/utils'; +import type {Config as SVGRConfig} from '@svgr/core'; +import type {RuleSetRule} from 'webpack'; + +type SVGOConfig = NonNullable; + +// TODO Docusaurus v4: change these defaults? +// see https://github.com/facebook/docusaurus/issues/8297 +// see https://github.com/facebook/docusaurus/pull/10205 +// see https://github.com/facebook/docusaurus/pull/10211 +const DefaultSVGOConfig: SVGOConfig = { + plugins: [ + { + name: 'preset-default', + params: { + overrides: { + removeTitle: false, + removeViewBox: false, + }, + }, + }, + ], +}; + +const DefaultSVGRConfig: SVGRConfig = { + prettier: false, + svgo: true, + svgoConfig: DefaultSVGOConfig, + titleProp: true, +}; + +type Params = {isServer: boolean; svgrConfig: SVGRConfig}; + +function createSVGRLoader(params: Params): RuleSetRule { + const options: SVGRConfig = { + ...DefaultSVGRConfig, + ...params.svgrConfig, + }; + return { + loader: require.resolve('@svgr/webpack'), + options, + }; +} + +export function createLoader(params: Params): RuleSetRule { + const utils = getFileLoaderUtils(params.isServer); + return { + test: /\.svg$/i, + oneOf: [ + { + use: [createSVGRLoader(params)], + // We don't want to use SVGR loader for non-React source code + // ie we don't want to use SVGR for CSS files... + issuer: { + and: [/\.(?:tsx?|jsx?|mdx?)$/i], + }, + }, + { + use: [utils.loaders.url({folder: 'images'})], + }, + ], + }; +} diff --git a/packages/docusaurus-types/src/plugin.d.ts b/packages/docusaurus-types/src/plugin.d.ts index fae721dcd0cb..a2936fc82e05 100644 --- a/packages/docusaurus-types/src/plugin.d.ts +++ b/packages/docusaurus-types/src/plugin.d.ts @@ -7,7 +7,7 @@ import type {CodeTranslations, TranslationFile} from './i18n'; import type {RuleSetRule, Configuration as WebpackConfiguration} from 'webpack'; -import type {CustomizeRuleString} from 'webpack-merge/dist/types'; +import type {CustomizeRuleString} from 'webpack-merge'; import type {CommanderStatic} from 'commander'; import type Joi from 'joi'; import type {HelmetServerState} from 'react-helmet-async'; @@ -108,6 +108,12 @@ export type HtmlTagObject = { export type HtmlTags = string | HtmlTagObject | (string | HtmlTagObject)[]; +export type ConfigureWebpackResult = WebpackConfiguration & { + mergeStrategy?: { + [key: string]: CustomizeRuleString; + }; +}; + export type Plugin = { name: string; loadContent?: () => Promise | Content; @@ -134,11 +140,7 @@ export type Plugin = { isServer: boolean, configureWebpackUtils: ConfigureWebpackUtils, content: Content, - ) => WebpackConfiguration & { - mergeStrategy?: { - [key: string]: CustomizeRuleString; - }; - }; + ) => ConfigureWebpackResult; configurePostCss?: (options: PostCssOptions) => PostCssOptions; getThemePath?: () => string; getTypeScriptThemePath?: () => string; diff --git a/packages/docusaurus-utils/package.json b/packages/docusaurus-utils/package.json index 4e2b66ba87a9..08f7eef4caed 100644 --- a/packages/docusaurus-utils/package.json +++ b/packages/docusaurus-utils/package.json @@ -21,7 +21,6 @@ "@docusaurus/logger": "3.6.1", "@docusaurus/types": "3.6.1", "@docusaurus/utils-common": "3.6.1", - "@svgr/webpack": "^8.1.0", "escape-string-regexp": "^4.0.0", "file-loader": "^6.2.0", "fs-extra": "^11.1.1", diff --git a/packages/docusaurus-utils/src/webpackUtils.ts b/packages/docusaurus-utils/src/webpackUtils.ts index 8c005a8a5c4b..dc3dd2b1181a 100644 --- a/packages/docusaurus-utils/src/webpackUtils.ts +++ b/packages/docusaurus-utils/src/webpackUtils.ts @@ -45,7 +45,6 @@ type FileLoaderUtils = { images: () => RuleSetRule; fonts: () => RuleSetRule; media: () => RuleSetRule; - svg: () => RuleSetRule; otherAssets: () => RuleSetRule; }; }; @@ -134,45 +133,6 @@ function createFileLoaderUtils({ test: /\.(?:mp4|avi|mov|mkv|mpg|mpeg|vob|wmv|m4v|webm|ogv|wav|mp3|m4a|aac|oga|flac)$/i, }), - svg: () => ({ - test: /\.svg$/i, - oneOf: [ - { - use: [ - { - loader: require.resolve('@svgr/webpack'), - options: { - prettier: false, - svgo: true, - svgoConfig: { - plugins: [ - { - name: 'preset-default', - params: { - overrides: { - removeTitle: false, - removeViewBox: false, - }, - }, - }, - ], - }, - titleProp: true, - }, - }, - ], - // We don't want to use SVGR loader for non-React source code - // ie we don't want to use SVGR for CSS files... - issuer: { - and: [/\.(?:tsx?|jsx?|mdx?)$/i], - }, - }, - { - use: [loaders.url({folder: 'images'})], - }, - ], - }), - otherAssets: () => ({ use: [loaders.file({folder: 'files'})], test: /\.(?:pdf|docx?|xlsx?|zip|rar)$/i, diff --git a/packages/docusaurus/src/webpack/base.ts b/packages/docusaurus/src/webpack/base.ts index 31ea6b85d5c1..5ae2a215e533 100644 --- a/packages/docusaurus/src/webpack/base.ts +++ b/packages/docusaurus/src/webpack/base.ts @@ -245,7 +245,6 @@ export async function createBaseConfig({ fileLoaderUtils.rules.images(), fileLoaderUtils.rules.fonts(), fileLoaderUtils.rules.media(), - fileLoaderUtils.rules.svg(), fileLoaderUtils.rules.otherAssets(), { test: /\.[jt]sx?$/i, From 871c41a54bfbfb2ac8802d7d94d8c3e79d0d0f3b Mon Sep 17 00:00:00 2001 From: sebastien Date: Thu, 14 Nov 2024 16:28:16 +0100 Subject: [PATCH 04/21] poc of SVGR plugin --- packages/docusaurus-preset-classic/package.json | 1 + packages/docusaurus-preset-classic/src/index.ts | 4 ++++ packages/docusaurus-preset-classic/src/options.ts | 3 +++ 3 files changed, 8 insertions(+) diff --git a/packages/docusaurus-preset-classic/package.json b/packages/docusaurus-preset-classic/package.json index 3b627aefed34..8b0cfa0c4d29 100644 --- a/packages/docusaurus-preset-classic/package.json +++ b/packages/docusaurus-preset-classic/package.json @@ -27,6 +27,7 @@ "@docusaurus/plugin-google-gtag": "3.6.1", "@docusaurus/plugin-google-tag-manager": "3.6.1", "@docusaurus/plugin-sitemap": "3.6.1", + "@docusaurus/plugin-svgr": "3.6.1", "@docusaurus/theme-classic": "3.6.1", "@docusaurus/theme-common": "3.6.1", "@docusaurus/theme-search-algolia": "3.6.1", diff --git a/packages/docusaurus-preset-classic/src/index.ts b/packages/docusaurus-preset-classic/src/index.ts index 45ae988bc507..eac8c461b306 100644 --- a/packages/docusaurus-preset-classic/src/index.ts +++ b/packages/docusaurus-preset-classic/src/index.ts @@ -37,6 +37,7 @@ export default function preset( blog, pages, sitemap, + svgr, theme, googleAnalytics, gtag, @@ -92,6 +93,9 @@ export default function preset( if (sitemap !== false && (isProd || debug)) { plugins.push(makePluginConfig('@docusaurus/plugin-sitemap', sitemap)); } + if (svgr !== false) { + plugins.push(makePluginConfig('@docusaurus/plugin-svgr', svgr)); + } if (Object.keys(rest).length > 0) { throw new Error( `Unrecognized keys ${Object.keys(rest).join( diff --git a/packages/docusaurus-preset-classic/src/options.ts b/packages/docusaurus-preset-classic/src/options.ts index a8fdb68125f2..98c4087ac696 100644 --- a/packages/docusaurus-preset-classic/src/options.ts +++ b/packages/docusaurus-preset-classic/src/options.ts @@ -9,6 +9,7 @@ import type {Options as DocsPluginOptions} from '@docusaurus/plugin-content-docs import type {Options as BlogPluginOptions} from '@docusaurus/plugin-content-blog'; import type {Options as PagesPluginOptions} from '@docusaurus/plugin-content-pages'; import type {Options as SitemapPluginOptions} from '@docusaurus/plugin-sitemap'; +import type {Options as SVGRPluginOptions} from '@docusaurus/plugin-svgr'; import type {Options as GAPluginOptions} from '@docusaurus/plugin-google-analytics'; import type {Options as GtagPluginOptions} from '@docusaurus/plugin-google-gtag'; import type {Options as GTMPluginOptions} from '@docusaurus/plugin-google-tag-manager'; @@ -31,6 +32,8 @@ export type Options = { pages?: false | PagesPluginOptions; /** Options for `@docusaurus/plugin-sitemap`. Use `false` to disable. */ sitemap?: false | SitemapPluginOptions; + /** Options for `@docusaurus/plugin-svgr`. Use `false` to disable. */ + svgr?: false | SVGRPluginOptions; /** Options for `@docusaurus/theme-classic`. */ theme?: ThemeOptions; /** From 334ee8f4d5c26ac80eea644b95f1c6a20a7bea9f Mon Sep 17 00:00:00 2001 From: sebastien Date: Thu, 14 Nov 2024 16:42:18 +0100 Subject: [PATCH 05/21] Add SVG dogfood page test --- website/_dogfooding/_pages tests/index.mdx | 1 + .../_dogfooding/_pages tests/svg/hacker.svg | 188 ++++++++++ .../_dogfooding/_pages tests/svg/index.mdx | 15 + .../_pages tests/svg/integrations.svg | 335 ++++++++++++++++++ website/_dogfooding/_pages tests/svg/logo.svg | 13 + .../_dogfooding/_pages tests/svg/mascot.svg | 239 +++++++++++++ .../_pages tests/svg/open-source.svg | 237 +++++++++++++ 7 files changed, 1028 insertions(+) create mode 100644 website/_dogfooding/_pages tests/svg/hacker.svg create mode 100644 website/_dogfooding/_pages tests/svg/index.mdx create mode 100644 website/_dogfooding/_pages tests/svg/integrations.svg create mode 100644 website/_dogfooding/_pages tests/svg/logo.svg create mode 100644 website/_dogfooding/_pages tests/svg/mascot.svg create mode 100644 website/_dogfooding/_pages tests/svg/open-source.svg diff --git a/website/_dogfooding/_pages tests/index.mdx b/website/_dogfooding/_pages tests/index.mdx index 4f7c2889bff1..d862394e29c4 100644 --- a/website/_dogfooding/_pages tests/index.mdx +++ b/website/_dogfooding/_pages tests/index.mdx @@ -26,6 +26,7 @@ import Readme from "../README.mdx" ### Other tests - [React 18](/tests/pages/react-18) +- [SVG](/tests/pages/svg) - [Crash test](/tests/pages/crashTest) - [Code block tests](/tests/pages/code-block-tests) - [Link tests](/tests/pages/link-tests) diff --git a/website/_dogfooding/_pages tests/svg/hacker.svg b/website/_dogfooding/_pages tests/svg/hacker.svg new file mode 100644 index 000000000000..701730e08652 --- /dev/null +++ b/website/_dogfooding/_pages tests/svg/hacker.svg @@ -0,0 +1,188 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + svgo --help + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/website/_dogfooding/_pages tests/svg/index.mdx b/website/_dogfooding/_pages tests/svg/index.mdx new file mode 100644 index 000000000000..a3c5c2718476 --- /dev/null +++ b/website/_dogfooding/_pages tests/svg/index.mdx @@ -0,0 +1,15 @@ +import Logo from './logo.svg'; +import Hacker from './hacker.svg'; +import Integrations from './integrations.svg'; +import OpenSource from './open-source.svg'; +import Mascot from './mascot.svg'; + +# Many inline SVGs + +Have a bunch of SVGs, they're written to intentionally override each others styled when inlined on the same page. + + + + + + diff --git a/website/_dogfooding/_pages tests/svg/integrations.svg b/website/_dogfooding/_pages tests/svg/integrations.svg new file mode 100644 index 000000000000..659c5d146bfa --- /dev/null +++ b/website/_dogfooding/_pages tests/svg/integrations.svg @@ -0,0 +1,335 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/website/_dogfooding/_pages tests/svg/logo.svg b/website/_dogfooding/_pages tests/svg/logo.svg new file mode 100644 index 000000000000..c0167b6f6d35 --- /dev/null +++ b/website/_dogfooding/_pages tests/svg/logo.svg @@ -0,0 +1,13 @@ + + + + + + + + + + + + + diff --git a/website/_dogfooding/_pages tests/svg/mascot.svg b/website/_dogfooding/_pages tests/svg/mascot.svg new file mode 100644 index 000000000000..b3c8bbe6e758 --- /dev/null +++ b/website/_dogfooding/_pages tests/svg/mascot.svg @@ -0,0 +1,239 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/website/_dogfooding/_pages tests/svg/open-source.svg b/website/_dogfooding/_pages tests/svg/open-source.svg new file mode 100644 index 000000000000..08311e31c091 --- /dev/null +++ b/website/_dogfooding/_pages tests/svg/open-source.svg @@ -0,0 +1,237 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + From b50845b258b4702805ddc1a87dc559777552e6a4 Mon Sep 17 00:00:00 2001 From: sebastien Date: Thu, 14 Nov 2024 16:51:15 +0100 Subject: [PATCH 06/21] Use website custom svgo config file --- website/docusaurus.config.ts | 5 +++++ website/svgo.config.js | 29 +++++++++++++++++++++++++++++ 2 files changed, 34 insertions(+) create mode 100644 website/svgo.config.js diff --git a/website/docusaurus.config.ts b/website/docusaurus.config.ts index b52e5c859a7a..852a0b4e3c83 100644 --- a/website/docusaurus.config.ts +++ b/website/docusaurus.config.ts @@ -547,6 +547,11 @@ export default async function createConfigAsync() { priority: null, changefreq: null, }, + svgr: { + svgrConfig: { + svgoConfig: undefined, // Use .svgo.config.js + }, + }, } satisfies Preset.Options, ], ], diff --git a/website/svgo.config.js b/website/svgo.config.js new file mode 100644 index 000000000000..be70fc07fc59 --- /dev/null +++ b/website/svgo.config.js @@ -0,0 +1,29 @@ +/** + * 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. + */ + +const path = require('path'); + +module.exports = { + plugins: [ + { + name: 'preset-default', + params: { + overrides: { + removeTitle: false, + removeViewBox: false, + }, + }, + }, + { + name: 'prefixIds', + params: { + delim: '', + prefix: (_, info) => path.parse(info.path).name, + }, + }, + ], +}; From 0b93cdbf5c9c96f907cb232ff1969148c8d20bea Mon Sep 17 00:00:00 2001 From: sebastien Date: Thu, 14 Nov 2024 17:02:36 +0100 Subject: [PATCH 07/21] remove useless SVGR tests --- .../src/__tests__/webpackUtils.test.ts | 34 ------------------- .../src/webpack/__tests__/base.test.ts | 16 --------- 2 files changed, 50 deletions(-) delete mode 100644 packages/docusaurus-utils/src/__tests__/webpackUtils.test.ts diff --git a/packages/docusaurus-utils/src/__tests__/webpackUtils.test.ts b/packages/docusaurus-utils/src/__tests__/webpackUtils.test.ts deleted file mode 100644 index 3d2c70f68924..000000000000 --- a/packages/docusaurus-utils/src/__tests__/webpackUtils.test.ts +++ /dev/null @@ -1,34 +0,0 @@ -/** - * 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 {getFileLoaderUtils} from '../webpackUtils'; - -describe('getFileLoaderUtils()', () => { - it('plugin svgo/removeViewBox and removeTitle should be disabled', () => { - const {oneOf} = getFileLoaderUtils().rules.svg(); - expect(oneOf![0]!.use).toContainEqual( - expect.objectContaining({ - loader: require.resolve('@svgr/webpack'), - options: expect.objectContaining({ - svgoConfig: { - plugins: [ - { - name: 'preset-default', - params: { - overrides: { - removeTitle: false, - removeViewBox: false, - }, - }, - }, - ], - }, - }), - }), - ); - }); -}); diff --git a/packages/docusaurus/src/webpack/__tests__/base.test.ts b/packages/docusaurus/src/webpack/__tests__/base.test.ts index b4c29b514e17..676e509fe4b9 100644 --- a/packages/docusaurus/src/webpack/__tests__/base.test.ts +++ b/packages/docusaurus/src/webpack/__tests__/base.test.ts @@ -132,20 +132,4 @@ describe('base webpack config', () => { ); expect(relativeAliases).toMatchSnapshot(); }); - - it('uses svg rule', async () => { - const config = await createBaseConfig({ - props, - isServer: false, - minify: false, - faster: DEFAULT_FASTER_CONFIG, - configureWebpackUtils: await createTestConfigureWebpackUtils(), - }); - - const svgRule = (config.module?.rules ?? []).find((rule) => { - return rule && (rule as any).test.toString().includes('.svg'); - }); - expect(svgRule).toBeDefined(); - expect(svgRule).toMatchSnapshot(); - }); }); From 87fd316612cf37d4fce0f5eb887fea6e17e30b51 Mon Sep 17 00:00:00 2001 From: sebastien Date: Thu, 14 Nov 2024 17:22:52 +0100 Subject: [PATCH 08/21] remove useless SVGR tests --- .../__tests__/__snapshots__/base.test.ts.snap | 51 ----- .../_dogfooding/_pages tests/svg/hacker.svg | 188 ------------------ .../_dogfooding/_pages tests/svg/index.mdx | 4 - website/_dogfooding/_pages tests/svg/logo.svg | 13 -- 4 files changed, 256 deletions(-) delete mode 100644 website/_dogfooding/_pages tests/svg/hacker.svg delete mode 100644 website/_dogfooding/_pages tests/svg/logo.svg diff --git a/packages/docusaurus/src/webpack/__tests__/__snapshots__/base.test.ts.snap b/packages/docusaurus/src/webpack/__tests__/__snapshots__/base.test.ts.snap index 8f321b063446..88a08cdf5997 100644 --- a/packages/docusaurus/src/webpack/__tests__/__snapshots__/base.test.ts.snap +++ b/packages/docusaurus/src/webpack/__tests__/__snapshots__/base.test.ts.snap @@ -52,54 +52,3 @@ exports[`base webpack config creates webpack aliases 1`] = ` "react-dom": "../../../../../../../node_modules/react-dom", } `; - -exports[`base webpack config uses svg rule 1`] = ` -{ - "oneOf": [ - { - "issuer": { - "and": [ - /\\\\\\.\\(\\?:tsx\\?\\|jsx\\?\\|mdx\\?\\)\\$/i, - ], - }, - "use": [ - { - "loader": "/node_modules/@svgr/webpack/dist/index.js", - "options": { - "prettier": false, - "svgo": true, - "svgoConfig": { - "plugins": [ - { - "name": "preset-default", - "params": { - "overrides": { - "removeTitle": false, - "removeViewBox": false, - }, - }, - }, - ], - }, - "titleProp": true, - }, - }, - ], - }, - { - "use": [ - { - "loader": "/node_modules/url-loader/dist/cjs.js", - "options": { - "emitFile": true, - "fallback": "/node_modules/file-loader/dist/cjs.js", - "limit": 10000, - "name": "assets/images/[name]-[contenthash].[ext]", - }, - }, - ], - }, - ], - "test": /\\\\\\.svg\\$/i, -} -`; diff --git a/website/_dogfooding/_pages tests/svg/hacker.svg b/website/_dogfooding/_pages tests/svg/hacker.svg deleted file mode 100644 index 701730e08652..000000000000 --- a/website/_dogfooding/_pages tests/svg/hacker.svg +++ /dev/null @@ -1,188 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - svgo --help - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/website/_dogfooding/_pages tests/svg/index.mdx b/website/_dogfooding/_pages tests/svg/index.mdx index a3c5c2718476..494bc5e21d10 100644 --- a/website/_dogfooding/_pages tests/svg/index.mdx +++ b/website/_dogfooding/_pages tests/svg/index.mdx @@ -1,5 +1,3 @@ -import Logo from './logo.svg'; -import Hacker from './hacker.svg'; import Integrations from './integrations.svg'; import OpenSource from './open-source.svg'; import Mascot from './mascot.svg'; @@ -8,8 +6,6 @@ import Mascot from './mascot.svg'; Have a bunch of SVGs, they're written to intentionally override each others styled when inlined on the same page. - - diff --git a/website/_dogfooding/_pages tests/svg/logo.svg b/website/_dogfooding/_pages tests/svg/logo.svg deleted file mode 100644 index c0167b6f6d35..000000000000 --- a/website/_dogfooding/_pages tests/svg/logo.svg +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - - - - - - - From 1d11f784b7b743552e5a947aca76dc824689d86b Mon Sep 17 00:00:00 2001 From: sebastien Date: Thu, 14 Nov 2024 17:31:08 +0100 Subject: [PATCH 09/21] refactor SVGR/SVGO types and export them --- packages/docusaurus-plugin-svgr/src/index.ts | 2 ++ packages/docusaurus-plugin-svgr/src/svgrLoader.ts | 5 ++--- packages/docusaurus-plugin-svgr/src/types.d.ts | 4 ++++ 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/packages/docusaurus-plugin-svgr/src/index.ts b/packages/docusaurus-plugin-svgr/src/index.ts index 53e34ecdf3fb..d68b94195f00 100644 --- a/packages/docusaurus-plugin-svgr/src/index.ts +++ b/packages/docusaurus-plugin-svgr/src/index.ts @@ -9,6 +9,8 @@ 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, options: PluginOptions, diff --git a/packages/docusaurus-plugin-svgr/src/svgrLoader.ts b/packages/docusaurus-plugin-svgr/src/svgrLoader.ts index 4c3d502f8d55..a75a16571186 100644 --- a/packages/docusaurus-plugin-svgr/src/svgrLoader.ts +++ b/packages/docusaurus-plugin-svgr/src/svgrLoader.ts @@ -6,10 +6,9 @@ */ import {getFileLoaderUtils} from '@docusaurus/utils'; -import type {Config as SVGRConfig} from '@svgr/core'; -import type {RuleSetRule} from 'webpack'; -type SVGOConfig = NonNullable; +import type {SVGRConfig, SVGOConfig} from './types'; +import type {RuleSetRule} from 'webpack'; // TODO Docusaurus v4: change these defaults? // see https://github.com/facebook/docusaurus/issues/8297 diff --git a/packages/docusaurus-plugin-svgr/src/types.d.ts b/packages/docusaurus-plugin-svgr/src/types.d.ts index 6f6f99f12793..763efa96df9b 100644 --- a/packages/docusaurus-plugin-svgr/src/types.d.ts +++ b/packages/docusaurus-plugin-svgr/src/types.d.ts @@ -6,3 +6,7 @@ */ /// + +export type {Config as SVGRConfig} from '@svgr/core'; + +export type SVGOConfig = NonNullable; From 61b4bdb61eaca79d3e75e355663f56715165318e Mon Sep 17 00:00:00 2001 From: sebastien Date: Thu, 14 Nov 2024 17:32:38 +0100 Subject: [PATCH 10/21] fix webpack merge type :s --- packages/docusaurus-types/src/plugin.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/docusaurus-types/src/plugin.d.ts b/packages/docusaurus-types/src/plugin.d.ts index a2936fc82e05..51cecbf64783 100644 --- a/packages/docusaurus-types/src/plugin.d.ts +++ b/packages/docusaurus-types/src/plugin.d.ts @@ -7,7 +7,7 @@ import type {CodeTranslations, TranslationFile} from './i18n'; import type {RuleSetRule, Configuration as WebpackConfiguration} from 'webpack'; -import type {CustomizeRuleString} from 'webpack-merge'; +import type {CustomizeRuleString} from 'webpack-merge/dist/types'; import type {CommanderStatic} from 'commander'; import type Joi from 'joi'; import type {HelmetServerState} from 'react-helmet-async'; From 992ea8189624dfbf7ef7cc29247a7ce789004039 Mon Sep 17 00:00:00 2001 From: sebastien Date: Thu, 14 Nov 2024 17:43:18 +0100 Subject: [PATCH 11/21] fix types --- packages/docusaurus-plugin-svgr/src/index.ts | 15 +-------------- packages/docusaurus-plugin-svgr/src/options.ts | 8 +++++++- packages/docusaurus-plugin-svgr/src/svgrLoader.ts | 2 +- packages/docusaurus-plugin-svgr/src/types.d.ts | 4 ---- 4 files changed, 9 insertions(+), 20 deletions(-) diff --git a/packages/docusaurus-plugin-svgr/src/index.ts b/packages/docusaurus-plugin-svgr/src/index.ts index d68b94195f00..ab92a1ee1507 100644 --- a/packages/docusaurus-plugin-svgr/src/index.ts +++ b/packages/docusaurus-plugin-svgr/src/index.ts @@ -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})], }, diff --git a/packages/docusaurus-plugin-svgr/src/options.ts b/packages/docusaurus-plugin-svgr/src/options.ts index c9448e1999d5..c4cd5c9f37e8 100644 --- a/packages/docusaurus-plugin-svgr/src/options.ts +++ b/packages/docusaurus-plugin-svgr/src/options.ts @@ -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; export type PluginOptions = { svgrConfig: SVGRConfig; diff --git a/packages/docusaurus-plugin-svgr/src/svgrLoader.ts b/packages/docusaurus-plugin-svgr/src/svgrLoader.ts index a75a16571186..3744b9decca1 100644 --- a/packages/docusaurus-plugin-svgr/src/svgrLoader.ts +++ b/packages/docusaurus-plugin-svgr/src/svgrLoader.ts @@ -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? diff --git a/packages/docusaurus-plugin-svgr/src/types.d.ts b/packages/docusaurus-plugin-svgr/src/types.d.ts index 763efa96df9b..6f6f99f12793 100644 --- a/packages/docusaurus-plugin-svgr/src/types.d.ts +++ b/packages/docusaurus-plugin-svgr/src/types.d.ts @@ -6,7 +6,3 @@ */ /// - -export type {Config as SVGRConfig} from '@svgr/core'; - -export type SVGOConfig = NonNullable; From 430494c54983923790bfbf432bc6e26432b1247a Mon Sep 17 00:00:00 2001 From: sebastien Date: Thu, 14 Nov 2024 17:58:50 +0100 Subject: [PATCH 12/21] docs --- website/docs/api/plugins/overview.mdx | 3 ++ website/docs/api/plugins/plugin-svgr.mdx | 55 ++++++++++++++++++++++++ website/docs/using-plugins.mdx | 3 ++ 3 files changed, 61 insertions(+) create mode 100644 website/docs/api/plugins/plugin-svgr.mdx diff --git a/website/docs/api/plugins/overview.mdx b/website/docs/api/plugins/overview.mdx index 651517d4ee83..23eb70892996 100644 --- a/website/docs/api/plugins/overview.mdx +++ b/website/docs/api/plugins/overview.mdx @@ -23,8 +23,11 @@ These plugins will add a useful behavior to your Docusaurus site. - [@docusaurus/plugin-debug](./plugin-debug.mdx) - [@docusaurus/plugin-sitemap](./plugin-sitemap.mdx) +- [@docusaurus/plugin-svgr](./plugin-svgr.mdx) +- [@docusaurus/plugin-rsdoctor](./plugin-rsdoctor.mdx) - [@docusaurus/plugin-pwa](./plugin-pwa.mdx) - [@docusaurus/plugin-client-redirects](./plugin-client-redirects.mdx) - [@docusaurus/plugin-ideal-image](./plugin-ideal-image.mdx) - [@docusaurus/plugin-google-analytics](./plugin-google-analytics.mdx) - [@docusaurus/plugin-google-gtag](./plugin-google-gtag.mdx) +- [@docusaurus/plugin-google-tag-manager](./plugin-google-tag-manager.mdx) diff --git a/website/docs/api/plugins/plugin-svgr.mdx b/website/docs/api/plugins/plugin-svgr.mdx new file mode 100644 index 000000000000..bd5bef1eab90 --- /dev/null +++ b/website/docs/api/plugins/plugin-svgr.mdx @@ -0,0 +1,55 @@ +--- +sidebar_position: 7 +slug: /api/plugins/@docusaurus/plugin-svgr +--- + +# 📦 plugin-svgr + +import APITable from '@site/src/components/APITable'; + +An [SVGR](https://react-svgr.com/) plugin to transform SVG files into React components automatically at build time. + +## Installation {#installation} + +```bash npm2yarn +npm install --save @docusaurus/plugin-svgr +``` + +:::tip + +If you use the preset `@docusaurus/preset-classic`, you don't need to install this plugin as a dependency. + +You can configure this plugin through the [preset options](../../using-plugins.mdx#docusauruspreset-classic). + +::: + +## Configuration {#configuration} + +Accepted fields: + +```mdx-code-block + +``` + +| Name | Type | Default | Description | +| --- | --- | --- | --- | +| `svgrConfig` | `object` | `{}` | The [SVGR config options](https://react-svgr.com/docs/options/), forwarded as is | + +```mdx-code-block + +``` + +### Example configuration {#ex-config} + +You can configure this plugin through plugin options. + +```js config-tabs +// Preset Options: svgr +// Plugin Options: @docusaurus/plugin-svgr + +const config = { + svgrConfig: { + /* SVGR config */ + }, +}; +``` diff --git a/website/docs/using-plugins.mdx b/website/docs/using-plugins.mdx index 92d86097d717..a9d7f043243b 100644 --- a/website/docs/using-plugins.mdx +++ b/website/docs/using-plugins.mdx @@ -148,6 +148,7 @@ The classic preset is shipped by default to new Docusaurus websites created with - [`@docusaurus/plugin-google-tag-manager`](./api/plugins/plugin-google-tag-manager.mdx) - [`@docusaurus/plugin-google-analytics`](./api/plugins/plugin-google-analytics.mdx) (**deprecated**) - [`@docusaurus/plugin-sitemap`](./api/plugins/plugin-sitemap.mdx) +- [`@docusaurus/plugin-svgr`](./api/plugins/plugin-svgr.mdx) The classic preset will relay each option entry to the respective plugin/theme. @@ -171,6 +172,8 @@ export default { pages: {}, // Will be passed to @docusaurus/plugin-sitemap (false to disable) sitemap: {}, + // Will be passed to @docusaurus/plugin-svgr (false to disable) + svgr: {}, // Will be passed to @docusaurus/plugin-google-gtag (only enabled when explicitly specified) gtag: {}, // Will be passed to @docusaurus/plugin-google-tag-manager (only enabled when explicitly specified) From 903bdfd96fc7968eb478143201f2d3e83469e82b Mon Sep 17 00:00:00 2001 From: sebastien Date: Thu, 21 Nov 2024 10:57:06 +0100 Subject: [PATCH 13/21] svgr version --- packages/docusaurus-plugin-svgr/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/docusaurus-plugin-svgr/package.json b/packages/docusaurus-plugin-svgr/package.json index aea47b5a2095..44922470d707 100644 --- a/packages/docusaurus-plugin-svgr/package.json +++ b/packages/docusaurus-plugin-svgr/package.json @@ -1,6 +1,6 @@ { "name": "@docusaurus/plugin-svgr", - "version": "3.6.1", + "version": "3.6.2", "description": "SVGR plugin for Docusaurus.", "main": "lib/index.js", "types": "lib/index.d.ts", From 8838a94fb199c022c2939df51ff03021f49dc834 Mon Sep 17 00:00:00 2001 From: slorber Date: Thu, 21 Nov 2024 10:02:08 +0000 Subject: [PATCH 14/21] refactor: apply lint autofix --- yarn.lock | 215 +++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 214 insertions(+), 1 deletion(-) diff --git a/yarn.lock b/yarn.lock index 1ead5c589d83..4ddf0d4f83ec 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2011,6 +2011,155 @@ "@docsearch/css" "3.5.2" algoliasearch "^4.19.1" +"@docusaurus/babel@3.6.1": + version "3.6.1" + resolved "https://registry.yarnpkg.com/@docusaurus/babel/-/babel-3.6.1.tgz#5f48a275934b8164ccac3a6fd1fca3741374c884" + integrity sha512-JcKaunW8Ml2nTnfnvFc55T00Y+aCpNWnf1KY/gG+wWxHYDH0IdXOOz+k6NAlEAerW8+VYLfUqRIqHZ7N/DVXvQ== + dependencies: + "@babel/core" "^7.25.9" + "@babel/generator" "^7.25.9" + "@babel/plugin-syntax-dynamic-import" "^7.8.3" + "@babel/plugin-transform-runtime" "^7.25.9" + "@babel/preset-env" "^7.25.9" + "@babel/preset-react" "^7.25.9" + "@babel/preset-typescript" "^7.25.9" + "@babel/runtime" "^7.25.9" + "@babel/runtime-corejs3" "^7.25.9" + "@babel/traverse" "^7.25.9" + "@docusaurus/logger" "3.6.1" + "@docusaurus/utils" "3.6.1" + babel-plugin-dynamic-import-node "^2.3.3" + fs-extra "^11.1.1" + tslib "^2.6.0" + +"@docusaurus/bundler@3.6.1": + version "3.6.1" + resolved "https://registry.yarnpkg.com/@docusaurus/bundler/-/bundler-3.6.1.tgz#240343d31f39638f987caf54793c09820270ecd5" + integrity sha512-vHSEx8Ku9x/gfIC6k4xb8J2nTxagLia0KvZkPZhxfkD1+n8i+Dj4BZPWTmv+kCA17RbgAvECG0XRZ0/ZEspQBQ== + dependencies: + "@babel/core" "^7.25.9" + "@docusaurus/babel" "3.6.1" + "@docusaurus/cssnano-preset" "3.6.1" + "@docusaurus/logger" "3.6.1" + "@docusaurus/types" "3.6.1" + "@docusaurus/utils" "3.6.1" + autoprefixer "^10.4.14" + babel-loader "^9.2.1" + clean-css "^5.3.2" + copy-webpack-plugin "^11.0.0" + css-loader "^6.8.1" + css-minimizer-webpack-plugin "^5.0.1" + cssnano "^6.1.2" + file-loader "^6.2.0" + html-minifier-terser "^7.2.0" + mini-css-extract-plugin "^2.9.1" + null-loader "^4.0.1" + postcss "^8.4.26" + postcss-loader "^7.3.3" + react-dev-utils "^12.0.1" + terser-webpack-plugin "^5.3.9" + tslib "^2.6.0" + url-loader "^4.1.1" + webpack "^5.95.0" + webpackbar "^6.0.1" + +"@docusaurus/core@3.6.1": + version "3.6.1" + resolved "https://registry.yarnpkg.com/@docusaurus/core/-/core-3.6.1.tgz#260d78e1eb7129ccb441fa944b5f7e6f492ac6cb" + integrity sha512-cDKxPihiM2z7G+4QtpTczS7uxNfNG6naSqM65OmAJET0CFRHbc9mDlLFtQF0lsVES91SHqfcGaaLZmi2FjdwWA== + dependencies: + "@docusaurus/babel" "3.6.1" + "@docusaurus/bundler" "3.6.1" + "@docusaurus/logger" "3.6.1" + "@docusaurus/mdx-loader" "3.6.1" + "@docusaurus/utils" "3.6.1" + "@docusaurus/utils-common" "3.6.1" + "@docusaurus/utils-validation" "3.6.1" + boxen "^6.2.1" + chalk "^4.1.2" + chokidar "^3.5.3" + cli-table3 "^0.6.3" + combine-promises "^1.1.0" + commander "^5.1.0" + core-js "^3.31.1" + del "^6.1.1" + detect-port "^1.5.1" + escape-html "^1.0.3" + eta "^2.2.0" + eval "^0.1.8" + fs-extra "^11.1.1" + html-tags "^3.3.1" + html-webpack-plugin "^5.6.0" + leven "^3.1.0" + lodash "^4.17.21" + p-map "^4.0.0" + prompts "^2.4.2" + react-dev-utils "^12.0.1" + react-helmet-async "^1.3.0" + react-loadable "npm:@docusaurus/react-loadable@6.0.0" + react-loadable-ssr-addon-v5-slorber "^1.0.1" + react-router "^5.3.4" + react-router-config "^5.1.1" + react-router-dom "^5.3.4" + rtl-detect "^1.0.4" + semver "^7.5.4" + serve-handler "^6.1.6" + shelljs "^0.8.5" + tslib "^2.6.0" + update-notifier "^6.0.2" + webpack "^5.95.0" + webpack-bundle-analyzer "^4.10.2" + webpack-dev-server "^4.15.2" + webpack-merge "^6.0.1" + +"@docusaurus/cssnano-preset@3.6.1": + version "3.6.1" + resolved "https://registry.yarnpkg.com/@docusaurus/cssnano-preset/-/cssnano-preset-3.6.1.tgz#dc07b15f37d5c7bc1e59255ce0fa8825dde2dfb7" + integrity sha512-ZxYUmNeyQHW2w4/PJ7d07jQDuxzmKr9uPAQ6IVe5dTkeIeV0mDBB3jOLeJkNoI42Ru9JKEqQ9aVDtM9ct6QHnw== + dependencies: + cssnano-preset-advanced "^6.1.2" + postcss "^8.4.38" + postcss-sort-media-queries "^5.2.0" + tslib "^2.6.0" + +"@docusaurus/logger@3.6.1": + version "3.6.1" + resolved "https://registry.yarnpkg.com/@docusaurus/logger/-/logger-3.6.1.tgz#724b7f9d8c435c9933d52792458659471ec90919" + integrity sha512-OvetI/nnOMBSqCkUzKAQhnIjhxduECK4qTu3tq/8/h/qqvLsvKURojm04WPE54L+Uy+UXMas0hnbBJd8zDlEOw== + dependencies: + chalk "^4.1.2" + tslib "^2.6.0" + +"@docusaurus/mdx-loader@3.6.1": + version "3.6.1" + resolved "https://registry.yarnpkg.com/@docusaurus/mdx-loader/-/mdx-loader-3.6.1.tgz#6482e6f2f32ccab4a74d8b64d7eeec4fdf9be475" + integrity sha512-KPIsYi0S3X3/rNrW3V1fgOu5t6ahYWc31zTHHod8pacFxdmk9Uf6uuw+Jd6Cly1ilgal+41Ku+s0gmMuqKqiqg== + dependencies: + "@docusaurus/logger" "3.6.1" + "@docusaurus/utils" "3.6.1" + "@docusaurus/utils-validation" "3.6.1" + "@mdx-js/mdx" "^3.0.0" + "@slorber/remark-comment" "^1.0.0" + escape-html "^1.0.3" + estree-util-value-to-estree "^3.0.1" + file-loader "^6.2.0" + fs-extra "^11.1.1" + image-size "^1.0.2" + mdast-util-mdx "^3.0.0" + mdast-util-to-string "^4.0.0" + rehype-raw "^7.0.0" + remark-directive "^3.0.0" + remark-emoji "^4.0.0" + remark-frontmatter "^5.0.0" + remark-gfm "^4.0.0" + stringify-object "^3.3.0" + tslib "^2.6.0" + unified "^11.0.3" + unist-util-visit "^5.0.0" + url-loader "^4.1.1" + vfile "^6.0.1" + webpack "^5.88.1" + "@docusaurus/responsive-loader@^1.7.0": version "1.7.0" resolved "https://registry.yarnpkg.com/@docusaurus/responsive-loader/-/responsive-loader-1.7.0.tgz#508df2779e04311aa2a38efb67cf743109afd681" @@ -2018,6 +2167,70 @@ dependencies: loader-utils "^2.0.0" +"@docusaurus/types@3.6.1": + version "3.6.1" + resolved "https://registry.yarnpkg.com/@docusaurus/types/-/types-3.6.1.tgz#0e55a0a51a3e55658b0845af83d5fe17c495978e" + integrity sha512-hCB1hj9DYutVYBisnPNobz9SzEmCcf1EetJv09O49Cov3BqOkm+vnnjB3d957YJMtpLGQoKBeN/FF1DZ830JwQ== + dependencies: + "@mdx-js/mdx" "^3.0.0" + "@types/history" "^4.7.11" + "@types/react" "*" + commander "^5.1.0" + joi "^17.9.2" + react-helmet-async "^1.3.0" + utility-types "^3.10.0" + webpack "^5.95.0" + webpack-merge "^5.9.0" + +"@docusaurus/utils-common@3.6.1": + version "3.6.1" + resolved "https://registry.yarnpkg.com/@docusaurus/utils-common/-/utils-common-3.6.1.tgz#994160470e6bd2c0eb771f2132883d21b3b6830f" + integrity sha512-LX1qiTiC0aS8c92uZ+Wj2iNCNJyYZJIKY8/nZDKNMBfo759VYVS3RX3fKP3DznB+16sYp7++MyCz/T6fOGaRfw== + dependencies: + "@docusaurus/types" "3.6.1" + tslib "^2.6.0" + +"@docusaurus/utils-validation@3.6.1": + version "3.6.1" + resolved "https://registry.yarnpkg.com/@docusaurus/utils-validation/-/utils-validation-3.6.1.tgz#8e4b5bd8b71f55228543e3fda1301e9fb83df1c6" + integrity sha512-+iMd6zRl5cJQm7nUP+7pSO/oAXsN79eHO34ME7l2YJt4GEAr70l5kkD58u2jEPpp+wSXT70c7x2A2lzJI1E8jw== + dependencies: + "@docusaurus/logger" "3.6.1" + "@docusaurus/utils" "3.6.1" + "@docusaurus/utils-common" "3.6.1" + fs-extra "^11.2.0" + joi "^17.9.2" + js-yaml "^4.1.0" + lodash "^4.17.21" + tslib "^2.6.0" + +"@docusaurus/utils@3.6.1": + version "3.6.1" + resolved "https://registry.yarnpkg.com/@docusaurus/utils/-/utils-3.6.1.tgz#4e4f80be294671bfb83910352d3625878134bf48" + integrity sha512-nS3WCvepwrnBEgSG5vQu40XG95lC9Jeh/odV5u5IhU1eQFEGDst9xBi6IK5yZdsGvbuaXBZLZtOqWYtuuFa/rQ== + dependencies: + "@docusaurus/logger" "3.6.1" + "@docusaurus/types" "3.6.1" + "@docusaurus/utils-common" "3.6.1" + "@svgr/webpack" "^8.1.0" + escape-string-regexp "^4.0.0" + file-loader "^6.2.0" + fs-extra "^11.1.1" + github-slugger "^1.5.0" + globby "^11.1.0" + gray-matter "^4.0.3" + jiti "^1.20.0" + js-yaml "^4.1.0" + lodash "^4.17.21" + micromatch "^4.0.5" + prompts "^2.4.2" + resolve-pathname "^3.0.0" + shelljs "^0.8.5" + tslib "^2.6.0" + url-loader "^4.1.1" + utility-types "^3.10.0" + webpack "^5.88.1" + "@eslint-community/eslint-utils@^4.2.0": version "4.4.0" resolved "https://registry.yarnpkg.com/@eslint-community/eslint-utils/-/eslint-utils-4.4.0.tgz#a23514e8fb9af1269d5f7788aa556798d61c6b59" @@ -5177,7 +5390,7 @@ at-least-node@^1.0.0: resolved "https://registry.yarnpkg.com/at-least-node/-/at-least-node-1.0.0.tgz#602cd4b46e844ad4effc92a8011a3c46e0238dc2" integrity sha512-+q/t7Ekv1EDY2l6Gda6LLiX14rU9TV20Wa3ofeQmwPFZbOMo9DXrLbOjFaaclkXKWidIaopwAObQDqwWtGUjqg== -autoprefixer@^10.4.19: +autoprefixer@^10.4.14, autoprefixer@^10.4.19: version "10.4.20" resolved "https://registry.yarnpkg.com/autoprefixer/-/autoprefixer-10.4.20.tgz#5caec14d43976ef42e32dcb4bd62878e96be5b3b" integrity sha512-XY25y5xSv/wEoqzDyXXME4AFfkZI0P23z6Fs3YgymDnKJkCGOnkL0iTxCa85UTqaSgfcqyf3UA6+c7wUvx/16g== From 6bfff3d48a09958d05f1d1490ca10e14d53a1350 Mon Sep 17 00:00:00 2001 From: sebastien Date: Thu, 21 Nov 2024 11:18:42 +0100 Subject: [PATCH 15/21] fix versions --- packages/docusaurus-plugin-svgr/package.json | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/docusaurus-plugin-svgr/package.json b/packages/docusaurus-plugin-svgr/package.json index 44922470d707..0d5b9d4bcb94 100644 --- a/packages/docusaurus-plugin-svgr/package.json +++ b/packages/docusaurus-plugin-svgr/package.json @@ -18,10 +18,10 @@ }, "license": "MIT", "dependencies": { - "@docusaurus/core": "3.6.1", - "@docusaurus/types": "3.6.1", - "@docusaurus/utils": "3.6.1", - "@docusaurus/utils-validation": "3.6.1", + "@docusaurus/core": "3.6.2", + "@docusaurus/types": "3.6.2", + "@docusaurus/utils": "3.6.2", + "@docusaurus/utils-validation": "3.6.2", "@svgr/core": "8.1.0", "@svgr/webpack": "^8.1.0", "tslib": "^2.6.0", From 8f2db3946261d842706d719b4625a7b24a456ec3 Mon Sep 17 00:00:00 2001 From: slorber Date: Thu, 21 Nov 2024 10:24:45 +0000 Subject: [PATCH 16/21] refactor: apply lint autofix --- yarn.lock | 215 +----------------------------------------------------- 1 file changed, 1 insertion(+), 214 deletions(-) diff --git a/yarn.lock b/yarn.lock index 4ddf0d4f83ec..1ead5c589d83 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2011,155 +2011,6 @@ "@docsearch/css" "3.5.2" algoliasearch "^4.19.1" -"@docusaurus/babel@3.6.1": - version "3.6.1" - resolved "https://registry.yarnpkg.com/@docusaurus/babel/-/babel-3.6.1.tgz#5f48a275934b8164ccac3a6fd1fca3741374c884" - integrity sha512-JcKaunW8Ml2nTnfnvFc55T00Y+aCpNWnf1KY/gG+wWxHYDH0IdXOOz+k6NAlEAerW8+VYLfUqRIqHZ7N/DVXvQ== - dependencies: - "@babel/core" "^7.25.9" - "@babel/generator" "^7.25.9" - "@babel/plugin-syntax-dynamic-import" "^7.8.3" - "@babel/plugin-transform-runtime" "^7.25.9" - "@babel/preset-env" "^7.25.9" - "@babel/preset-react" "^7.25.9" - "@babel/preset-typescript" "^7.25.9" - "@babel/runtime" "^7.25.9" - "@babel/runtime-corejs3" "^7.25.9" - "@babel/traverse" "^7.25.9" - "@docusaurus/logger" "3.6.1" - "@docusaurus/utils" "3.6.1" - babel-plugin-dynamic-import-node "^2.3.3" - fs-extra "^11.1.1" - tslib "^2.6.0" - -"@docusaurus/bundler@3.6.1": - version "3.6.1" - resolved "https://registry.yarnpkg.com/@docusaurus/bundler/-/bundler-3.6.1.tgz#240343d31f39638f987caf54793c09820270ecd5" - integrity sha512-vHSEx8Ku9x/gfIC6k4xb8J2nTxagLia0KvZkPZhxfkD1+n8i+Dj4BZPWTmv+kCA17RbgAvECG0XRZ0/ZEspQBQ== - dependencies: - "@babel/core" "^7.25.9" - "@docusaurus/babel" "3.6.1" - "@docusaurus/cssnano-preset" "3.6.1" - "@docusaurus/logger" "3.6.1" - "@docusaurus/types" "3.6.1" - "@docusaurus/utils" "3.6.1" - autoprefixer "^10.4.14" - babel-loader "^9.2.1" - clean-css "^5.3.2" - copy-webpack-plugin "^11.0.0" - css-loader "^6.8.1" - css-minimizer-webpack-plugin "^5.0.1" - cssnano "^6.1.2" - file-loader "^6.2.0" - html-minifier-terser "^7.2.0" - mini-css-extract-plugin "^2.9.1" - null-loader "^4.0.1" - postcss "^8.4.26" - postcss-loader "^7.3.3" - react-dev-utils "^12.0.1" - terser-webpack-plugin "^5.3.9" - tslib "^2.6.0" - url-loader "^4.1.1" - webpack "^5.95.0" - webpackbar "^6.0.1" - -"@docusaurus/core@3.6.1": - version "3.6.1" - resolved "https://registry.yarnpkg.com/@docusaurus/core/-/core-3.6.1.tgz#260d78e1eb7129ccb441fa944b5f7e6f492ac6cb" - integrity sha512-cDKxPihiM2z7G+4QtpTczS7uxNfNG6naSqM65OmAJET0CFRHbc9mDlLFtQF0lsVES91SHqfcGaaLZmi2FjdwWA== - dependencies: - "@docusaurus/babel" "3.6.1" - "@docusaurus/bundler" "3.6.1" - "@docusaurus/logger" "3.6.1" - "@docusaurus/mdx-loader" "3.6.1" - "@docusaurus/utils" "3.6.1" - "@docusaurus/utils-common" "3.6.1" - "@docusaurus/utils-validation" "3.6.1" - boxen "^6.2.1" - chalk "^4.1.2" - chokidar "^3.5.3" - cli-table3 "^0.6.3" - combine-promises "^1.1.0" - commander "^5.1.0" - core-js "^3.31.1" - del "^6.1.1" - detect-port "^1.5.1" - escape-html "^1.0.3" - eta "^2.2.0" - eval "^0.1.8" - fs-extra "^11.1.1" - html-tags "^3.3.1" - html-webpack-plugin "^5.6.0" - leven "^3.1.0" - lodash "^4.17.21" - p-map "^4.0.0" - prompts "^2.4.2" - react-dev-utils "^12.0.1" - react-helmet-async "^1.3.0" - react-loadable "npm:@docusaurus/react-loadable@6.0.0" - react-loadable-ssr-addon-v5-slorber "^1.0.1" - react-router "^5.3.4" - react-router-config "^5.1.1" - react-router-dom "^5.3.4" - rtl-detect "^1.0.4" - semver "^7.5.4" - serve-handler "^6.1.6" - shelljs "^0.8.5" - tslib "^2.6.0" - update-notifier "^6.0.2" - webpack "^5.95.0" - webpack-bundle-analyzer "^4.10.2" - webpack-dev-server "^4.15.2" - webpack-merge "^6.0.1" - -"@docusaurus/cssnano-preset@3.6.1": - version "3.6.1" - resolved "https://registry.yarnpkg.com/@docusaurus/cssnano-preset/-/cssnano-preset-3.6.1.tgz#dc07b15f37d5c7bc1e59255ce0fa8825dde2dfb7" - integrity sha512-ZxYUmNeyQHW2w4/PJ7d07jQDuxzmKr9uPAQ6IVe5dTkeIeV0mDBB3jOLeJkNoI42Ru9JKEqQ9aVDtM9ct6QHnw== - dependencies: - cssnano-preset-advanced "^6.1.2" - postcss "^8.4.38" - postcss-sort-media-queries "^5.2.0" - tslib "^2.6.0" - -"@docusaurus/logger@3.6.1": - version "3.6.1" - resolved "https://registry.yarnpkg.com/@docusaurus/logger/-/logger-3.6.1.tgz#724b7f9d8c435c9933d52792458659471ec90919" - integrity sha512-OvetI/nnOMBSqCkUzKAQhnIjhxduECK4qTu3tq/8/h/qqvLsvKURojm04WPE54L+Uy+UXMas0hnbBJd8zDlEOw== - dependencies: - chalk "^4.1.2" - tslib "^2.6.0" - -"@docusaurus/mdx-loader@3.6.1": - version "3.6.1" - resolved "https://registry.yarnpkg.com/@docusaurus/mdx-loader/-/mdx-loader-3.6.1.tgz#6482e6f2f32ccab4a74d8b64d7eeec4fdf9be475" - integrity sha512-KPIsYi0S3X3/rNrW3V1fgOu5t6ahYWc31zTHHod8pacFxdmk9Uf6uuw+Jd6Cly1ilgal+41Ku+s0gmMuqKqiqg== - dependencies: - "@docusaurus/logger" "3.6.1" - "@docusaurus/utils" "3.6.1" - "@docusaurus/utils-validation" "3.6.1" - "@mdx-js/mdx" "^3.0.0" - "@slorber/remark-comment" "^1.0.0" - escape-html "^1.0.3" - estree-util-value-to-estree "^3.0.1" - file-loader "^6.2.0" - fs-extra "^11.1.1" - image-size "^1.0.2" - mdast-util-mdx "^3.0.0" - mdast-util-to-string "^4.0.0" - rehype-raw "^7.0.0" - remark-directive "^3.0.0" - remark-emoji "^4.0.0" - remark-frontmatter "^5.0.0" - remark-gfm "^4.0.0" - stringify-object "^3.3.0" - tslib "^2.6.0" - unified "^11.0.3" - unist-util-visit "^5.0.0" - url-loader "^4.1.1" - vfile "^6.0.1" - webpack "^5.88.1" - "@docusaurus/responsive-loader@^1.7.0": version "1.7.0" resolved "https://registry.yarnpkg.com/@docusaurus/responsive-loader/-/responsive-loader-1.7.0.tgz#508df2779e04311aa2a38efb67cf743109afd681" @@ -2167,70 +2018,6 @@ dependencies: loader-utils "^2.0.0" -"@docusaurus/types@3.6.1": - version "3.6.1" - resolved "https://registry.yarnpkg.com/@docusaurus/types/-/types-3.6.1.tgz#0e55a0a51a3e55658b0845af83d5fe17c495978e" - integrity sha512-hCB1hj9DYutVYBisnPNobz9SzEmCcf1EetJv09O49Cov3BqOkm+vnnjB3d957YJMtpLGQoKBeN/FF1DZ830JwQ== - dependencies: - "@mdx-js/mdx" "^3.0.0" - "@types/history" "^4.7.11" - "@types/react" "*" - commander "^5.1.0" - joi "^17.9.2" - react-helmet-async "^1.3.0" - utility-types "^3.10.0" - webpack "^5.95.0" - webpack-merge "^5.9.0" - -"@docusaurus/utils-common@3.6.1": - version "3.6.1" - resolved "https://registry.yarnpkg.com/@docusaurus/utils-common/-/utils-common-3.6.1.tgz#994160470e6bd2c0eb771f2132883d21b3b6830f" - integrity sha512-LX1qiTiC0aS8c92uZ+Wj2iNCNJyYZJIKY8/nZDKNMBfo759VYVS3RX3fKP3DznB+16sYp7++MyCz/T6fOGaRfw== - dependencies: - "@docusaurus/types" "3.6.1" - tslib "^2.6.0" - -"@docusaurus/utils-validation@3.6.1": - version "3.6.1" - resolved "https://registry.yarnpkg.com/@docusaurus/utils-validation/-/utils-validation-3.6.1.tgz#8e4b5bd8b71f55228543e3fda1301e9fb83df1c6" - integrity sha512-+iMd6zRl5cJQm7nUP+7pSO/oAXsN79eHO34ME7l2YJt4GEAr70l5kkD58u2jEPpp+wSXT70c7x2A2lzJI1E8jw== - dependencies: - "@docusaurus/logger" "3.6.1" - "@docusaurus/utils" "3.6.1" - "@docusaurus/utils-common" "3.6.1" - fs-extra "^11.2.0" - joi "^17.9.2" - js-yaml "^4.1.0" - lodash "^4.17.21" - tslib "^2.6.0" - -"@docusaurus/utils@3.6.1": - version "3.6.1" - resolved "https://registry.yarnpkg.com/@docusaurus/utils/-/utils-3.6.1.tgz#4e4f80be294671bfb83910352d3625878134bf48" - integrity sha512-nS3WCvepwrnBEgSG5vQu40XG95lC9Jeh/odV5u5IhU1eQFEGDst9xBi6IK5yZdsGvbuaXBZLZtOqWYtuuFa/rQ== - dependencies: - "@docusaurus/logger" "3.6.1" - "@docusaurus/types" "3.6.1" - "@docusaurus/utils-common" "3.6.1" - "@svgr/webpack" "^8.1.0" - escape-string-regexp "^4.0.0" - file-loader "^6.2.0" - fs-extra "^11.1.1" - github-slugger "^1.5.0" - globby "^11.1.0" - gray-matter "^4.0.3" - jiti "^1.20.0" - js-yaml "^4.1.0" - lodash "^4.17.21" - micromatch "^4.0.5" - prompts "^2.4.2" - resolve-pathname "^3.0.0" - shelljs "^0.8.5" - tslib "^2.6.0" - url-loader "^4.1.1" - utility-types "^3.10.0" - webpack "^5.88.1" - "@eslint-community/eslint-utils@^4.2.0": version "4.4.0" resolved "https://registry.yarnpkg.com/@eslint-community/eslint-utils/-/eslint-utils-4.4.0.tgz#a23514e8fb9af1269d5f7788aa556798d61c6b59" @@ -5390,7 +5177,7 @@ at-least-node@^1.0.0: resolved "https://registry.yarnpkg.com/at-least-node/-/at-least-node-1.0.0.tgz#602cd4b46e844ad4effc92a8011a3c46e0238dc2" integrity sha512-+q/t7Ekv1EDY2l6Gda6LLiX14rU9TV20Wa3ofeQmwPFZbOMo9DXrLbOjFaaclkXKWidIaopwAObQDqwWtGUjqg== -autoprefixer@^10.4.14, autoprefixer@^10.4.19: +autoprefixer@^10.4.19: version "10.4.20" resolved "https://registry.yarnpkg.com/autoprefixer/-/autoprefixer-10.4.20.tgz#5caec14d43976ef42e32dcb4bd62878e96be5b3b" integrity sha512-XY25y5xSv/wEoqzDyXXME4AFfkZI0P23z6Fs3YgymDnKJkCGOnkL0iTxCa85UTqaSgfcqyf3UA6+c7wUvx/16g== From 524c4f01f122f4a8772f2129ac115dca1ca9fa99 Mon Sep 17 00:00:00 2001 From: sebastien Date: Thu, 21 Nov 2024 12:08:37 +0100 Subject: [PATCH 17/21] empty From 1ee22a440b22115b2fc62f81e45d2d28c820e39f Mon Sep 17 00:00:00 2001 From: sebastien Date: Thu, 21 Nov 2024 12:24:28 +0100 Subject: [PATCH 18/21] Add svg ambiant types comment todo --- packages/docusaurus-module-type-aliases/src/index.d.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/packages/docusaurus-module-type-aliases/src/index.d.ts b/packages/docusaurus-module-type-aliases/src/index.d.ts index 7fb78549f13d..2fc6b3e66925 100644 --- a/packages/docusaurus-module-type-aliases/src/index.d.ts +++ b/packages/docusaurus-module-type-aliases/src/index.d.ts @@ -369,6 +369,9 @@ declare module '@docusaurus/useGlobalData' { export default function useGlobalData(): GlobalData; } +// TODO find a way to move this ambiant type to the SVGR plugin? +// unfortunately looks complicated in practice +// see https://x.com/sebastienlorber/status/1859543512661832053 declare module '*.svg' { import type {ComponentType, SVGProps} from 'react'; From 7226854ce90bc245785e434be1ba8ef117588ab6 Mon Sep 17 00:00:00 2001 From: slorber Date: Thu, 21 Nov 2024 11:29:42 +0000 Subject: [PATCH 19/21] refactor: apply lint autofix --- project-words.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/project-words.txt b/project-words.txt index 9cef579226d0..799dd527acef 100644 --- a/project-words.txt +++ b/project-words.txt @@ -6,6 +6,7 @@ alexbdebrie Alexey algoliasearch Allez +ambiant anshul Anshul apfs From 7bf5901335d185a21606497e6c4da045c89070b1 Mon Sep 17 00:00:00 2001 From: sebastien Date: Fri, 29 Nov 2024 16:59:53 +0100 Subject: [PATCH 20/21] fix versions --- packages/docusaurus-plugin-svgr/package.json | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/packages/docusaurus-plugin-svgr/package.json b/packages/docusaurus-plugin-svgr/package.json index 0d5b9d4bcb94..c4af737e688f 100644 --- a/packages/docusaurus-plugin-svgr/package.json +++ b/packages/docusaurus-plugin-svgr/package.json @@ -1,6 +1,6 @@ { "name": "@docusaurus/plugin-svgr", - "version": "3.6.2", + "version": "3.6.3", "description": "SVGR plugin for Docusaurus.", "main": "lib/index.js", "types": "lib/index.d.ts", @@ -18,10 +18,10 @@ }, "license": "MIT", "dependencies": { - "@docusaurus/core": "3.6.2", - "@docusaurus/types": "3.6.2", - "@docusaurus/utils": "3.6.2", - "@docusaurus/utils-validation": "3.6.2", + "@docusaurus/core": "3.6.3", + "@docusaurus/types": "3.6.3", + "@docusaurus/utils": "3.6.3", + "@docusaurus/utils-validation": "3.6.3", "@svgr/core": "8.1.0", "@svgr/webpack": "^8.1.0", "tslib": "^2.6.0", From 1f8f6e3b7c6b5fb4bf4981769de437f5126bd01c Mon Sep 17 00:00:00 2001 From: sebastien Date: Fri, 29 Nov 2024 17:04:52 +0100 Subject: [PATCH 21/21] fix typo --- packages/docusaurus-module-type-aliases/src/index.d.ts | 2 +- project-words.txt | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/packages/docusaurus-module-type-aliases/src/index.d.ts b/packages/docusaurus-module-type-aliases/src/index.d.ts index 2fc6b3e66925..8b4a2701676d 100644 --- a/packages/docusaurus-module-type-aliases/src/index.d.ts +++ b/packages/docusaurus-module-type-aliases/src/index.d.ts @@ -369,7 +369,7 @@ declare module '@docusaurus/useGlobalData' { export default function useGlobalData(): GlobalData; } -// TODO find a way to move this ambiant type to the SVGR plugin? +// TODO find a way to move this ambient type to the SVGR plugin? // unfortunately looks complicated in practice // see https://x.com/sebastienlorber/status/1859543512661832053 declare module '*.svg' { diff --git a/project-words.txt b/project-words.txt index 799dd527acef..9cef579226d0 100644 --- a/project-words.txt +++ b/project-words.txt @@ -6,7 +6,6 @@ alexbdebrie Alexey algoliasearch Allez -ambiant anshul Anshul apfs