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(headless,atomic): add type "module" to atomic, atomic-react and headless #4442

Merged
merged 21 commits into from
Sep 24, 2024
Merged
Show file tree
Hide file tree
Changes from 15 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: 1 addition & 1 deletion .github/actions/e2e-atomic-insight-panel/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ runs:
with:
browser: chrome
command-prefix: 'npx -w @coveo/atomic cypress-repeat run -n 3 --until-passes --rerun-failed-only --'
config-file: cypress-insight-panel.config.ts
config-file: cypress-insight-panel.config.mjs
start: npm start -w @coveo/atomic
wait-on: 'http://localhost:3333/ping'
wait-on-timeout: 600000
Expand Down
2 changes: 1 addition & 1 deletion .github/actions/e2e-atomic-screenshots/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ runs:
with:
browser: chrome
command-prefix: 'npx -w @coveo/atomic cypress-repeat run -n 3 --until-passes --rerun-failed-only --'
config-file: cypress-screenshots.config.ts
config-file: cypress-screenshots.config.mjs
start: npm start -w @coveo/atomic
wait-on: 'http://localhost:3333/ping'
wait-on-timeout: 600000
Expand Down
23 changes: 22 additions & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 8 additions & 5 deletions packages/atomic-react/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"name": "@coveo/atomic-react",
"sideEffects": false,
"type": "module",
"version": "3.0.2",
"description": "React specific wrapper for the Atomic component library",
"repository": {
Expand All @@ -11,6 +12,7 @@
"scripts": {
"build": "nx build",
"clean": "rimraf -rf dist",
"build:addExtensions": "fix-esm-import-path src/components/stencil-generated",
alexprudhomme marked this conversation as resolved.
Show resolved Hide resolved
"build:bundles:esm": "tsc -p tsconfig.esm.json",
"build:bundles:iife-cjs": "rollup --config rollup.config.mjs --bundleConfigAsCjs",
"build:bundles": "concurrently \"npm run build:bundles:esm\" \"npm run build:bundles:iife-cjs\"",
Expand All @@ -19,7 +21,7 @@
"promote:npm:latest": "node ../../scripts/deploy/update-npm-tag.mjs latest",
"build:assets": "ncp ../atomic/dist/atomic/assets dist/assets && ncp ../atomic/dist/atomic/lang dist/lang "
},
"main": "./dist/cjs/atomic-react.js",
"main": "./dist/cjs/atomic-react.cjs",
"module": "./dist/index.js",
"types": "./dist/index.d.ts",
"files": [
Expand All @@ -31,8 +33,8 @@
"@coveo/atomic": "3.1.1"
},
"devDependencies": {
"@coveo/rollup-plugin-replace-with-ast": "1.0.0",
"@coveo/release": "1.0.0",
"@coveo/rollup-plugin-replace-with-ast": "1.0.0",
"@rollup/plugin-commonjs": "^25.0.0",
"@rollup/plugin-json": "6.1.0",
"@rollup/plugin-node-resolve": "^15.0.0",
Expand All @@ -42,6 +44,7 @@
"@types/node": "20.14.12",
"@types/react": "18.3.3",
"@types/react-dom": "18.3.0",
"fix-esm-import-path": "1.10.0",
"ncp": "2.0.0",
"react": "18.3.1",
"react-dom": "18.3.1",
Expand All @@ -60,17 +63,17 @@
".": {
"types": "./dist/index.d.ts",
"import": "./dist/index.js",
"require": "./dist/cjs/atomic-react.js"
"require": "./dist/cjs/atomic-react.cjs"
},
"./commerce": {
"types": "./dist/commerce.index.d.ts",
"import": "./dist/commerce.index.js",
"require": "./dist/cjs/commerce/atomic-react.js"
"require": "./dist/cjs/commerce/atomic-react.cjs"
},
"./recommendation": {
"types": "./dist/recommendation.index.d.ts",
"import": "./dist/recommendation.index.js",
"require": "./dist/cjs/recommendation/atomic-react.js"
"require": "./dist/cjs/recommendation/atomic-react.cjs"
}
}
}
6 changes: 5 additions & 1 deletion packages/atomic-react/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,11 @@
"dependsOn": ["^build", "clean"],
"executor": "nx:run-commands",
"options": {
"commands": ["npm run build:bundles", "npm run build:assets"],
"commands": [
"npm run build:addExtensions",
"npm run build:bundles",
"npm run build:assets"
],
"parallel": false,
"cwd": "packages/atomic-react"
}
Expand Down
2 changes: 1 addition & 1 deletion packages/atomic-react/rollup.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ const commonExternal = [

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

Expand Down
2 changes: 1 addition & 1 deletion packages/atomic-react/src/commerce.index.ts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export * from './components/commerce/index';
export * from './components/commerce/index.js';
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type {JSX, i18n} from '@coveo/atomic';
import React, {useEffect, useRef} from 'react';
import {AtomicCommerceInterface} from '../stencil-generated/commerce';
import {AtomicCommerceInterface} from '../stencil-generated/commerce/index.js';

type ExecuteRequest = HTMLAtomicCommerceInterfaceElement['executeFirstRequest'];

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {renderToString} from 'react-dom/server';
import {
AtomicCommerceProductList,
AtomicProductLink,
} from '../stencil-generated/commerce';
} from '../stencil-generated/commerce/index.js';

interface Template {
contentTemplate: JSX.Element;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {renderToString} from 'react-dom/server';
import {
AtomicCommerceRecommendationList,
AtomicProductLink,
} from '../stencil-generated/commerce';
} from '../stencil-generated/commerce/index.js';

interface Template {
contentTemplate: JSX.Element;
Expand Down
8 changes: 4 additions & 4 deletions packages/atomic-react/src/components/commerce/index.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
export * from '../stencil-generated/commerce/index';
export * from '../stencil-generated/commerce/index.js';
export {CommerceBindings, i18n} from '@coveo/atomic';

// Important: Re-exporting under the same name (eg: "AtomicCommerceInterface") shadows the original component
// and should wrap it nicely for users of the library
export {InterfaceWrapper as AtomicCommerceInterface} from './CommerceInterfaceWrapper';
export {ListWrapper as AtomicCommerceProductList} from './CommerceProductListWrapper';
export {ListWrapper as AtomicCommerceRecommendationList} from './CommerceRecommendationListWrapper';
export {InterfaceWrapper as AtomicCommerceInterface} from './CommerceInterfaceWrapper.js';
export {ListWrapper as AtomicCommerceProductList} from './CommerceProductListWrapper.js';
export {ListWrapper as AtomicCommerceRecommendationList} from './CommerceRecommendationListWrapper.js';
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import {
buildRecommendationEngine,
} from '@coveo/headless/recommendation';
import React, {useEffect, useRef} from 'react';
import {AtomicRecsInterface} from '../stencil-generated/search';
import {AtomicRecsInterface} from '../stencil-generated/search/index.js';

type GetRecommendations = HTMLAtomicRecsInterfaceElement['getRecommendations'];
/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@ import type {Result} from '@coveo/headless/recommendation';
import React, {useEffect, useRef} from 'react';
import {createRoot} from 'react-dom/client';
import {renderToString} from 'react-dom/server';
import {AtomicRecsList, AtomicResultLink} from '../stencil-generated/search';
import {
AtomicRecsList,
AtomicResultLink,
} from '../stencil-generated/search/index.js';

interface Template {
contentTemplate: JSX.Element;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
export * from '../stencil-generated/search';
export * from '../stencil-generated/search/index.js';
export {RecsBindings, i18n} from '@coveo/atomic';

// Important: Re-exporting under the same name (eg: "AtomicRecsInterface") shadows the original component
// and should wrap it nicely for users of the library
export {RecsInterfaceWrapper as AtomicRecsInterface} from './RecsInterfaceWrapper';
export {RecsListWrapper as AtomicRecsList} from './RecsListWrapper';
export {RecsInterfaceWrapper as AtomicRecsInterface} from './RecsInterfaceWrapper.js';
export {RecsListWrapper as AtomicRecsList} from './RecsListWrapper.js';
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import type {FoldedResult} from '@coveo/headless';
import React, {useEffect, useRef} from 'react';
import {createRoot} from 'react-dom/client';
import {renderToString} from 'react-dom/server';
import {AtomicFoldedResultList} from '../stencil-generated/search';
import {AtomicFoldedResultList} from '../stencil-generated/search/index.js';

/**
* The properties of the AtomicFoldedResultList component
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@ import type {Result} from '@coveo/headless';
import React, {useEffect, useRef} from 'react';
import {createRoot} from 'react-dom/client';
import {renderToString} from 'react-dom/server';
import {AtomicResultLink, AtomicResultList} from '../stencil-generated/search';
import {
AtomicResultLink,
AtomicResultList,
} from '../stencil-generated/search/index.js';

interface Template {
contentTemplate: JSX.Element;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import type {FoldedResult, Result} from '@coveo/headless';
import React, {useEffect, useRef} from 'react';
import {createRoot} from 'react-dom/client';
import {renderToString} from 'react-dom/server';
import {AtomicSearchBoxInstantResults} from '../stencil-generated/search';
import {AtomicSearchBoxInstantResults} from '../stencil-generated/search/index.js';

/**
* The properties of the AtomicSearchBoxInstantResults component
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import {
getSampleSearchEngineConfiguration,
} from '@coveo/headless';
import React, {useEffect, useRef} from 'react';
import {AtomicSearchInterface} from '../stencil-generated/search';
import {AtomicSearchInterface} from '../stencil-generated/search/index.js';

type ExecuteSearch = HTMLAtomicSearchInterfaceElement['executeFirstSearch'];
/**
Expand Down
10 changes: 5 additions & 5 deletions packages/atomic-react/src/components/search/index.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
export * from '../stencil-generated/search/index';
export * from '../stencil-generated/search/index.js';
export {Bindings, i18n} from '@coveo/atomic';

// Important: Re-exporting under the same name (eg: "AtomicSearchInterface") shadows the original component
// and should wrap it nicely for users of the library
export {SearchInterfaceWrapper as AtomicSearchInterface} from './SearchInterfaceWrapper';
export {ResultListWrapper as AtomicResultList} from './ResultListWrapper';
export {FoldedResultListWrapper as AtomicFoldedResultList} from './FoldedResultListWrapper';
export {SearchBoxInstantResultsWrapper as AtomicSearchBoxInstantResults} from './SearchBoxInstantResultsWrapper';
export {SearchInterfaceWrapper as AtomicSearchInterface} from './SearchInterfaceWrapper.js';
export {ResultListWrapper as AtomicResultList} from './ResultListWrapper.js';
export {FoldedResultListWrapper as AtomicFoldedResultList} from './FoldedResultListWrapper.js';
export {SearchBoxInstantResultsWrapper as AtomicSearchBoxInstantResults} from './SearchBoxInstantResultsWrapper.js';
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/* eslint-disable */
/* tslint:disable */
/* auto-generated react proxies */
import { createReactComponent } from './react-component-lib';
import { createReactComponent } from './react-component-lib/index.js';

import type { JSX } from '@coveo/atomic';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React, { createElement } from 'react';

import { attachProps, camelToDashCase, createForwardRef, dashToPascalCase, isCoveredByReact, mergeRefs } from './utils';
import { attachProps, camelToDashCase, createForwardRef, dashToPascalCase, isCoveredByReact, mergeRefs } from './utils/index.js';

export interface HTMLStencilElement extends HTMLElement {
componentOnReady(): Promise<this>;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import React from 'react';
import ReactDOM from 'react-dom';

import { OverlayEventDetail } from './interfaces';
import { StencilReactForwardedRef, attachProps, dashToPascalCase, defineCustomElement, setRef } from './utils';
import { OverlayEventDetail } from './interfaces.js';
import { StencilReactForwardedRef, attachProps, dashToPascalCase, defineCustomElement, setRef } from './utils/index.js';

interface OverlayElement extends HTMLElement {
present: () => Promise<void>;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
export { createReactComponent } from './createComponent';
export { createOverlayComponent } from './createOverlayComponent';
export { createReactComponent } from './createComponent.js';
export { createOverlayComponent } from './createOverlayComponent.js';
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { camelToDashCase } from './case';
import { camelToDashCase } from './case.js';

export const attachProps = (node: HTMLElement, newProps: any, oldProps: any = {}) => {
// some test frameworks don't render DOM elements, so we test here to make sure we are dealing with DOM first
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from 'react';

import type { StyleReactProps } from '../interfaces';
import type { StyleReactProps } from '../interfaces.js';

export type StencilReactExternalProps<PropType, ElementType> = PropType &
Omit<React.HTMLAttributes<ElementType>, 'style'> &
Expand Down Expand Up @@ -46,5 +46,5 @@ export const defineCustomElement = (tagName: string, customElement: any) => {
}
};

export * from './attachProps';
export * from './case';
export * from './attachProps.js';
export * from './case.js';
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/* eslint-disable */
/* tslint:disable */
/* auto-generated react proxies */
import { createReactComponent } from './react-component-lib';
import { createReactComponent } from './react-component-lib/index.js';

import type { JSX } from '@coveo/atomic';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React, { createElement } from 'react';

import { attachProps, camelToDashCase, createForwardRef, dashToPascalCase, isCoveredByReact, mergeRefs } from './utils';
import { attachProps, camelToDashCase, createForwardRef, dashToPascalCase, isCoveredByReact, mergeRefs } from './utils/index.js';

export interface HTMLStencilElement extends HTMLElement {
componentOnReady(): Promise<this>;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import React from 'react';
import ReactDOM from 'react-dom';

import { OverlayEventDetail } from './interfaces';
import { StencilReactForwardedRef, attachProps, dashToPascalCase, defineCustomElement, setRef } from './utils';
import { OverlayEventDetail } from './interfaces.js';
import { StencilReactForwardedRef, attachProps, dashToPascalCase, defineCustomElement, setRef } from './utils/index.js';

interface OverlayElement extends HTMLElement {
present: () => Promise<void>;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
export { createReactComponent } from './createComponent';
export { createOverlayComponent } from './createOverlayComponent';
export { createReactComponent } from './createComponent.js';
export { createOverlayComponent } from './createOverlayComponent.js';
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { camelToDashCase } from './case';
import { camelToDashCase } from './case.js';

export const attachProps = (node: HTMLElement, newProps: any, oldProps: any = {}) => {
// some test frameworks don't render DOM elements, so we test here to make sure we are dealing with DOM first
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from 'react';

import type { StyleReactProps } from '../interfaces';
import type { StyleReactProps } from '../interfaces.js';

export type StencilReactExternalProps<PropType, ElementType> = PropType &
Omit<React.HTMLAttributes<ElementType>, 'style'> &
Expand Down Expand Up @@ -46,5 +46,5 @@ export const defineCustomElement = (tagName: string, customElement: any) => {
}
};

export * from './attachProps';
export * from './case';
export * from './attachProps.js';
export * from './case.js';
Loading
Loading