svg / svgo

⚙️ Node.js tool for optimizing SVG files
https://svgo.dev/
MIT License
20.88k stars 1.39k forks source link

add: centralize exports to svgo #2071

Closed SethFalco closed 3 weeks ago

SethFalco commented 3 weeks ago

For SVGO v4, we're changed how we handle exports.

We use the exports field in package.json to define the public interface of the package. This enforces boundaries between the intended public API and any internal structures/helpers that we use internally.

https://github.com/svg/svgo/releases/tag/v4.0.0-rc.0

I had omitted most of the exports before, as they were mostly intended for SVGO itself to consume. However, consumers of the library are using these functions while maintaining their custom plugins, so we're changing how they're exported, but the functions will otherwise still be available in v4.

- import { querySelector, querySelectorAll } from 'svgo/lib/xast.js';
+ import { querySelector, querySelectorAll } from 'svgo';

- import _collections from 'svgo/plugins/_collections';
+ import _collections from 'svgo';

- import type { XastElement, XastRoot, XastChild } from 'svgo/lib/types';
+ import type { XastElement, XastRoot, XastChild } from 'svgo';

You get the idea, similar to other libraries like React, we're pretty much exporting everything from our top-level namespace, i.e. svgo and svgo/browser.