2
0
mirror of https://github.com/iconify/iconify.git synced 2024-11-10 07:11:00 +00:00

feat: refactor modern loader

This commit is contained in:
Joaquín Sánchez Jiménez 2022-01-10 12:17:05 +01:00
parent 30c4ddf3f1
commit d090a3801b
6 changed files with 33 additions and 25 deletions

4
package-lock.json generated
View File

@ -4460,7 +4460,6 @@
"minimist": "^1.2.5",
"neo-async": "^2.6.0",
"source-map": "^0.6.1",
"uglify-js": "^3.1.4",
"wordwrap": "^1.0.0"
},
"bin": {
@ -5245,9 +5244,6 @@
"resolved": "https://registry.npmjs.org/jsonfile/-/jsonfile-4.0.0.tgz",
"integrity": "sha1-h3Gq4HmbZAdrdmQPygWPnBDjPss=",
"dev": true,
"dependencies": {
"graceful-fs": "^4.1.6"
},
"optionalDependencies": {
"graceful-fs": "^4.1.6"
}

View File

@ -90,14 +90,6 @@
"require": "./lib/icon/sort.js",
"import": "./lib/icon/sort.mjs"
},
"./lib/modern": {
"require": "./lib/modern/index.js",
"import": "./lib/modern/index.mjs"
},
"./lib/modern/index": {
"require": "./lib/modern/index.js",
"import": "./lib/modern/index.mjs"
},
"./lib/storage/functions": {
"require": "./lib/storage/functions.js",
"import": "./lib/storage/functions.mjs"
@ -108,17 +100,13 @@
}
},
"dependencies": {
"@antfu/utils": "^0.3.0",
"@iconify/api-redundancy": "^1.0.2",
"@iconify/types": "^1.0.10",
"@iconify/utils": "^1.0.16",
"cross-fetch": "^3.1.4",
"debug": "^4.3.3",
"local-pkg": "^0.4.0"
"cross-fetch": "^3.1.4"
},
"devDependencies": {
"@iconify/library-builder": "^1.0.3",
"@types/debug": "^4.1.7",
"@types/jest": "^27.0.2",
"@types/node": "^15.3.0",
"@typescript-eslint/eslint-plugin": "^4.31.1",

View File

@ -13,7 +13,8 @@
"@antfu/utils": "^0.3.0",
"@iconify/types": "^1.0.12",
"debug": "^4.3.3",
"kolorist": "^1.5.0"
"kolorist": "^1.5.0",
"local-pkg": "^0.4.0"
},
"devDependencies": {
"@iconify/library-builder": "^1.0.4",
@ -3972,6 +3973,17 @@
"node": ">= 0.8.0"
}
},
"node_modules/local-pkg": {
"version": "0.4.1",
"resolved": "https://registry.npmjs.org/local-pkg/-/local-pkg-0.4.1.tgz",
"integrity": "sha512-lL87ytIGP2FU5PWwNDo0w3WhIo2gopIAxPg9RxDYF7m4rr5ahuZxP22xnJHIvaLTe4Z9P6uKKY2UHiwyB4pcrw==",
"engines": {
"node": ">=14"
},
"funding": {
"url": "https://github.com/sponsors/antfu"
}
},
"node_modules/locate-path": {
"version": "6.0.0",
"resolved": "https://registry.npmjs.org/locate-path/-/locate-path-6.0.0.tgz",
@ -8412,6 +8424,11 @@
"type-check": "~0.4.0"
}
},
"local-pkg": {
"version": "0.4.1",
"resolved": "https://registry.npmjs.org/local-pkg/-/local-pkg-0.4.1.tgz",
"integrity": "sha512-lL87ytIGP2FU5PWwNDo0w3WhIo2gopIAxPg9RxDYF7m4rr5ahuZxP22xnJHIvaLTe4Z9P6uKKY2UHiwyB4pcrw=="
},
"locate-path": {
"version": "6.0.0",
"resolved": "https://registry.npmjs.org/locate-path/-/locate-path-6.0.0.tgz",

View File

@ -128,6 +128,10 @@
"require": "./lib/loader/loaders.js",
"import": "./lib/loader/loaders.mjs"
},
"./lib/loader/modern": {
"require": "./lib/loader/modern.js",
"import": "./lib/loader/modern.mjs"
},
"./lib/loader/types": {
"require": "./lib/loader/types.js",
"import": "./lib/loader/types.mjs"
@ -158,7 +162,8 @@
"@antfu/utils": "^0.3.0",
"@iconify/types": "^1.0.12",
"debug": "^4.3.3",
"kolorist": "^1.5.0"
"kolorist": "^1.5.0",
"local-pkg": "^0.4.0"
},
"devDependencies": {
"@iconify/library-builder": "^1.0.4",

View File

@ -53,6 +53,7 @@ export type {
export { tryInstallPkg } from './loader/utils';
export { FileSystemIconLoader } from './loader/loaders';
export { getCustomIcon } from './loader/custom';
export { loadCollection, searchForIcon } from './loader/modern';
// Misc
export { camelize, camelToKebab, pascalize } from './misc/strings';

View File

@ -1,14 +1,15 @@
import { promises as fs } from 'fs';
import type { IconifyJSON } from '@iconify/types';
import type { FullIconifyIcon } from '@iconify/utils/lib/icon';
import { defaultCustomisations as DefaultIconCustomizations, iconToSVG, getIconData, tryInstallPkg } from '@iconify/utils';
import type { FullIconifyIcon } from '../icon';
import { iconToSVG, getIconData, tryInstallPkg } from '../index';
import createDebugger from 'debug';
import { isPackageExists, resolveModule } from 'local-pkg';
import type { FullIconCustomisations } from '@iconify/utils/lib/customisations';
import { defaults as DefaultIconCustomizations } from '../customisations';
import type { FullIconCustomisations } from '../customisations';
const debug = createDebugger('@iconify-core:icon');
const debugModern = createDebugger('@iconify-core:modern');
const debugLegacy = createDebugger('@iconify-core:legacy');
const debug = createDebugger('@iconify-loader:icon');
const debugModern = createDebugger('@iconify-loader:modern');
const debugLegacy = createDebugger('@iconify-loader:legacy');
const _collections: Record<string, Promise<IconifyJSON | undefined>> = {};
const isLegacyExists = isPackageExists('@iconify/json');