gregberge / svgr

Transform SVGs into React components 🦁
https://react-svgr.com
MIT License
10.59k stars 422 forks source link

React-SVGR docs show config for v5, not v6+ #863

Open KevinGhadyani-Okta opened 1 year ago

KevinGhadyani-Okta commented 1 year ago

Going through the TypeScript types for Config in @svgr/core, it's missing two options still listed in the website but that no longer exist in the code: ignoreExisting and indexTemplate.

interface Config {
    ref?: boolean;
    titleProp?: boolean;
    descProp?: boolean;
    expandProps?: boolean | 'start' | 'end';
    dimensions?: boolean;
    icon?: boolean | string | number;
    native?: boolean;
    svgProps?: {
        [key: string]: string;
    };
    replaceAttrValues?: {
        [key: string]: string;
    };
    runtimeConfig?: boolean;
    typescript?: boolean;
    prettier?: boolean;
    prettierConfig?: Options;
    svgo?: boolean;
    svgoConfig?: Config$1;
    configFile?: string;
    template?: Options$1['template'];
    memo?: boolean;
    exportType?: 'named' | 'default';
    namedExport?: string;
    jsxRuntime?: 'classic' | 'classic-preact' | 'automatic';
    jsxRuntimeImport?: {
        source: string;
        namespace?: string;
        specifiers?: string[];
        defaultSpecifier?: string;
    };
    index?: boolean;
    plugins?: ConfigPlugin[];
    jsx?: {
        babelConfig?: TransformOptions;
    };
}

In the TS for Config, there's no option here for ignoreExisting nor indexTemplate. Both of these are still documented on the website:

image Source: https://react-svgr.com/docs/options/#indexjs-template

But they're not in the output index.js anymore. It's possible ignoreExisting isn't required anymore, but what about indexTemplate? How am I supposed to template the index file?

gregberge commented 1 year ago

These options are CLI only. It means the error is to has "API Override" for these options. Could you please fix the doc?

KevinGhadyani-Okta commented 1 year ago

I'd actually like it if those could also work with the API. They worked previously in v5, but now they're not there anymore. Can we match the API spec to the CLI capabilities?

demedos commented 2 months ago

There you go: https://github.com/gregberge/svgr/pull/972 I spent some time to convert a rather complex cli command to api and just figured it out; it would be awesome to have those options in the API too.

Related: https://github.com/gregberge/svgr/issues/532