Skip to content

Commit

Permalink
chore(atomic-react): disable iife output (#4428)
Browse files Browse the repository at this point in the history
https://coveord.atlassian.net/browse/KIT-3562

---------

Co-authored-by: ylakhdar <[email protected]>
Co-authored-by: GitHub Actions Bot <>
  • Loading branch information
louis-bompart and y-lakhdar authored Sep 17, 2024
1 parent 9a54cac commit 47debe7
Showing 1 changed file with 55 additions and 55 deletions.
110 changes: 55 additions & 55 deletions packages/atomic-react/rollup.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,20 @@ import commonjs from '@rollup/plugin-commonjs';
import json from '@rollup/plugin-json';
import {nodeResolve} from '@rollup/plugin-node-resolve';
import replace from '@rollup/plugin-replace';
import terser from '@rollup/plugin-terser';
// import terser from '@rollup/plugin-terser';
import typescript from '@rollup/plugin-typescript';
import {defineConfig} from 'rollup';
import nodePolyfills from 'rollup-plugin-polyfill-node';

/** @type {import("rollup").GlobalsOption} */
const globals = {
react: 'React',
'react-dom': 'ReactDOM',
'react-dom/client': 'ReactDOM',
'react-dom/server': 'ReactDOMServer',
'@coveo/atomic': 'CoveoAtomic',
'@coveo/headless': 'CoveoHeadless',
};
// /** @type {import("rollup").GlobalsOption} */
// const globals = {
// react: 'React',
// 'react-dom': 'ReactDOM',
// 'react-dom/client': 'ReactDOM',
// 'react-dom/server': 'ReactDOMServer',
// '@coveo/atomic': 'CoveoAtomic',
// '@coveo/headless': 'CoveoHeadless',
// };

/** @type {import('rollup').ExternalOption} */
const commonExternal = [
Expand All @@ -27,38 +27,38 @@ const commonExternal = [
'@coveo/headless',
];

/** @returns {import('rollup').OutputOptions} */
const outputIIFE = ({minify}) => ({
file: `dist/iife/atomic-react${minify ? '.min' : ''}.js`,
format: 'iife',
name: 'CoveoAtomicReact',
globals,
plugins: minify ? [terser()] : [],
});
// /** @returns {import('rollup').OutputOptions} */
// const outputIIFE = ({minify}) => ({
// file: `dist/iife/atomic-react${minify ? '.min' : ''}.js`,
// format: 'iife',
// name: 'CoveoAtomicReact',
// globals,
// plugins: minify ? [terser()] : [],
// });

/** @returns {import('rollup').OutputOptions} */
const outputCJS = ({useCase}) => ({
file: `dist/cjs/${useCase}atomic-react.js`,
format: 'cjs',
});

/** @returns {import('rollup').OutputOptions} */
const outputIIFERecs = ({minify}) => ({
file: `dist/iife/atomic-react/recommendation${minify ? '.min' : ''}.js`,
format: 'iife',
name: 'CoveoAtomicReactRecommendation',
globals,
plugins: minify ? [terser()] : [],
});
// /** @returns {import('rollup').OutputOptions} */
// const outputIIFERecs = ({minify}) => ({
// file: `dist/iife/atomic-react/recommendation${minify ? '.min' : ''}.js`,
// format: 'iife',
// name: 'CoveoAtomicReactRecommendation',
// globals,
// plugins: minify ? [terser()] : [],
// });

/** @returns {import('rollup').OutputOptions} */
const outputIIFECommerce = ({minify}) => ({
file: `dist/iife/atomic-react/commerce${minify ? '.min' : ''}.js`,
format: 'iife',
name: 'CoveoAtomicReactCommerce',
globals,
plugins: minify ? [terser()] : [],
});
// /** @returns {import('rollup').OutputOptions} */
// const outputIIFECommerce = ({minify}) => ({
// file: `dist/iife/atomic-react/commerce${minify ? '.min' : ''}.js`,
// format: 'iife',
// name: 'CoveoAtomicReactCommerce',
// globals,
// plugins: minify ? [terser()] : [],
// });

const plugins = [
json(),
Expand Down Expand Up @@ -95,39 +95,39 @@ const pluginsCJS = [
];

export default defineConfig([
{
input: 'src/index.ts',
output: [outputIIFE({minify: true}), outputIIFE({minify: false})],
external: commonExternal,
plugins,
},
// {
// input: 'src/index.ts',
// output: [outputIIFE({minify: true}), outputIIFE({minify: false})],
// external: commonExternal,
// plugins,
// },
{
input: 'src/index.ts',
output: [outputCJS({useCase: ''})],
external: commonExternal,
plugins: pluginsCJS,
},
{
input: 'src/recommendation.index.ts',
output: [outputIIFERecs({minify: true}), outputIIFERecs({minify: false})],
external: commonExternal,
plugins,
},
// {
// input: 'src/recommendation.index.ts',
// output: [outputIIFERecs({minify: true}), outputIIFERecs({minify: false})],
// external: commonExternal,
// plugins,
// },
{
input: 'src/recommendation.index.ts',
output: [outputCJS({useCase: 'recommendation/'})],
external: commonExternal,
plugins: pluginsCJS,
},
{
input: 'src/commerce.index.ts',
output: [
outputIIFECommerce({minify: true}),
outputIIFECommerce({minify: false}),
],
external: commonExternal,
plugins,
},
// {
// input: 'src/commerce.index.ts',
// output: [
// outputIIFECommerce({minify: true}),
// outputIIFECommerce({minify: false}),
// ],
// external: commonExternal,
// plugins,
// },
{
input: 'src/commerce.index.ts',
output: [outputCJS({useCase: 'commerce/'})],
Expand Down

0 comments on commit 47debe7

Please sign in to comment.