mirror of
https://github.com/simple-icons/simple-icons.git
synced 2024-11-16 00:59:07 +02:00
remove icons/* entrypoints (#6788)
* remove icons/* entrypoints * remove icons/* tests * remove icons/* references from the README * reference actual variable in README console.log * merge develop * fix conflicts * fix * fix tests * Update scripts/build/package.js * Update README.md * fix ignore files
This commit is contained in:
parent
762ae7959c
commit
665b82590d
@ -3,5 +3,7 @@ node_modules/
|
||||
npm-debug.log
|
||||
|
||||
# Build files
|
||||
icons/*.js
|
||||
/index.js
|
||||
/icons.js
|
||||
/icons.mjs
|
||||
/icons.d.ts
|
||||
|
@ -13,4 +13,3 @@
|
||||
!icons.js
|
||||
!icons.mjs
|
||||
!icons.d.ts
|
||||
!alias.d.ts
|
||||
|
@ -10,9 +10,7 @@ _data/simple-icons.json
|
||||
scripts/build/templates/*.js
|
||||
|
||||
# Generated JavaScript files don't need to be formatted
|
||||
icons/*.js
|
||||
icons/*.d.ts
|
||||
icons.d.ts
|
||||
index.js
|
||||
icons.js
|
||||
icons.mjs
|
||||
index.js
|
||||
icons.d.ts
|
||||
|
11
README.md
11
README.md
@ -69,16 +69,15 @@ Alternatively, you can also import all icons from a single file, where `[ICON SL
|
||||
|
||||
// For example:
|
||||
// use import/esm to allow tree shaking
|
||||
import { siSimpleicons } from 'simple-icons/icons'
|
||||
import { siSimpleicons } from 'simple-icons/icons';
|
||||
// or with require/cjs
|
||||
const { siSimpleicons } = require('simple-icons/icons');
|
||||
```
|
||||
|
||||
> :warning: The old way of importing with `require('simple-icons/icons/[ICON SLUG]')` is deprecated and
|
||||
will be removed in v7.0.0.
|
||||
|
||||
Either method will return an icon object:
|
||||
It will return an icon object:
|
||||
|
||||
```javascript
|
||||
console.log(icon);
|
||||
console.log(siSimpleicons);
|
||||
|
||||
/*
|
||||
{
|
||||
|
6
alias.d.ts
vendored
6
alias.d.ts
vendored
@ -1,6 +0,0 @@
|
||||
import { SimpleIcon } from '.';
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
export type I = SimpleIcon;
|
@ -19,7 +19,6 @@
|
||||
"default": "./icons.js"
|
||||
},
|
||||
"./icons/*": [
|
||||
"./icons/*.js",
|
||||
"./icons/*"
|
||||
]
|
||||
},
|
||||
@ -57,7 +56,7 @@
|
||||
},
|
||||
"scripts": {
|
||||
"build": "node scripts/build/package.js",
|
||||
"clean": "rimraf icons/*.js icons/*.d.ts index.js icons.js icons.mjs icons.d.ts",
|
||||
"clean": "rimraf index.js icons.js icons.mjs icons.d.ts",
|
||||
"format": "prettier --write .",
|
||||
"lint": "run-s our-lint jslint jsonlint svglint wslint",
|
||||
"our-lint": "node scripts/lint/ourlint.js",
|
||||
|
@ -99,25 +99,6 @@ const build = async () => {
|
||||
|
||||
const iconExportName = slugToVariableName(icon.slug);
|
||||
|
||||
// write the static .js file for the icon
|
||||
const jsFilepath = path.resolve(iconsDir, `${filename}.js`);
|
||||
const newImportMessage = `use "const { ${iconExportName} } = require('simple-icons/icons');" instead`;
|
||||
const message = JSON.stringify(
|
||||
`Imports like "const ${icon.slug} = require('simple-icons/icons/${icon.slug}');" have been deprecated in v6.0.0 and will no longer work from v7.0.0, ${newImportMessage}`,
|
||||
);
|
||||
|
||||
const dtsFilepath = path.resolve(iconsDir, `${filename}.d.ts`);
|
||||
await Promise.all([
|
||||
writeJs(
|
||||
jsFilepath,
|
||||
`console.warn("warn -", ${message});module.exports=${iconObject};`,
|
||||
),
|
||||
writeTs(
|
||||
dtsFilepath,
|
||||
`/**@deprecated ${newImportMessage}*/declare const i:import("../alias").I;export default i;`,
|
||||
),
|
||||
]);
|
||||
|
||||
// add object to the barrel file
|
||||
iconsBarrelJs.push(`${iconExportName}:${iconObject},`);
|
||||
iconsBarrelMjs.push(`export const ${iconExportName}=${iconObject}`);
|
||||
@ -139,7 +120,9 @@ const build = async () => {
|
||||
const rawIconsMjs = iconsBarrelMjs.join('');
|
||||
await writeJs(iconsMjsFile, rawIconsMjs);
|
||||
// and create a type declaration file
|
||||
const rawIconsDts = `import {I} from "./alias";${iconsBarrelDts.join('')}`;
|
||||
const rawIconsDts = `import {SimpleIcon} from ".";type I = SimpleIcon;${iconsBarrelDts.join(
|
||||
'',
|
||||
)}`;
|
||||
await writeTs(iconsDtsFile, rawIconsDts);
|
||||
};
|
||||
|
||||
|
@ -1,16 +0,0 @@
|
||||
import { testIcon } from './test-icon.js';
|
||||
import { getIconSlug, getIconsData } from '../scripts/utils.js';
|
||||
(async () => {
|
||||
console.warn = () => {};
|
||||
|
||||
const icons = await getIconsData();
|
||||
|
||||
const tests = icons.map(async (icon) => {
|
||||
const slug = getIconSlug(icon);
|
||||
const { default: subject } = await import(`../icons/${slug}.js`);
|
||||
|
||||
testIcon(icon, subject, slug);
|
||||
});
|
||||
|
||||
await Promise.all(tests);
|
||||
})();
|
Loading…
Reference in New Issue
Block a user