Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unify non-icon exports in svg/font indices #693

Merged
merged 3 commits into from
Feb 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions packages/react-icons/addRexportsToIndex.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
module.exports = function addRexportsToIndex(indexContents, rootPath = `.`) {
indexContents.push(`export { FluentIconsProps } from \'${rootPath}/utils/FluentIconsProps.types\'`);
indexContents.push(`export { default as wrapIcon } from \'${rootPath}/utils/wrapIcon\'`);
indexContents.push(`export { default as bundleIcon } from \'${rootPath}/utils/bundleIcon\'`);
indexContents.push(`export { createFluentIcon } from \'${rootPath}/utils/createFluentIcon\'`);
indexContents.push(`export { createFluentFontIcon } from \'${rootPath}/utils/fonts/createFluentFontIcon\'`);
indexContents.push(`export type { FluentIcon } from \'${rootPath}/utils/createFluentIcon\'`);
indexContents.push(`export * from \'${rootPath}/utils/useIconState\'`);
indexContents.push(`export * from \'${rootPath}/utils/constants\'`);
indexContents.push(`export { IconDirectionContextProvider, useIconContext } from \'${rootPath}/contexts/index\'`);
indexContents.push(`export type { IconDirectionContextValue } from \'${rootPath}/contexts/index\'`);
}
11 changes: 2 additions & 9 deletions packages/react-icons/convert-font.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ const mkdirp = require('mkdirp');
const { promisify } = require('util');
const { option } = require("yargs");
const glob = promisify(require('glob'));
const addRexportsToIndex = require('./addRexportsToIndex');

// @ts-ignore
const SRC_PATH = argv.source;
Expand Down Expand Up @@ -69,15 +70,7 @@ async function processFiles(src, dest) {

const indexPath = path.join(dest, 'index.tsx')
// Finally add the interface definition and then write out the index.
indexContents.push('export { FluentIconsProps } from \'../utils/FluentIconsProps.types\'');
indexContents.push('export { default as wrapIcon } from \'../utils/wrapIcon\'');
indexContents.push('export { default as bundleIcon } from \'../utils/bundleIcon\'');
indexContents.push('export { createFluentFontIcon } from \'../utils/fonts/createFluentFontIcon\'');
indexContents.push('export type { FluentIcon } from \'../utils/createFluentIcon\'');
indexContents.push('export * from \'../utils/useIconState\'');
indexContents.push('export * from \'../utils/constants\'');
indexContents.push('export { IconDirectionContextProvider, useIconContext } from \'../contexts/index\'');
indexContents.push('export type { IconDirectionContextValue } from \'../contexts/index\'');
addRexportsToIndex(indexContents, '..');


await fs.writeFile(indexPath, indexContents.join('\n'));
Expand Down
12 changes: 2 additions & 10 deletions packages/react-icons/convert.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ const fs = require("fs");
const path = require("path");
const argv = require("yargs").boolean("selector").default("selector", false).argv;
const _ = require("lodash");
const addRexportsToIndex = require('./addRexportsToIndex');

const SRC_PATH = argv.source;
const DEST_PATH = argv.dest;
Expand Down Expand Up @@ -68,20 +69,11 @@ function processFiles(src, dest) {

const indexPath = path.join(dest, 'index.tsx')
// Finally add the interface definition and then write out the index.
indexContents.push('export { FluentIconsProps } from \'./utils/FluentIconsProps.types\'');
indexContents.push('export { default as wrapIcon } from \'./utils/wrapIcon\'');
indexContents.push('export { default as bundleIcon } from \'./utils/bundleIcon\'');
indexContents.push('export { createFluentIcon } from \'./utils/createFluentIcon\'');
indexContents.push('export type { FluentIcon } from \'./utils/createFluentIcon\'');
indexContents.push('export * from \'./utils/useIconState\'');
indexContents.push('export * from \'./utils/constants\'');
indexContents.push('export { IconDirectionContextProvider, useIconContext } from \'./contexts/index\'');
indexContents.push('export type { IconDirectionContextValue } from \'./contexts/index\'');
addRexportsToIndex(indexContents);

fs.writeFileSync(indexPath, indexContents.join('\n'), (err) => {
if (err) throw err;
});

}

/**
Expand Down
Loading