react-icons-sprite 1.0.1 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{build-sprite-DgeWMz2D.mjs → build-sprite-CxqvU2LE.mjs} +46 -4
- package/dist/{collector-DxE_zcTH.mjs → collector-CBRz9R_h.mjs} +1 -1
- package/dist/{compute-icon-id-CVIo3z9m.mjs → compute-icon-id-Xx4G3fva.mjs} +17 -2
- package/dist/icon.d.mts +1 -5
- package/dist/index.d.mts +0 -1
- package/dist/{transform-module-CIpNj5Na.mjs → transform-module-1am5uV8-.mjs} +113 -6
- package/dist/vite/plugin.d.mts +0 -1
- package/dist/vite/plugin.mjs +3 -3
- package/dist/webpack/loader.d.mts +0 -1
- package/dist/webpack/loader.mjs +2 -2
- package/dist/webpack/plugin.d.mts +0 -1
- package/dist/webpack/plugin.mjs +2 -2
- package/package.json +102 -13
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { i as resolveIconImport, t as computeIconId } from "./compute-icon-id-
|
|
1
|
+
import { i as resolveIconImport, t as computeIconId } from "./compute-icon-id-Xx4G3fva.mjs";
|
|
2
2
|
import { existsSync, readFileSync } from "node:fs";
|
|
3
3
|
import path from "node:path";
|
|
4
4
|
import { pathToFileURL } from "node:url";
|
|
@@ -9,7 +9,7 @@ const SVG_INNER_RE = /<svg\b[^>]*>([\s\S]*?)<\/svg>/i;
|
|
|
9
9
|
const VIEWBOX_RE = /viewBox=["']([^"']+)["']/i;
|
|
10
10
|
const SVG_OPEN_RE = /<svg\b([^>]*)>/i;
|
|
11
11
|
const SVG_ATTR_RE = /([:\w-]+)=("[^"]*"|'[^']*')/g;
|
|
12
|
-
const OMITTED_SVG_ATTRIBUTES = new Set([
|
|
12
|
+
const OMITTED_SVG_ATTRIBUTES = /* @__PURE__ */ new Set([
|
|
13
13
|
"xmlns",
|
|
14
14
|
"viewBox",
|
|
15
15
|
"width",
|
|
@@ -74,7 +74,10 @@ const resolveFromBaseDir = (specifier, baseDir) => {
|
|
|
74
74
|
if (!packageRoot) return null;
|
|
75
75
|
const packageJson = JSON.parse(readFileSync(path.join(packageRoot, "package.json"), "utf8"));
|
|
76
76
|
const exportTarget = resolveExportTarget(packageJson.exports, parsed.subpath);
|
|
77
|
-
if (exportTarget)
|
|
77
|
+
if (exportTarget) {
|
|
78
|
+
const resolved = resolveFileCandidate(path.join(packageRoot, exportTarget));
|
|
79
|
+
if (resolved) return resolved;
|
|
80
|
+
}
|
|
78
81
|
if (parsed.subpath === ".") {
|
|
79
82
|
const entry = packageJson.module ?? packageJson.main;
|
|
80
83
|
if (entry) return resolveFileCandidate(path.join(packageRoot, entry));
|
|
@@ -100,6 +103,11 @@ const pickExport = (moduleExports, exportName) => {
|
|
|
100
103
|
if (exportName === "default") return moduleExports.default;
|
|
101
104
|
return moduleExports[exportName] ?? moduleExports.default;
|
|
102
105
|
};
|
|
106
|
+
const unwrapNestedDefaultExport = (value) => {
|
|
107
|
+
if (!value || typeof value !== "object" || !("default" in value)) return value;
|
|
108
|
+
if ("$$typeof" in value) return value;
|
|
109
|
+
return value.default;
|
|
110
|
+
};
|
|
103
111
|
const isRenderableComponent = (value) => {
|
|
104
112
|
if (typeof value === "function") return true;
|
|
105
113
|
if (!value || typeof value !== "object") return false;
|
|
@@ -111,6 +119,13 @@ const isFontAwesomeIconDefinition = (value) => {
|
|
|
111
119
|
if (!Array.isArray(icon) || icon.length < 5) return false;
|
|
112
120
|
return typeof icon[0] === "number" && typeof icon[1] === "number";
|
|
113
121
|
};
|
|
122
|
+
const isHugeiconsIconDefinition = (value) => {
|
|
123
|
+
if (!Array.isArray(value)) return false;
|
|
124
|
+
return value.every((item) => {
|
|
125
|
+
if (!Array.isArray(item) || item.length < 2) return false;
|
|
126
|
+
return typeof item[0] === "string" && typeof item[1] === "object";
|
|
127
|
+
});
|
|
128
|
+
};
|
|
114
129
|
const renderFontAwesomeIconDefinition = (iconDefinition) => {
|
|
115
130
|
const [width, height, , , svgPathData] = iconDefinition.icon;
|
|
116
131
|
return {
|
|
@@ -119,9 +134,36 @@ const renderFontAwesomeIconDefinition = (iconDefinition) => {
|
|
|
119
134
|
symbolAttributes: ""
|
|
120
135
|
};
|
|
121
136
|
};
|
|
137
|
+
const renderHugeiconsIconDefinition = (iconDefinition) => {
|
|
138
|
+
const svgMarkup = renderToStaticMarkup(createElement("svg", {
|
|
139
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
140
|
+
viewBox: "0 0 24 24",
|
|
141
|
+
fill: "none",
|
|
142
|
+
color: "currentColor"
|
|
143
|
+
}, [...iconDefinition].sort(([, a], [, b]) => {
|
|
144
|
+
const hasOpacityA = a.opacity !== void 0;
|
|
145
|
+
return b.opacity !== void 0 ? 1 : hasOpacityA ? -1 : 0;
|
|
146
|
+
}).map(([tag, attributes]) => {
|
|
147
|
+
const { key, ...rest } = attributes;
|
|
148
|
+
return createElement(tag, {
|
|
149
|
+
...rest,
|
|
150
|
+
key
|
|
151
|
+
});
|
|
152
|
+
})));
|
|
153
|
+
const svgInner = SVG_INNER_RE.exec(svgMarkup)?.[1];
|
|
154
|
+
if (!svgInner) throw new Error("[react-icons-sprite] Unable to extract SVG content for Hugeicons icon.");
|
|
155
|
+
return {
|
|
156
|
+
symbolBody: svgInner,
|
|
157
|
+
viewBox: "0 0 24 24",
|
|
158
|
+
symbolAttributes: extractSymbolAttributes(svgMarkup)
|
|
159
|
+
};
|
|
160
|
+
};
|
|
122
161
|
const renderIcon = async (pack, exportName, options = {}) => {
|
|
123
|
-
const
|
|
162
|
+
const importPath = resolveIconImport(pack, exportName);
|
|
163
|
+
const imported = await import(resolveImportSpecifier(importPath, options));
|
|
164
|
+
const iconComponent = unwrapNestedDefaultExport(pickExport(imported, exportName));
|
|
124
165
|
if (isFontAwesomeIconDefinition(iconComponent)) return renderFontAwesomeIconDefinition(iconComponent);
|
|
166
|
+
if (isHugeiconsIconDefinition(iconComponent)) return renderHugeiconsIconDefinition(iconComponent);
|
|
125
167
|
if (!isRenderableComponent(iconComponent)) throw new Error(`[react-icons-sprite] Unable to render icon "${exportName}" from "${pack}". Expected a React component export.`);
|
|
126
168
|
const svgMarkup = renderToStaticMarkup(createElement(iconComponent));
|
|
127
169
|
const svgInner = SVG_INNER_RE.exec(svgMarkup)?.[1];
|
|
@@ -41,9 +41,16 @@ const DEFAULT_ICON_SOURCES = [
|
|
|
41
41
|
/^@remixicon\/react$/,
|
|
42
42
|
/^devicons-react$/,
|
|
43
43
|
/^@mui\/icons-material(?:\/.*)?$/,
|
|
44
|
-
/^@carbon\/icons-react
|
|
44
|
+
/^@carbon\/icons-react$/,
|
|
45
|
+
/^@ant-design\/icons(?:\/.*)?$/,
|
|
46
|
+
/^@fluentui\/react-icons(?:\/svg\/[\w-]+)?$/,
|
|
47
|
+
/^@primer\/octicons-react$/,
|
|
48
|
+
/^@hugeicons\/core-free-icons(?:\/.*)?$/
|
|
45
49
|
];
|
|
46
50
|
const phosphorIconPathName = (name) => name.endsWith("Icon") ? name.slice(0, -4) : name;
|
|
51
|
+
const fluentIconPathName = (name) => {
|
|
52
|
+
return kebabCase(name.replace(/(?:12|16|20|24|28|32|48)?(?:Regular|Filled|Light|Resizable|Color)$/, ""));
|
|
53
|
+
};
|
|
47
54
|
const exactResolvers = {
|
|
48
55
|
"lucide-react": (pack, name) => `${pack}/dist/esm/icons/${kebabCase(name)}.mjs`,
|
|
49
56
|
"@radix-ui/react-icons": (pack) => `${pack}/dist/react-icons.esm.js`,
|
|
@@ -54,12 +61,20 @@ const exactResolvers = {
|
|
|
54
61
|
"react-feather": (pack, name) => `${pack}/dist/icons/${kebabCase(name)}.js`,
|
|
55
62
|
"grommet-icons": (pack, name) => `${pack}/icons/${name}.js`,
|
|
56
63
|
"devicons-react": (pack, name) => `${pack}/icons/${name}`,
|
|
57
|
-
"@carbon/icons-react": (pack, name) => `${pack}/es/${name}.js
|
|
64
|
+
"@carbon/icons-react": (pack, name) => `${pack}/es/${name}.js`,
|
|
65
|
+
"@ant-design/icons": (pack, name) => `${pack}/lib/icons/${name}.js`,
|
|
66
|
+
"@fluentui/react-icons": (pack, name) => `${pack}/lib-cjs/atoms/svg/${fluentIconPathName(name)}.js`,
|
|
67
|
+
"@primer/octicons-react": (pack) => pack,
|
|
68
|
+
"@hugeicons/core-free-icons": (pack, name) => `${pack}/${name}`
|
|
58
69
|
};
|
|
59
70
|
const resolveIconImport = (pack, exportName) => {
|
|
60
71
|
const exactResolver = exactResolvers[pack];
|
|
61
72
|
if (exactResolver) return exactResolver(pack, exportName);
|
|
62
73
|
if (/^@mui\/icons-material(?:\/.*)?$/.test(pack)) return pack.split("/").length > 2 ? pack : `${pack}/${exportName}`;
|
|
74
|
+
if (/^@ant-design\/icons\/.+$/.test(pack)) return `@ant-design/icons/lib/icons/${exportName === "default" ? pack.split("/").at(-1) : exportName}.js`;
|
|
75
|
+
const fluentSubpath = /^@fluentui\/react-icons\/svg\/(.+)$/.exec(pack);
|
|
76
|
+
if (fluentSubpath) return `@fluentui/react-icons/lib-cjs/atoms/svg/${fluentSubpath[1]}.js`;
|
|
77
|
+
if (/^@hugeicons\/core-free-icons\/.+$/.test(pack)) return pack;
|
|
63
78
|
if (/^@heroicons\/react\/(?:\d{2})\/(?:outline|solid)$/.test(pack)) return `${pack}/${exportName}`;
|
|
64
79
|
if (/^@fortawesome\/[\w-]+-svg-icons$/.test(pack)) return `${pack}/${exportName}`;
|
|
65
80
|
return pack;
|
package/dist/icon.d.mts
CHANGED
|
@@ -1,12 +1,8 @@
|
|
|
1
1
|
import { JSX, SVGProps } from "react";
|
|
2
|
-
|
|
3
2
|
//#region src/icon.d.ts
|
|
4
3
|
type IconProps = SVGProps<SVGSVGElement> & {
|
|
5
4
|
iconId: string;
|
|
6
5
|
};
|
|
7
|
-
declare const ReactIconsSpriteIcon: ({
|
|
8
|
-
iconId,
|
|
9
|
-
...rest
|
|
10
|
-
}: IconProps) => JSX.Element;
|
|
6
|
+
declare const ReactIconsSpriteIcon: ({ iconId, ...rest }: IconProps) => JSX.Element;
|
|
11
7
|
//#endregion
|
|
12
8
|
export { IconProps, ReactIconsSpriteIcon };
|
package/dist/index.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { n as normalizePackAlias, r as DEFAULT_ICON_SOURCES } from "./compute-icon-id-
|
|
1
|
+
import { n as normalizePackAlias, r as DEFAULT_ICON_SOURCES } from "./compute-icon-id-Xx4G3fva.mjs";
|
|
2
2
|
import MagicString from "magic-string";
|
|
3
3
|
//#region src/transform/edit-applier.ts
|
|
4
4
|
const applyEdits = (code, edits) => {
|
|
@@ -52,9 +52,13 @@ const fastFilter = (code) => {
|
|
|
52
52
|
const ICON_SOURCE = "react-icons-sprite";
|
|
53
53
|
const ICON_COMPONENT_NAME = "ReactIconsSpriteIcon";
|
|
54
54
|
const FONTAWESOME_REACT_PACK = "@fortawesome/react-fontawesome";
|
|
55
|
+
const HUGEICONS_REACT_PACK = "@hugeicons/react";
|
|
55
56
|
const isFontAwesomeIconPack = (pack) => {
|
|
56
57
|
return /^@fortawesome\/[\w-]+-svg-icons$/.test(pack);
|
|
57
58
|
};
|
|
59
|
+
const isHugeiconsIconPack = (pack) => {
|
|
60
|
+
return /^@hugeicons\/core-free-icons(?:\/.*)?$/.test(pack);
|
|
61
|
+
};
|
|
58
62
|
const sourceMatches = (source, pack) => {
|
|
59
63
|
source.lastIndex = 0;
|
|
60
64
|
return source.test(pack);
|
|
@@ -74,7 +78,8 @@ const parseNamedSpecifiers = (specifier, specifierOffset, imports) => {
|
|
|
74
78
|
let segmentStart = start + 1;
|
|
75
79
|
for (let index = start + 1; index <= end; index += 1) {
|
|
76
80
|
if (index !== end && specifier[index] !== ",") continue;
|
|
77
|
-
const
|
|
81
|
+
const segment = specifier.slice(segmentStart, index);
|
|
82
|
+
const range = trimRange(segment, specifierOffset + segmentStart);
|
|
78
83
|
segmentStart = index + 1;
|
|
79
84
|
if (!range) continue;
|
|
80
85
|
const text = specifier.slice(range[0] - specifierOffset, range[1] - specifierOffset);
|
|
@@ -111,7 +116,8 @@ const scanImportsDetailed = (code, sources) => {
|
|
|
111
116
|
const specifierOffset = matchStart + statement.indexOf(specifier);
|
|
112
117
|
const specifiers = [];
|
|
113
118
|
const braceStart = specifier.indexOf("{");
|
|
114
|
-
const
|
|
119
|
+
const defaultText = (braceStart === -1 ? specifier : specifier.slice(0, braceStart)).replace(/,$/, "");
|
|
120
|
+
const defaultRange = trimRange(defaultText, specifierOffset);
|
|
115
121
|
if (defaultRange && !specifier.slice(defaultRange[0] - specifierOffset, defaultRange[1] - specifierOffset).startsWith("type ")) {
|
|
116
122
|
const local = specifier.slice(defaultRange[0] - specifierOffset, defaultRange[1] - specifierOffset);
|
|
117
123
|
if (local && /^[A-Za-z_$][\w$]*$/.test(local)) specifiers.push({
|
|
@@ -307,6 +313,47 @@ const scanFontAwesomeUsages = (code, symbols, componentLocals) => {
|
|
|
307
313
|
}
|
|
308
314
|
return usages;
|
|
309
315
|
};
|
|
316
|
+
const scanHugeiconsComponents = (code) => {
|
|
317
|
+
const locals = /* @__PURE__ */ new Set();
|
|
318
|
+
IMPORT_RE.lastIndex = 0;
|
|
319
|
+
for (const match of code.matchAll(IMPORT_RE)) {
|
|
320
|
+
const [, specifier, , source] = match;
|
|
321
|
+
if (source !== HUGEICONS_REACT_PACK) continue;
|
|
322
|
+
const specifiers = [];
|
|
323
|
+
parseNamedSpecifiers(specifier, match.index + match[0].indexOf(specifier), specifiers);
|
|
324
|
+
for (const item of specifiers) if (item.exportName === "HugeiconsIcon") locals.add(item.local);
|
|
325
|
+
}
|
|
326
|
+
return locals;
|
|
327
|
+
};
|
|
328
|
+
const scanHugeiconsUsages = (code, symbols, componentLocals) => {
|
|
329
|
+
if (!componentLocals.size) return [];
|
|
330
|
+
const names = [...componentLocals].map(escapeRegExp).join("|");
|
|
331
|
+
const tagRe = new RegExp(`<\\s*(${names})\\b`, "g");
|
|
332
|
+
const usages = [];
|
|
333
|
+
for (const match of code.matchAll(tagRe)) {
|
|
334
|
+
const componentLocal = match[1];
|
|
335
|
+
const componentStart = match.index + match[0].lastIndexOf(componentLocal);
|
|
336
|
+
const tagEnd = findJsxOpeningTagEnd(code, componentStart + componentLocal.length);
|
|
337
|
+
if (tagEnd === -1) continue;
|
|
338
|
+
const attributes = code.slice(componentStart + componentLocal.length, tagEnd);
|
|
339
|
+
const iconMatch = /\sicon\s*=\s*\{\s*([A-Za-z_$][\w$]*)\s*\}/.exec(attributes);
|
|
340
|
+
if (!iconMatch || iconMatch.index === void 0) continue;
|
|
341
|
+
const symbol = symbols.items[iconMatch[1]];
|
|
342
|
+
if (!symbol || !isHugeiconsIconPack(symbol.pack)) continue;
|
|
343
|
+
const attributeStart = componentStart + componentLocal.length + iconMatch.index;
|
|
344
|
+
usages.push({
|
|
345
|
+
componentLocal,
|
|
346
|
+
componentRange: [componentStart, componentStart + componentLocal.length],
|
|
347
|
+
iconAttributeRange: [attributeStart, attributeStart + iconMatch[0].length],
|
|
348
|
+
iconLocal: iconMatch[1],
|
|
349
|
+
pack: symbol.pack,
|
|
350
|
+
exportName: symbol.exportName,
|
|
351
|
+
iconId: symbol.iconId,
|
|
352
|
+
hasIconId: /\biconId\s*=/.test(attributes)
|
|
353
|
+
});
|
|
354
|
+
}
|
|
355
|
+
return usages;
|
|
356
|
+
};
|
|
310
357
|
const cleanupScannedImports = (code, imports, usedLocals) => {
|
|
311
358
|
const edits = [];
|
|
312
359
|
for (const item of imports) {
|
|
@@ -360,6 +407,35 @@ const cleanupScannedFontAwesomeComponentImports = (code, usedLocals) => {
|
|
|
360
407
|
}
|
|
361
408
|
return edits;
|
|
362
409
|
};
|
|
410
|
+
const cleanupScannedHugeiconsComponentImports = (code, usedLocals) => {
|
|
411
|
+
const edits = [];
|
|
412
|
+
IMPORT_RE.lastIndex = 0;
|
|
413
|
+
for (const match of code.matchAll(IMPORT_RE)) {
|
|
414
|
+
const [statement, specifier, , source] = match;
|
|
415
|
+
if (source !== HUGEICONS_REACT_PACK) continue;
|
|
416
|
+
const specifiers = [];
|
|
417
|
+
parseNamedSpecifiers(specifier, match.index + statement.indexOf(specifier), specifiers);
|
|
418
|
+
const removableSpecifiers = specifiers.filter((item) => item.exportName === "HugeiconsIcon" && usedLocals.has(item.local));
|
|
419
|
+
if (!removableSpecifiers.length) continue;
|
|
420
|
+
if (removableSpecifiers.length === specifiers.length) {
|
|
421
|
+
edits.push({
|
|
422
|
+
type: "remove",
|
|
423
|
+
from: match.index,
|
|
424
|
+
to: extendToLineEnd(code, match.index + statement.length)
|
|
425
|
+
});
|
|
426
|
+
continue;
|
|
427
|
+
}
|
|
428
|
+
for (const specifier of removableSpecifiers) {
|
|
429
|
+
const [from, to] = specifierRemovalRange(code, specifier.range);
|
|
430
|
+
edits.push({
|
|
431
|
+
type: "remove",
|
|
432
|
+
from,
|
|
433
|
+
to
|
|
434
|
+
});
|
|
435
|
+
}
|
|
436
|
+
}
|
|
437
|
+
return edits;
|
|
438
|
+
};
|
|
363
439
|
const extendToLineEnd = (code, end) => {
|
|
364
440
|
let to = end;
|
|
365
441
|
while (to < code.length) {
|
|
@@ -404,6 +480,7 @@ const transformModule = (code, id, register, sources = DEFAULT_ICON_SOURCES, opt
|
|
|
404
480
|
anyReplacements: false
|
|
405
481
|
};
|
|
406
482
|
const hasPotentialFontAwesomeUsage = code.includes(FONTAWESOME_REACT_PACK) && scannedImports.some((item) => isFontAwesomeIconPack(item.pack));
|
|
483
|
+
const hasPotentialHugeiconsUsage = code.includes(HUGEICONS_REACT_PACK) && scannedImports.some((item) => isHugeiconsIconPack(item.pack));
|
|
407
484
|
const table = buildScannedSymbolTable(scannedImports);
|
|
408
485
|
if (!table.size) return {
|
|
409
486
|
code,
|
|
@@ -416,9 +493,11 @@ const transformModule = (code, id, register, sources = DEFAULT_ICON_SOURCES, opt
|
|
|
416
493
|
};
|
|
417
494
|
const used = /* @__PURE__ */ new Set();
|
|
418
495
|
const usedFontAwesomeComponents = /* @__PURE__ */ new Set();
|
|
496
|
+
const usedHugeiconsComponents = /* @__PURE__ */ new Set();
|
|
419
497
|
const jsxScan = scanJsxIconEdits(code, table, spriteIconImport.localName, used, register, code.includes("iconId"));
|
|
420
498
|
const fontAwesomeUsages = hasPotentialFontAwesomeUsage ? scanFontAwesomeUsages(code, table, scanFontAwesomeComponents(code)) : [];
|
|
421
|
-
|
|
499
|
+
const hugeiconsUsages = hasPotentialHugeiconsUsage ? scanHugeiconsUsages(code, table, scanHugeiconsComponents(code)) : [];
|
|
500
|
+
if (jsxScan.count === 0 && !fontAwesomeUsages.length && !hugeiconsUsages.length) return {
|
|
422
501
|
code,
|
|
423
502
|
map: null,
|
|
424
503
|
anyReplacements: false
|
|
@@ -450,13 +529,41 @@ const transformModule = (code, id, register, sources = DEFAULT_ICON_SOURCES, opt
|
|
|
450
529
|
register(usage.pack, usage.exportName);
|
|
451
530
|
}
|
|
452
531
|
}
|
|
532
|
+
const registeredHugeiconsIcons = /* @__PURE__ */ new Set();
|
|
533
|
+
for (const usage of hugeiconsUsages) {
|
|
534
|
+
edits.push({
|
|
535
|
+
type: "replace",
|
|
536
|
+
from: usage.componentRange[0],
|
|
537
|
+
to: usage.componentRange[1],
|
|
538
|
+
value: spriteIconImport.localName
|
|
539
|
+
});
|
|
540
|
+
if (!usage.hasIconId) edits.push({
|
|
541
|
+
type: "insert",
|
|
542
|
+
pos: usage.componentRange[1],
|
|
543
|
+
value: ` iconId="${usage.iconId}"`
|
|
544
|
+
});
|
|
545
|
+
edits.push({
|
|
546
|
+
type: "remove",
|
|
547
|
+
from: usage.iconAttributeRange[0],
|
|
548
|
+
to: consumeTrailingWhitespace(code, usage.iconAttributeRange[1])
|
|
549
|
+
});
|
|
550
|
+
used.add(usage.iconLocal);
|
|
551
|
+
usedHugeiconsComponents.add(usage.componentLocal);
|
|
552
|
+
const key = `${usage.pack}:${usage.exportName}`;
|
|
553
|
+
if (!registeredHugeiconsIcons.has(key)) {
|
|
554
|
+
registeredHugeiconsIcons.add(key);
|
|
555
|
+
register(usage.pack, usage.exportName);
|
|
556
|
+
}
|
|
557
|
+
}
|
|
453
558
|
const cleanupEdits = cleanupScannedImports(code, scannedImports, used);
|
|
454
559
|
const cleanupFontAwesomeEdits = usedFontAwesomeComponents.size ? cleanupScannedFontAwesomeComponentImports(code, usedFontAwesomeComponents) : [];
|
|
455
|
-
const
|
|
560
|
+
const cleanupHugeiconsEdits = usedHugeiconsComponents.size ? cleanupScannedHugeiconsComponentImports(code, usedHugeiconsComponents) : [];
|
|
561
|
+
const canUsePresortedEdits = cleanupFontAwesomeEdits.length === 0 && cleanupHugeiconsEdits.length === 0;
|
|
456
562
|
const allEdits = canUsePresortedEdits ? [...cleanupEdits, ...edits] : [
|
|
457
563
|
...edits,
|
|
458
564
|
...cleanupEdits,
|
|
459
|
-
...cleanupFontAwesomeEdits
|
|
565
|
+
...cleanupFontAwesomeEdits,
|
|
566
|
+
...cleanupHugeiconsEdits
|
|
460
567
|
];
|
|
461
568
|
const importPrefix = `import { ${ICON_COMPONENT_NAME} } from "${ICON_SOURCE}";\n`;
|
|
462
569
|
if (!sourceMap) return {
|
package/dist/vite/plugin.d.mts
CHANGED
package/dist/vite/plugin.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { REACT_ICONS_SPRITE_URL_PLACEHOLDER } from "../index.mjs";
|
|
2
|
-
import { a as createCollector, r as DEFAULT_ICON_SOURCES } from "../compute-icon-id-
|
|
3
|
-
import { t as buildSprite } from "../build-sprite-
|
|
4
|
-
import { t as transformModule } from "../transform-module-
|
|
2
|
+
import { a as createCollector, r as DEFAULT_ICON_SOURCES } from "../compute-icon-id-Xx4G3fva.mjs";
|
|
3
|
+
import { t as buildSprite } from "../build-sprite-CxqvU2LE.mjs";
|
|
4
|
+
import { t as transformModule } from "../transform-module-1am5uV8-.mjs";
|
|
5
5
|
import { createHash } from "node:crypto";
|
|
6
6
|
//#region src/vite/plugin.ts
|
|
7
7
|
const reactIconsSprite = (options = {}) => {
|
package/dist/webpack/loader.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { t as transformModule } from "../transform-module-
|
|
2
|
-
import { t as collector } from "../collector-
|
|
1
|
+
import { t as transformModule } from "../transform-module-1am5uV8-.mjs";
|
|
2
|
+
import { t as collector } from "../collector-CBRz9R_h.mjs";
|
|
3
3
|
//#region src/webpack/loader.ts
|
|
4
4
|
const reactIconsSpriteLoader = async function(source) {
|
|
5
5
|
if (this.mode === "development") return source;
|
package/dist/webpack/plugin.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { REACT_ICONS_SPRITE_URL_PLACEHOLDER } from "../index.mjs";
|
|
2
|
-
import { t as buildSprite } from "../build-sprite-
|
|
3
|
-
import { t as collector } from "../collector-
|
|
2
|
+
import { t as buildSprite } from "../build-sprite-CxqvU2LE.mjs";
|
|
3
|
+
import { t as collector } from "../collector-CBRz9R_h.mjs";
|
|
4
4
|
import { createHash } from "node:crypto";
|
|
5
5
|
//#region src/webpack/plugin.ts
|
|
6
6
|
var ReactIconsSpriteWebpackPlugin = class {
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$schema": "https://www.schemastore.org/package.json",
|
|
3
3
|
"name": "react-icons-sprite",
|
|
4
|
-
"version": "1.0
|
|
4
|
+
"version": "1.1.0",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"description": "A lightweight Vite, Rsbuild and Webpack plugin for react-icons that builds a single SVG sprite and rewrites icons to <use>, reducing bundle size and runtime overhead.",
|
|
7
7
|
"author": "Jure Rotar <hello@jurerotar.com>",
|
|
@@ -55,12 +55,33 @@
|
|
|
55
55
|
"format:check": "biome format --no-errors-on-unmatched",
|
|
56
56
|
"lint": "biome lint --write --no-errors-on-unmatched",
|
|
57
57
|
"lint:check": "biome lint --no-errors-on-unmatched",
|
|
58
|
-
"type-check": "
|
|
58
|
+
"type-check": "tsc",
|
|
59
59
|
"test": "vitest",
|
|
60
60
|
"prepublishOnly": "npm run build",
|
|
61
61
|
"release": "npm publish --access public"
|
|
62
62
|
},
|
|
63
63
|
"peerDependencies": {
|
|
64
|
+
"@ant-design/icons": ">=6",
|
|
65
|
+
"@carbon/icons-react": ">=11",
|
|
66
|
+
"@fluentui/react-icons": ">=2",
|
|
67
|
+
"@fortawesome/free-solid-svg-icons": ">=7",
|
|
68
|
+
"@fortawesome/react-fontawesome": ">=3",
|
|
69
|
+
"@heroicons/react": ">=2",
|
|
70
|
+
"@hugeicons/core-free-icons": ">=4",
|
|
71
|
+
"@hugeicons/react": ">=1",
|
|
72
|
+
"@mui/icons-material": ">=9",
|
|
73
|
+
"@phosphor-icons/react": ">=2",
|
|
74
|
+
"@primer/octicons-react": ">=19",
|
|
75
|
+
"@radix-ui/react-icons": ">=1",
|
|
76
|
+
"@remixicon/react": ">=4",
|
|
77
|
+
"@tabler/icons-react": ">=3",
|
|
78
|
+
"devicons-react": ">=1",
|
|
79
|
+
"grommet-icons": ">=4",
|
|
80
|
+
"lucide-react": ">=1",
|
|
81
|
+
"phosphor-react": ">=1",
|
|
82
|
+
"react-bootstrap-icons": ">=1",
|
|
83
|
+
"react-feather": ">=2",
|
|
84
|
+
"react-icons": ">=5",
|
|
64
85
|
"react": ">= 16",
|
|
65
86
|
"react-dom": ">= 16"
|
|
66
87
|
},
|
|
@@ -68,17 +89,15 @@
|
|
|
68
89
|
"magic-string": "0.30.21"
|
|
69
90
|
},
|
|
70
91
|
"devDependencies": {
|
|
71
|
-
"@
|
|
72
|
-
"@types/node": "25.9.1",
|
|
92
|
+
"@types/node": "26.1.1",
|
|
73
93
|
"@types/react-dom": "19.2.3",
|
|
74
|
-
"
|
|
75
|
-
"react": "19.2.
|
|
76
|
-
"
|
|
77
|
-
"
|
|
78
|
-
"
|
|
79
|
-
"
|
|
80
|
-
"
|
|
81
|
-
"webpack": "5.107.1"
|
|
94
|
+
"react": "19.2.7",
|
|
95
|
+
"react-dom": "19.2.7",
|
|
96
|
+
"tsdown": "0.22.7",
|
|
97
|
+
"typescript": "7.0.2",
|
|
98
|
+
"vite": "8.1.4",
|
|
99
|
+
"vitest": "4.1.10",
|
|
100
|
+
"webpack": "5.108.4"
|
|
82
101
|
},
|
|
83
102
|
"keywords": [
|
|
84
103
|
"vite",
|
|
@@ -106,11 +125,81 @@
|
|
|
106
125
|
"@fortawesome/free-solid-svg-icons",
|
|
107
126
|
"@mui/icons-material",
|
|
108
127
|
"@carbon/icons-react",
|
|
128
|
+
"@ant-design/icons",
|
|
129
|
+
"@fluentui/react-icons",
|
|
130
|
+
"@primer/octicons-react",
|
|
131
|
+
"@hugeicons/react",
|
|
132
|
+
"@hugeicons/core-free-icons",
|
|
109
133
|
"react",
|
|
110
134
|
"icons",
|
|
111
135
|
"svg",
|
|
112
136
|
"svg-sprite",
|
|
113
137
|
"spritesheet",
|
|
114
138
|
"icon-sprite"
|
|
115
|
-
]
|
|
139
|
+
],
|
|
140
|
+
"peerDependenciesMeta": {
|
|
141
|
+
"@ant-design/icons": {
|
|
142
|
+
"optional": true
|
|
143
|
+
},
|
|
144
|
+
"@carbon/icons-react": {
|
|
145
|
+
"optional": true
|
|
146
|
+
},
|
|
147
|
+
"@fluentui/react-icons": {
|
|
148
|
+
"optional": true
|
|
149
|
+
},
|
|
150
|
+
"@fortawesome/free-solid-svg-icons": {
|
|
151
|
+
"optional": true
|
|
152
|
+
},
|
|
153
|
+
"@fortawesome/react-fontawesome": {
|
|
154
|
+
"optional": true
|
|
155
|
+
},
|
|
156
|
+
"@heroicons/react": {
|
|
157
|
+
"optional": true
|
|
158
|
+
},
|
|
159
|
+
"@hugeicons/core-free-icons": {
|
|
160
|
+
"optional": true
|
|
161
|
+
},
|
|
162
|
+
"@hugeicons/react": {
|
|
163
|
+
"optional": true
|
|
164
|
+
},
|
|
165
|
+
"@mui/icons-material": {
|
|
166
|
+
"optional": true
|
|
167
|
+
},
|
|
168
|
+
"@phosphor-icons/react": {
|
|
169
|
+
"optional": true
|
|
170
|
+
},
|
|
171
|
+
"@primer/octicons-react": {
|
|
172
|
+
"optional": true
|
|
173
|
+
},
|
|
174
|
+
"@radix-ui/react-icons": {
|
|
175
|
+
"optional": true
|
|
176
|
+
},
|
|
177
|
+
"@remixicon/react": {
|
|
178
|
+
"optional": true
|
|
179
|
+
},
|
|
180
|
+
"@tabler/icons-react": {
|
|
181
|
+
"optional": true
|
|
182
|
+
},
|
|
183
|
+
"devicons-react": {
|
|
184
|
+
"optional": true
|
|
185
|
+
},
|
|
186
|
+
"grommet-icons": {
|
|
187
|
+
"optional": true
|
|
188
|
+
},
|
|
189
|
+
"lucide-react": {
|
|
190
|
+
"optional": true
|
|
191
|
+
},
|
|
192
|
+
"phosphor-react": {
|
|
193
|
+
"optional": true
|
|
194
|
+
},
|
|
195
|
+
"react-bootstrap-icons": {
|
|
196
|
+
"optional": true
|
|
197
|
+
},
|
|
198
|
+
"react-feather": {
|
|
199
|
+
"optional": true
|
|
200
|
+
},
|
|
201
|
+
"react-icons": {
|
|
202
|
+
"optional": true
|
|
203
|
+
}
|
|
204
|
+
}
|
|
116
205
|
}
|