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

chore(atomic-react): disable iife output #4428

Merged
merged 12 commits into from
Sep 17, 2024
Merged
10 changes: 0 additions & 10 deletions packages/atomic-react/commerce/package.json

This file was deleted.

17 changes: 17 additions & 0 deletions packages/atomic-react/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,5 +55,22 @@
},
"engines": {
"node": "^20.9.0"
},
"exports": {
".": {
"types": "./dist/index.d.ts",
"import": "./dist/index.js",
"require": "./dist/cjs/atomic-react.js"
},
"./commerce": {
"types": "./dist/commerce.index.d.ts",
"import": "./dist/commerce.index.js",
"require": "./dist/cjs/commerce/atomic-react.js"
},
"./recommendation": {
"types": "./dist/recommendation.index.d.ts",
"import": "./dist/recommendation.index.js",
"require": "./dist/cjs/recommendation/atomic-react.js"
}
}
}
9 changes: 0 additions & 9 deletions packages/atomic-react/recommendation/package.json

This file was deleted.

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
1 change: 0 additions & 1 deletion packages/atomic-react/src/components/commerce/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
export * from '../stencil-generated/commerce/index';
export * from '@coveo/headless/commerce';
export {CommerceBindings, i18n} from '@coveo/atomic';

// Important: Re-exporting under the same name (eg: "AtomicCommerceInterface") shadows the original component
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
export * from '../stencil-generated/search';
export * from '@coveo/headless/recommendation';
export {RecsBindings, i18n} from '@coveo/atomic';

// Important: Re-exporting under the same name (eg: "AtomicRecsInterface") shadows the original component
Expand Down
1 change: 0 additions & 1 deletion packages/atomic-react/src/components/search/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
export * from '../stencil-generated/search/index';
export * from '@coveo/headless';
export {Bindings, i18n} from '@coveo/atomic';

// Important: Re-exporting under the same name (eg: "AtomicSearchInterface") shadows the original component
Expand Down
3 changes: 1 addition & 2 deletions packages/samples/atomic-next/pages/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ import {
AtomicSortExpression,
AtomicTimeframe,
AtomicTimeframeFacet,
buildSearchEngine,
AtomicFormatCurrency,
AtomicResultBadge,
AtomicResultFieldsList,
Expand All @@ -42,8 +41,8 @@ import {
AtomicResultSectionVisual,
AtomicResultText,
AtomicText,
Result,
} from '@coveo/atomic-react';
import {buildSearchEngine, Result} from '@coveo/headless';
import type {NextPage} from 'next';
import dynamic from 'next/dynamic';
import {useMemo} from 'react';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ import {
AtomicTimeframe,
AtomicTimeframeFacet,
AtomicSearchBoxInstantResults,
buildSearchEngine,
AtomicSearchBoxRecentQueries,
AtomicResultSectionVisual,
AtomicResultImage,
Expand All @@ -32,13 +31,16 @@ import {
AtomicResultSectionTitleMetadata,
AtomicResultRating,
AtomicResultNumber,
Result,
Bindings,
AtomicSearchBoxQuerySuggestions,
} from '@coveo/atomic-react';
import {
buildSearchEngine,
Result,
SearchEngineConfiguration,
getSampleSearchEngineConfiguration,
loadAdvancedSearchQueryActions,
} from '@coveo/atomic-react';
} from '@coveo/headless';
import React, {FunctionComponent, useMemo} from 'react';

type Sample = 'service' | 'electronics';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import {
AtomicProductText,
AtomicProductPrice,
AtomicProductDescription,
buildCommerceEngine,
AtomicCommerceSearchBox,
AtomicCommerceSearchBoxInstantProducts,
AtomicCommerceSearchBoxQuerySuggestions,
Expand All @@ -21,8 +20,11 @@ import {
AtomicProductSectionEmphasized,
AtomicProductSectionMetadata,
AtomicProductSectionName,
getSampleCommerceEngineConfiguration,
} from '@coveo/atomic-react/commerce';
import {
buildCommerceEngine,
getSampleCommerceEngineConfiguration,
} from '@coveo/headless/commerce';
import React, {useMemo} from 'react';

export const CommerceSearchPage = () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@ import {
AtomicResultSectionVisual,
AtomicResultText,
AtomicText,
FoldedResult,
AtomicResultSectionChildren,
AtomicFoldedResultList,
AtomicResultImage,
} from '@coveo/atomic-react';
import {FoldedResult} from '@coveo/headless';
import React, {FunctionComponent} from 'react';
import {AtomicPageWrapper} from '../components/AtomicPageWrapper';

Expand Down
6 changes: 4 additions & 2 deletions packages/samples/atomic-react/src/pages/RecsPage.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import {
AtomicFormatCurrency,
AtomicRecsInterface,
buildRecommendationEngine,
AtomicResultImage,
AtomicResultSectionTitle,
AtomicResultLink,
Expand All @@ -20,9 +19,12 @@ import {
AtomicResultPrintableUri,
AtomicResultMultiValueText,
AtomicResultText,
Result,
AtomicRecsList,
} from '@coveo/atomic-react/recommendation';
import {
buildRecommendationEngine,
Result,
} from '@coveo/headless/recommendation';
import React, {FunctionComponent, useMemo} from 'react';

export const RecsPage: FunctionComponent = () => {
Expand Down
Loading