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

feat(react): update subfolder exports for icons #11318

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
2 changes: 2 additions & 0 deletions packages/react/icons/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
/index.esm.js
/index.js
4 changes: 2 additions & 2 deletions packages/react/icons/package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"main": "lib/index.js",
"module": "es/index.js",
"main": "index.js",
"module": "index.esm.js",
"sideEffects": false
}
File renamed without changes.
56 changes: 32 additions & 24 deletions packages/react/tasks/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,14 @@ const stripBanner = require('rollup-plugin-strip-banner');
const packageJson = require('../package.json');

async function build() {
const entrypoints = [
{
filepath: path.resolve(__dirname, '..', 'src', 'index.js'),
outputDirectory: path.resolve(__dirname, '..'),
},
{
filepath: path.resolve(__dirname, '..', 'icons', 'index.js'),
outputDirectory: path.resolve(__dirname, '..', 'icons'),
},
];
const reactEntrypoint = {
filepath: path.resolve(__dirname, '..', 'src', 'index.js'),
outputDirectory: path.resolve(__dirname, '..'),
};
const iconsEntrypoint = {
filepath: path.resolve(__dirname, '..', 'icons', 'src', 'index.js'),
outputDirectory: path.resolve(__dirname, '..', 'icons'),
};
const formats = [
{
type: 'esm',
Expand All @@ -37,25 +35,35 @@ async function build() {
},
];

for (const entrypoint of entrypoints) {
const inputConfig = getRollupConfig(entrypoint.filepath);
const bundle = await rollup(inputConfig);
const reactInputConfig = getRollupConfig(reactEntrypoint.filepath);
const reactBundle = await rollup(reactInputConfig);

for (const format of formats) {
await reactBundle.write({
dir: path.join(reactEntrypoint.outputDirectory, format.directory),
format: format.type,
preserveModules: true,
preserveModulesRoot: path.dirname(reactEntrypoint.filepath),
banner,
exports: 'named',
});
}

for (const format of formats) {
await bundle.write({
dir: path.join(entrypoint.outputDirectory, format.directory),
format: format.type,
preserveModules: true,
preserveModulesRoot: path.dirname(entrypoint.filepath),
banner,
exports: 'named',
});
}
const iconsInputConfig = getRollupConfig(iconsEntrypoint.filepath);
const iconsBundle = await rollup(iconsInputConfig);
for (const format of formats) {
await iconsBundle.write({
file:
format.type === 'commonjs' ? 'icons/index.js' : 'icons/index.esm.js',
format: format.type,
banner,
exports: 'named',
});
}
}

const banner = `/**
* Copyright IBM Corp. 2016, 2021
* Copyright IBM Corp. 2016, 2022
*
* This source code is licensed under the Apache-2.0 license found in the
* LICENSE file in the root directory of this source tree.
Expand Down