Skip to content

fix(base): mark base package as type: module #4140

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

Merged
merged 5 commits into from
Apr 20, 2023
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
3 changes: 1 addition & 2 deletions docs/Welcome.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -124,8 +124,7 @@ UI5 Web Components and UI5 Web Components for React are both coming with the `sa
children={
<>
UI5 Web Components for React uses the theme configuration of UI5 Web Components. Please also have a look at their{' '}
<Link href="https://sap.github.io/ui5-webcomponents/playground/advanced/configuration/#theme">documentation</Link>
.
<Link href="https://sap.github.io/ui5-webcomponents/playground/advanced/configuration/#theme">documentation</Link>.
</>
}
/>
Expand Down
11 changes: 11 additions & 0 deletions packages/base/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,20 @@
"name": "@ui5/webcomponents-react-base",
"version": "1.13.1",
"description": "Base for ui5-webcomponents-react",
"type": "module",
"main": "dist/index.js",
"module": "dist/index.js",
"types": "dist/index.d.ts",
"exports": {
".": {
"types": "./dist/index.d.ts",
"default": "./dist/index.js"
},
"./package.json": "./package.json",
"./dist": "./dist/index.js",
"./dist/*": "./dist/*",
"./dist/*.js": "./dist/*.js"
},
"homepage": "https://sap.github.io/ui5-webcomponents-react",
"repository": {
"type": "git",
Expand Down
2 changes: 1 addition & 1 deletion packages/base/src/Device/Media.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import UI5MediaRange from '@ui5/webcomponents-base/dist/MediaRange.js';
import { MediaEventProvider, RANGE_LEGACY_4_STEPS, RangeInfo } from './EventProvider';
import { MediaEventProvider, RANGE_LEGACY_4_STEPS, RangeInfo } from './EventProvider.js';

type RANGE_4_STEPS = 'S' | 'M' | 'L' | 'XL';

Expand Down
4 changes: 2 additions & 2 deletions packages/base/src/Device/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { supportsTouch } from '@ui5/webcomponents-base/dist/Device.js';
import { IOrientation, IWindowSize, OrientationEventProvider, ResizeEventProvider } from './EventProvider';
import { IOrientation, IWindowSize, OrientationEventProvider, ResizeEventProvider } from './EventProvider.js';

const isSSR = () => typeof window === 'undefined';

Expand Down Expand Up @@ -165,7 +165,7 @@ const handleResizeEvent = () => {
// re-export everything from the web components device
export * from '@ui5/webcomponents-base/dist/Device.js';
// export all media methods
export { attachMediaHandler, detachMediaHandler, getCurrentRange } from './Media';
export { attachMediaHandler, detachMediaHandler, getCurrentRange } from './Media.js';

// resize events
export const attachResizeHandler = (fnFunction: (windowSize: IWindowSize) => void): void => {
Expand Down
2 changes: 1 addition & 1 deletion packages/base/src/context/I18nContext.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
'use client';

import I18nBundle from '@ui5/webcomponents-base/dist/i18nBundle.js';
import type I18nBundle from '@ui5/webcomponents-base/dist/i18nBundle.js';
import { createContext, useContext } from 'react';

export const I18nContext = createContext<{
Expand Down
16 changes: 8 additions & 8 deletions packages/base/src/hooks/index.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { useCurrentTheme } from './useCurrentTheme';
import { useI18nBundle } from './useI18nBundle';
import { useIsomorphicId } from './useIsomorphicId';
import { useIsomorphicLayoutEffect } from './useIsomorphicLayoutEffect';
import { useIsRTL } from './useIsRTL';
import { useResponsiveContentPadding } from './useResponsiveContentPadding';
import { useSyncRef } from './useSyncRef';
import { useViewportRange } from './useViewportRange';
import { useCurrentTheme } from './useCurrentTheme.js';
import { useI18nBundle } from './useI18nBundle.js';
import { useIsomorphicId } from './useIsomorphicId.js';
import { useIsomorphicLayoutEffect } from './useIsomorphicLayoutEffect.js';
import { useIsRTL } from './useIsRTL.js';
import { useResponsiveContentPadding } from './useResponsiveContentPadding.js';
import { useSyncRef } from './useSyncRef.js';
import { useViewportRange } from './useViewportRange.js';

export {
useI18nBundle,
Expand Down
4 changes: 2 additions & 2 deletions packages/base/src/hooks/useI18nBundle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

import I18nBundle, { getI18nBundle } from '@ui5/webcomponents-base/dist/i18nBundle.js';
import { useRef } from 'react';
import { useI18nContext } from '../context/I18nContext';
import { useIsomorphicLayoutEffect } from '../hooks';
import { useI18nContext } from '../context/I18nContext.js';
import { useIsomorphicLayoutEffect } from '../hooks/index.js';

const defaultBundle = new I18nBundle('defaultBundle');

Expand Down
2 changes: 1 addition & 1 deletion packages/base/src/hooks/useIsRTL.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import { getRTL } from '@ui5/webcomponents-base/dist/config/RTL.js';
import { RefObject, useRef, useState } from 'react';
import { useIsomorphicLayoutEffect } from '../hooks';
import { useIsomorphicLayoutEffect } from '../hooks/index.js';

const GLOBAL_DIR_CSS_VAR = '--_ui5_dir';

Expand Down
4 changes: 2 additions & 2 deletions packages/base/src/hooks/useIsomorphicId.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { useRef } from 'react';
import * as React from 'react';

function getRandomId() {
if ('randomUUID' in crypto) {
Expand All @@ -17,6 +17,6 @@ export function useIsomorphicId(): string {
}

// eslint-disable-next-line react-hooks/rules-of-hooks
const localId = useRef(getRandomId()); // React version never changes at runtime
const localId = React.useRef(getRandomId()); // React version never changes at runtime
return localId.current;
}
2 changes: 1 addition & 1 deletion packages/base/src/hooks/useResponsiveContentPadding.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import { useEffect, useRef, useState } from 'react';
import { createUseStyles } from 'react-jss';
import { getCurrentRange } from '../Device';
import { getCurrentRange } from '../Device/index.js';

type Range = 'Phone' | 'Tablet' | 'Desktop' | 'LargeDesktop';

Expand Down
2 changes: 1 addition & 1 deletion packages/base/src/hooks/useViewportRange.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
'use client';

import { useEffect, useState } from 'react';
import { getCurrentRange, attachMediaHandler, detachMediaHandler } from '../Device';
import { getCurrentRange, attachMediaHandler, detachMediaHandler } from '../Device/index.js';

export const useViewportRange = () => {
const [currentRange, setCurrentRange] = useState(getCurrentRange()?.name);
Expand Down
16 changes: 8 additions & 8 deletions packages/base/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { getI18nContext, I18nContext } from './context/I18nContext';
import * as Device from './Device';
import * as hooks from './hooks';
import * as spacing from './styling/spacing';
import { ThemingParameters } from './styling/ThemingParameters';
import { getI18nContext, I18nContext } from './context/I18nContext.js';
import * as Device from './Device/index.js';
import * as hooks from './hooks/index.js';
import * as spacing from './styling/spacing.js';
import { ThemingParameters } from './styling/ThemingParameters.js';

export * from './styling/CssSizeVariables';
export * from './utils/index';
export * from './hooks';
export * from './styling/CssSizeVariables.js';
export * from './utils/index.js';
export * from './hooks/index.js';

export { getI18nContext, I18nContext, ThemingParameters, Device, hooks, spacing };
4 changes: 2 additions & 2 deletions packages/base/src/utils/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,5 @@ export const enrichEventWithDetails = <T extends Record<string, unknown>, Return
return event as unknown as ReturnType;
};

export { debounce } from './debounce';
export { throttle } from './throttle';
export { debounce } from './debounce.js';
export { throttle } from './throttle.js';
2 changes: 2 additions & 0 deletions packages/base/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
{
"extends": "../../tsconfig.base.json",
"compilerOptions": {
"module": "Node16",
"moduleResolution": "Node16",
"baseUrl": ".",
"outDir": "./dist",
"declarationDir": "./dist",
Expand Down