Repository: api-platform/admin
Pull request #473 (2022-09-13 17:57:00)

fix: build only esm
More and more packages are ESM only: it doesn't make sense to continue to build CJS.


Patch:
diff --git a/.eslintrc.cjs b/.eslintrc.cjs
index 3e905e9..1634d11 100644
--- a/.eslintrc.cjs
+++ b/.eslintrc.cjs
@@ -25,7 +25,7 @@ module.exports = {
         'prettier',
       ],
       parserOptions: {
-        project: ['./tsconfig.json'],
+        project: ['./tsconfig.eslint.json'],
       },
       rules: {
         '@typescript-eslint/no-use-before-define': 'error',
diff --git a/package.json b/package.json
index ff80b83..9a09480 100644
--- a/package.json
+++ b/package.json
@@ -8,14 +8,9 @@
     "lib",
     "src"
   ],
-  "exports": {
-    ".": {
-      "import": "./lib/esm/index.js",
-      "require": "./lib/cjs/index.js"
-    }
-  },
-  "main": "./lib/cjs/index.js",
-  "module": "./lib/esm/index.js",
+  "type": "module",
+  "exports": "./lib/index.js",
+  "main": "./lib/index.js",
   "repository": "api-platform/admin",
   "homepage": "https://github.com/api-platform/admin",
   "bugs": "https://github.com/api-platform/admin/issues",
@@ -69,7 +64,7 @@
     "react-dom": "*"
   },
   "scripts": {
-    "build": "rimraf ./lib && tsc -p tsconfig.cjs.json && tsc -p tsconfig.esm.json",
+    "build": "rimraf ./lib && tsc",
     "eslint-check": "eslint-config-prettier .eslintrc.cjs",
     "fix": "eslint --ignore-pattern 'lib/*' --ext .ts,.tsx,.js,.md --fix .",
     "lint": "eslint --ignore-pattern 'lib/*' --ext .ts,.tsx,.js,.md .",
diff --git a/src/AdminGuesser.tsx b/src/AdminGuesser.tsx
index d9a658d..ac30a40 100644
--- a/src/AdminGuesser.tsx
+++ b/src/AdminGuesser.tsx
@@ -15,15 +15,20 @@ import type { ComponentType, ErrorInfo } from 'react';
 import type { AdminProps, ErrorProps } from 'react-admin';
 import type { Resource } from '@api-platform/api-doc-parser';
 
-import IntrospectionContext from './IntrospectionContext';
-import ResourceGuesser from './ResourceGuesser';
-import SchemaAnalyzerContext from './SchemaAnalyzerContext';
-import { Error as DefaultError, Layout, LoginPage, lightTheme } from './layout';
+import IntrospectionContext from './IntrospectionContext.js';
+import ResourceGuesser from './ResourceGuesser.js';
+import SchemaAnalyzerContext from './SchemaAnalyzerContext.js';
+import {
+  Error as DefaultError,
+  Layout,
+  LoginPage,
+  lightTheme,
+} from './layout/index.js';
 import getRoutesAndResourcesFromNodes, {
   isSingleChildFunction,
-} from './getRoutesAndResourcesFromNodes';
-import useDisplayOverrideCode from './useDisplayOverrideCode';
-import type { ApiPlatformAdminDataProvider, SchemaAnalyzer } from './types';
+} from './getRoutesAndResourcesFromNodes.js';
+import useDisplayOverrideCode from './useDisplayOverrideCode.js';
+import type { ApiPlatformAdminDataProvider, SchemaAnalyzer } from './types.js';
 
 export interface AdminGuesserProps extends AdminProps {
   dataProvider: ApiPlatformAdminDataProvider;
diff --git a/src/CreateGuesser.tsx b/src/CreateGuesser.tsx
index d25655b..0671eaf 100644
--- a/src/CreateGuesser.tsx
+++ b/src/CreateGuesser.tsx
@@ -12,13 +12,13 @@ import {
 import type { HttpError, RaRecord } from 'react-admin';
 import type { Field, Resource } from '@api-platform/api-doc-parser';
 
-import InputGuesser from './InputGuesser';
-import Introspecter from './Introspecter';
-import useDisplayOverrideCode from './useDisplayOverrideCode';
+import InputGuesser from './InputGuesser.js';
+import Introspecter from './Introspecter.js';
+import useDisplayOverrideCode from './useDisplayOverrideCode.js';
 import type {
   CreateGuesserProps,
   IntrospectedCreateGuesserProps,
-} from './types';
+} from './types.js';
 
 const getOverrideCode = (schema: Resource, fields: Field[]) => {
   let code =
diff --git a/src/EditGuesser.tsx b/src/EditGuesser.tsx
index 46b1674..e151287 100644
--- a/src/EditGuesser.tsx
+++ b/src/EditGuesser.tsx
@@ -13,11 +13,14 @@ import type { HttpError, RaRecord } from 'react-admin';
 import { useParams } from 'react-router-dom';
 import type { Field, Resource } from '@api-platform/api-doc-parser';
 
-import InputGuesser from './InputGuesser';
-import Introspecter from './Introspecter';
-import useMercureSubscription from './useMercureSubscription';
-import useDisplayOverrideCode from './useDisplayOverrideCode';
-import type { EditGuesserProps, IntrospectedEditGuesserProps } from './types';
+import InputGuesser from './InputGuesser.js';
+import Introspecter from './Introspecter.js';
+import useMercureSubscription from './useMercureSubscription.js';
+import useDisplayOverrideCode from './useDisplayOverrideCode.js';
+import type {
+  EditGuesserProps,
+  IntrospectedEditGuesserProps,
+} from './types.js';
 
 const getOverrideCode = (schema: Resource, fields: Field[]) => {
   let code =
diff --git a/src/FieldGuesser.tsx b/src/FieldGuesser.tsx
index bfff7f5..dd5b159 100644
--- a/src/FieldGuesser.tsx
+++ b/src/FieldGuesser.tsx
@@ -28,13 +28,13 @@ import type {
 } from 'react-admin';
 import type { Field, Resource } from '@api-platform/api-doc-parser';
 
-import Introspecter from './Introspecter';
+import Introspecter from './Introspecter.js';
 import type {
   FieldGuesserProps,
   FieldProps,
   IntrospectedFieldGuesserProps,
   SchemaAnalyzer,
-} from './types';
+} from './types.js';
 
 const isFieldSortable = (field: Field, schema: Resource) =>
   !!schema.parameters &&
diff --git a/src/FilterGuesser.tsx b/src/FilterGuesser.tsx
index e1f4b70..18836a8 100644
--- a/src/FilterGuesser.tsx
+++ b/src/FilterGuesser.tsx
@@ -1,12 +1,12 @@
 import React, { useEffect, useState } from 'react';
 import { Filter, useResourceContext } from 'react-admin';
-import InputGuesser from './InputGuesser';
-import Introspecter from './Introspecter';
+import InputGuesser from './InputGuesser.js';
+import Introspecter from './Introspecter.js';
 import type {
   FilterGuesserProps,
   FilterParameter,
   IntrospectedFiterGuesserProps,
-} from './types';
+} from './types.js';
 
 export const IntrospectedFilterGuesser = ({
   fields,
diff --git a/src/InputGuesser.tsx b/src/InputGuesser.tsx
index e910598..2fb082e 100644
--- a/src/InputGuesser.tsx
+++ b/src/InputGuesser.tsx
@@ -26,8 +26,11 @@ import type {
   TextInputProps,
 } from 'react-admin';
 import isPlainObject from 'lodash.isplainobject';
-import Introspecter from './Introspecter';
-import type { InputGuesserProps, IntrospectedInputGuesserProps } from './types';
+import Introspecter from './Introspecter.js';
+import type {
+  InputGuesserProps,
+  IntrospectedInputGuesserProps,
+} from './types.js';
 
 const convertEmptyStringToNull = (value: string) =>
   value === '' ? null : value;
diff --git a/src/Introspecter.tsx b/src/Introspecter.tsx
index effd81d..f33e6ab 100644
--- a/src/Introspecter.tsx
+++ b/src/Introspecter.tsx
@@ -1,13 +1,13 @@
 import React, { useContext, useEffect, useMemo } from 'react';
 import PropTypes from 'prop-types';
 import { useLogoutIfAccessDenied } from 'react-admin';
-import SchemaAnalyzerContext from './SchemaAnalyzerContext';
-import useIntrospect from './useIntrospect';
+import SchemaAnalyzerContext from './SchemaAnalyzerContext.js';
+import useIntrospect from './useIntrospect.js';
 import type {
   IntrospecterProps,
   ResourcesIntrospecterProps,
   SchemaAnalyzer,
-} from './types';
+} from './types.js';
 
 const ResourcesIntrospecter = ({
   component: Component,
diff --git a/src/ListGuesser.tsx b/src/ListGuesser.tsx
index ad3f129..6583f90 100644
--- a/src/ListGuesser.tsx
+++ b/src/ListGuesser.tsx
@@ -12,16 +12,16 @@ import {
 import type { DatagridBodyProps } from 'react-admin';
 import type { Field, Resource } from '@api-platform/api-doc-parser';
 
-import FieldGuesser from './FieldGuesser';
-import FilterGuesser from './FilterGuesser';
-import Introspecter from './Introspecter';
-import useMercureSubscription from './useMercureSubscription';
-import useDisplayOverrideCode from './useDisplayOverrideCode';
+import FieldGuesser from './FieldGuesser.js';
+import FilterGuesser from './FilterGuesser.js';
+import Introspecter from './Introspecter.js';
+import useMercureSubscription from './useMercureSubscription.js';
+import useDisplayOverrideCode from './useDisplayOverrideCode.js';
 import type {
   ApiPlatformAdminRecord,
   IntrospectedListGuesserProps,
   ListGuesserProps,
-} from './types';
+} from './types.js';
 
 const getOverrideCode = (schema: Resource, fields: Field[]) => {
   let code =
diff --git a/src/ResourceGuesser.tsx b/src/ResourceGuesser.tsx
index 6e4987b..e5e8785 100644
--- a/src/ResourceGuesser.tsx
+++ b/src/ResourceGuesser.tsx
@@ -6,15 +6,15 @@ import {
   useResourceDefinitionContext,
 } from 'react-admin';
 import type { ResourceDefinition, ResourceProps } from 'react-admin';
-import ListGuesser from './ListGuesser';
-import CreateGuesser from './CreateGuesser';
-import EditGuesser from './EditGuesser';
-import ShowGuesser from './ShowGuesser';
-import Introspecter from './Introspecter';
+import ListGuesser from './ListGuesser.js';
+import CreateGuesser from './CreateGuesser.js';
+import EditGuesser from './EditGuesser.js';
+import ShowGuesser from './ShowGuesser.js';
+import Introspecter from './Introspecter.js';
 import type {
   IntrospectedResourceGuesserProps,
   ResourceGuesserProps,
-} from './types';
+} from './types.js';
 
 export const IntrospectedResourceGuesser = ({
   resource,
diff --git a/src/SchemaAnalyzerContext.ts b/src/SchemaAnalyzerContext.ts
index b9b5051..5a32d4d 100644
--- a/src/SchemaAnalyzerContext.ts
+++ b/src/SchemaAnalyzerContext.ts
@@ -1,7 +1,7 @@
 import {
   /* tree-shaking no-side-effects-when-called */ createContext,
 } from 'react';
-import type { SchemaAnalyzer } from './types';
+import type { SchemaAnalyzer } from './types.js';
 
 const SchemaAnalyzerContext = createContext<SchemaAnalyzer | null>(null);
 
diff --git a/src/ShowGuesser.tsx b/src/ShowGuesser.tsx
index e9b2975..323c9c3 100644
--- a/src/ShowGuesser.tsx
+++ b/src/ShowGuesser.tsx
@@ -4,11 +4,14 @@ import { Show, SimpleShowLayout, useResourceContext } from 'react-admin';
 import { useParams } from 'react-router-dom';
 import type { Field, Resource } from '@api-platform/api-doc-parser';
 
-import FieldGuesser from './FieldGuesser';
-import Introspecter from './Introspecter';
-import useMercureSubscription from './useMercureSubscription';
-import useDisplayOverrideCode from './useDisplayOverrideCode';
-import type { IntrospectedShowGuesserProps, ShowGuesserProps } from './types';
+import FieldGuesser from './FieldGuesser.js';
+import Introspecter from './Introspecter.js';
+import useMercureSubscription from './useMercureSubscription.js';
+import useDisplayOverrideCode from './useDisplayOverrideCode.js';
+import type {
+  IntrospectedShowGuesserProps,
+  ShowGuesserProps,
+} from './types.js';
 
 const getOverrideCode = (schema: Resource, fields: Field[]) => {
   let code =
diff --git a/src/dataProvider/adminDataProvider.ts b/src/dataProvider/adminDataProvider.ts
index cf9513e..868550e 100644
--- a/src/dataProvider/adminDataProvider.ts
+++ b/src/dataProvider/adminDataProvider.ts
@@ -1,11 +1,11 @@
 import type { Api, Resource } from '@api-platform/api-doc-parser';
-import { mercureManager } from '../mercure';
+import { mercureManager } from '../mercure/index.js';
 import type {
   ApiDocumentationParserResponse,
   ApiPlatformAdminDataProviderFactoryParams,
   ApiPlatformAdminRecord,
   MercureOptions,
-} from '../types';
+} from '../types.js';
 
 export default (
   factoryParams: Required<ApiPlatformAdminDataProviderFactoryParams>,
diff --git a/src/dataProvider/index.ts b/src/dataProvider/index.ts
index 963b5cb..61a9f9b 100644
--- a/src/dataProvider/index.ts
+++ b/src/dataProvider/index.ts
@@ -1,5 +1,5 @@
-import adminDataProvider from './adminDataProvider';
-import restDataProvider from './restDataProvider';
-import useUpdateCache from './useUpdateCache';
+import adminDataProvider from './adminDataProvider.js';
+import restDataProvider from './restDataProvider.js';
+import useUpdateCache from './useUpdateCache.js';
 
 export { adminDataProvider, restDataProvider, useUpdateCache };
diff --git a/src/dataProvider/restDataProvider.ts b/src/dataProvider/restDataProvider.ts
index 87e6557..8bd1537 100644
--- a/src/dataProvider/restDataProvider.ts
+++ b/src/dataProvider/restDataProvider.ts
@@ -1,7 +1,7 @@
 import { stringify } from 'query-string';
 import { fetchUtils } from 'react-admin';
 import type { DataProvider } from 'react-admin';
-import { removeTrailingSlash } from '../removeTrailingSlash';
+import { removeTrailingSlash } from '../removeTrailingSlash.js';
 
 // Based on https://github.com/marmelab/react-admin/blob/master/packages/ra-data-simple-rest/src/index.ts
 
diff --git a/src/dataProvider/useUpdateCache.ts b/src/dataProvider/useUpdateCache.ts
index 5e5cf50..51da8cd 100644
--- a/src/dataProvider/useUpdateCache.ts
+++ b/src/dataProvider/useUpdateCache.ts
@@ -1,7 +1,7 @@
 import { useCallback } from 'react';
 import type { GetListResult, Identifier } from 'react-admin';
 import { useQueryClient } from 'react-query';
-import type { ApiPlatformAdminRecord } from '../types';
+import type { ApiPlatformAdminRecord } from '../types.js';
 
 const useUpdateCache = () => {
   const queryClient = useQueryClient();
diff --git a/src/hydra/HydraAdmin.tsx b/src/hydra/HydraAdmin.tsx
index ffe271f..79d9b14 100644
--- a/src/hydra/HydraAdmin.tsx
+++ b/src/hydra/HydraAdmin.tsx
@@ -1,10 +1,10 @@
 import React from 'react';
 import PropTypes from 'prop-types';
-import dataProviderFactory from './dataProvider';
-import /* tree-shaking no-side-effects-when-called */ schemaAnalyzer from './schemaAnalyzer';
-import AdminGuesser from '../AdminGuesser';
-import type { AdminGuesserProps } from '../AdminGuesser';
-import type { MercureOptions } from '../types';
+import dataProviderFactory from './dataProvider.js';
+import /* tree-shaking no-side-effects-when-called */ schemaAnalyzer from './schemaAnalyzer.js';
+import AdminGuesser from '../AdminGuesser.js';
+import type { AdminGuesserProps } from '../AdminGuesser.js';
+import type { MercureOptions } from '../types.js';
 
 type AdminGuesserPartialProps = Omit<
   AdminGuesserProps,
diff --git a/src/hydra/dataProvider.ts b/src/hydra/dataProvider.ts
index 40a6606..3170779 100644
--- a/src/hydra/dataProvider.ts
+++ b/src/hydra/dataProvider.ts
@@ -22,11 +22,11 @@ import type {
   UpdateParams,
 } from 'react-admin';
 
-import fetchHydra from './fetchHydra';
-import { resolveSchemaParameters } from '../schemaAnalyzer';
-import { adminDataProvider } from '../dataProvider';
-import { mercureManager } from '../mercure';
-import { removeTrailingSlash } from '../removeTrailingSlash';
+import fetchHydra from './fetchHydra.js';
+import { resolveSchemaParameters } from '../schemaAnalyzer.js';
+import { adminDataProvider } from '../dataProvider/index.js';
+import { mercureManager } from '../mercure/index.js';
+import { removeTrailingSlash } from '../removeTrailingSlash.js';
 import type {
   ApiPlatformAdminDataProvider,
   ApiPlatformAdminDataProviderParams,
@@ -38,7 +38,7 @@ import type {
   HydraHttpClientResponse,
   MercureOptions,
   SearchParams,
-} from '../types';
+} from '../types.js';
 
 // eslint-disable-next-line @typescript-eslint/no-explicit-any
 const isPlainObject = (value: any): value is object =>
diff --git a/src/hydra/fetchHydra.ts b/src/hydra/fetchHydra.ts
index 74754fe..c02db95 100644
--- a/src/hydra/fetchHydra.ts
+++ b/src/hydra/fetchHydra.ts
@@ -6,7 +6,7 @@ import {
 import jsonld from 'jsonld';
 import type { NodeObject } from 'jsonld';
 import type { JsonLdObj } from 'jsonld/jsonld-spec';
-import type { HttpClientOptions, HydraHttpClientResponse } from '../types';
+import type { HttpClientOptions, HydraHttpClientResponse } from '../types.js';
 
 /**
  * Sends HTTP requests to a Hydra API.
diff --git a/src/hydra/index.ts b/src/hydra/index.ts
index 8677edc..6904bfb 100644
--- a/src/hydra/index.ts
+++ b/src/hydra/index.ts
@@ -1,8 +1,8 @@
-import dataProvider from './dataProvider';
-import fetchHydra from './fetchHydra';
-import HydraAdmin from './HydraAdmin';
-import type { HydraAdminProps } from './HydraAdmin';
-import schemaAnalyzer from './schemaAnalyzer';
+import dataProvider from './dataProvider.js';
+import fetchHydra from './fetchHydra.js';
+import HydraAdmin from './HydraAdmin.js';
+import type { HydraAdminProps } from './HydraAdmin.js';
+import schemaAnalyzer from './schemaAnalyzer.js';
 
 export {
   dataProvider,
diff --git a/src/hydra/schemaAnalyzer.ts b/src/hydra/schemaAnalyzer.ts
index 2a9c55b..beed813 100644
--- a/src/hydra/schemaAnalyzer.ts
+++ b/src/hydra/schemaAnalyzer.ts
@@ -4,8 +4,8 @@ import type { JsonLdObj } from 'jsonld/jsonld-spec';
 import {
   getFiltersParametersFromSchema,
   getOrderParametersFromSchema,
-} from '../schemaAnalyzer';
-import type { SchemaAnalyzer, SubmissionErrors } from '../types';
+} from '../schemaAnalyzer.js';
+import type { SchemaAnalyzer, SubmissionErrors } from '../types.js';
 
 const withHttpScheme = (value: string | null | undefined) =>
   value?.startsWith('https://') ? value.replace(/^https/, 'http') : value;
diff --git a/src/index.ts b/src/index.ts
index 3b527f4..36dd447 100644
--- a/src/index.ts
+++ b/src/index.ts
@@ -1,16 +1,16 @@
-import AdminGuesser from './AdminGuesser';
-import CreateGuesser from './CreateGuesser';
-import EditGuesser from './EditGuesser';
-import FieldGuesser from './FieldGuesser';
-import InputGuesser from './InputGuesser';
-import Introspecter from './Introspecter';
-import ListGuesser from './ListGuesser';
-import ResourceGuesser from './ResourceGuesser';
-import SchemaAnalyzerContext from './SchemaAnalyzerContext';
-import ShowGuesser from './ShowGuesser';
-import useIntrospect from './useIntrospect';
-import useIntrospection from './useIntrospection';
-import useMercureSubscription from './useMercureSubscription';
+import AdminGuesser from './AdminGuesser.js';
+import CreateGuesser from './CreateGuesser.js';
+import EditGuesser from './EditGuesser.js';
+import FieldGuesser from './FieldGuesser.js';
+import InputGuesser from './InputGuesser.js';
+import Introspecter from './Introspecter.js';
+import ListGuesser from './ListGuesser.js';
+import ResourceGuesser from './ResourceGuesser.js';
+import SchemaAnalyzerContext from './SchemaAnalyzerContext.js';
+import ShowGuesser from './ShowGuesser.js';
+import useIntrospect from './useIntrospect.js';
+import useIntrospection from './useIntrospection.js';
+import useMercureSubscription from './useMercureSubscription.js';
 
 export {
   AdminGuesser,
@@ -32,12 +32,12 @@ export {
   dataProvider as hydraDataProvider,
   schemaAnalyzer as hydraSchemaAnalyzer,
   fetchHydra,
-} from './hydra';
-export type { HydraAdminProps } from './hydra';
+} from './hydra/index.js';
+export type { HydraAdminProps } from './hydra/index.js';
 export {
   OpenApiAdmin,
   dataProvider as openApiDataProvider,
   schemaAnalyzer as openApiSchemaAnalyzer,
-} from './openapi';
-export type { OpenApiAdminProps } from './openapi';
-export * from './types';
+} from './openapi/index.js';
+export type { OpenApiAdminProps } from './openapi/index.js';
+export * from './types.js';
diff --git a/src/layout/AppBar.tsx b/src/layout/AppBar.tsx
index dd21465..0f2cafd 100644
--- a/src/layout/AppBar.tsx
+++ b/src/layout/AppBar.tsx
@@ -8,8 +8,8 @@ import {
 import type { AppBarProps } from 'react-admin';
 import { Box, Typography } from '@mui/material';
 
-import Logo from './Logo';
-import { darkTheme, lightTheme } from './themes';
+import Logo from './Logo.js';
+import { darkTheme, lightTheme } from './themes.js';
 
 const CustomAppBar = ({ classes, userMenu, ...props }: AppBarProps) => {
   const authProvider = useAuthProvider();
diff --git a/src/layout/Error.tsx b/src/layout/Error.tsx
index 4c8b745..fbf2fbb 100644
--- a/src/layout/Error.tsx
+++ b/src/layout/Error.tsx
@@ -15,7 +15,7 @@ import ExpandMoreIcon from '@mui/icons-material/ExpandMore';
 import HistoryIcon from '@mui/icons-material/History';
 import RefreshIcon from '@mui/icons-material/Refresh';
 import type { FallbackProps } from 'react-error-boundary';
-import LogoError from './LogoError';
+import LogoError from './LogoError.js';
 
 const PREFIX = 'RaError';
 
diff --git a/src/layout/Layout.tsx b/src/layout/Layout.tsx
index 1911237..96b8566 100644
--- a/src/layout/Layout.tsx
+++ b/src/layout/Layout.tsx
@@ -1,8 +1,8 @@
 import React from 'react';
 import { Layout } from 'react-admin';
 import type { LayoutProps } from 'react-admin';
-import AppBar from './AppBar';
-import DefaultError from './Error';
+import AppBar from './AppBar.js';
+import DefaultError from './Error.js';
 
 const CustomLayout = (props: LayoutProps) => (
   <Layout appBar={AppBar} error={DefaultError} {...props} />
diff --git a/src/layout/index.ts b/src/layout/index.ts
index 98f8775..4a6bde6 100644
--- a/src/layout/index.ts
+++ b/src/layout/index.ts
@@ -1,6 +1,6 @@
-import Error from './Error';
-import Layout from './Layout';
-import LoginPage from './LoginPage';
+import Error from './Error.js';
+import Layout from './Layout.js';
+import LoginPage from './LoginPage.js';
 
 export { Error, Layout, LoginPage };
-export * from './themes';
+export * from './themes.js';
diff --git a/src/mercure/createSubscription.ts b/src/mercure/createSubscription.ts
index ac53aab..2f8336a 100644
--- a/src/mercure/createSubscription.ts
+++ b/src/mercure/createSubscription.ts
@@ -3,7 +3,7 @@ import type {
   DataTransformer,
   MercureOptions,
   MercureSubscription,
-} from '../types';
+} from '../types.js';
 
 const createSubscription = (
   mercure: MercureOptions,
diff --git a/src/mercure/index.ts b/src/mercure/index.ts
index 9341b4e..c280bcd 100644
--- a/src/mercure/index.ts
+++ b/src/mercure/index.ts
@@ -1,4 +1,4 @@
-import createSubscription from './createSubscription';
-import manager from './manager';
+import createSubscription from './createSubscription.js';
+import manager from './manager.js';
 
 export { createSubscription, manager as mercureManager };
diff --git a/src/mercure/manager.ts b/src/mercure/manager.ts
index 792f63d..d0f29c9 100644
--- a/src/mercure/manager.ts
+++ b/src/mercure/manager.ts
@@ -1,10 +1,10 @@
-import createSubscription from './createSubscription';
+import createSubscription from './createSubscription.js';
 import type {
   ApiPlatformAdminRecord,
   DataTransformer,
   MercureOptions,
   MercureSubscription,
-} from '../types';
+} from '../types.js';
 
 // store mercure subscriptions
 const subscriptions: Record<string, MercureSubscription> = {};
diff --git a/src/openapi/OpenApiAdmin.tsx b/src/openapi/OpenApiAdmin.tsx
index 8775a55..e386375 100644
--- a/src/openapi/OpenApiAdmin.tsx
+++ b/src/openapi/OpenApiAdmin.tsx
@@ -1,11 +1,11 @@
 import React from 'react';
 import PropTypes from 'prop-types';
-import dataProviderFactory from './dataProvider';
-import { restDataProvider } from '../dataProvider';
-import /* tree-shaking no-side-effects-when-called */ schemaAnalyzer from './schemaAnalyzer';
-import AdminGuesser from '../AdminGuesser';
-import type { AdminGuesserProps } from '../AdminGuesser';
-import type { MercureOptions } from '../types';
+import dataProviderFactory from './dataProvider.js';
+import { restDataProvider } from '../dataProvider/index.js';
+import /* tree-shaking no-side-effects-when-called */ schemaAnalyzer from './schemaAnalyzer.js';
+import AdminGuesser from '../AdminGuesser.js';
+import type { AdminGuesserProps } from '../AdminGuesser.js';
+import type { MercureOptions } from '../types.js';
 
 type AdminGuesserPartialProps = Omit<
   AdminGuesserProps,
diff --git a/src/openapi/dataProvider.ts b/src/openapi/dataProvider.ts
index 2d3b20e..cf26765 100644
--- a/src/openapi/dataProvider.ts
+++ b/src/openapi/dataProvider.ts
@@ -1,12 +1,12 @@
 import { parseOpenApi3Documentation } from '@api-platform/api-doc-parser';
 import { fetchUtils } from 'react-admin';
-import { adminDataProvider } from '../dataProvider';
+import { adminDataProvider } from '../dataProvider/index.js';
 import type {
   ApiPlatformAdminDataProvider,
   HttpClientOptions,
   MercureOptions,
   OpenApiDataProviderFactoryParams,
-} from '../types';
+} from '../types.js';
 
 const fetchJson = (url: URL, options: HttpClientOptions = {}) => {
   let { headers } = options;
diff --git a/src/openapi/index.ts b/src/openapi/index.ts
index 514032b..0cbcdb0 100644
--- a/src/openapi/index.ts
+++ b/src/openapi/index.ts
@@ -1,6 +1,6 @@
-import dataProvider from './dataProvider';
-import OpenApiAdmin from './OpenApiAdmin';
-import type { OpenApiAdminProps } from './OpenApiAdmin';
-import schemaAnalyzer from './schemaAnalyzer';
+import dataProvider from './dataProvider.js';
+import OpenApiAdmin from './OpenApiAdmin.js';
+import type { OpenApiAdminProps } from './OpenApiAdmin.js';
+import schemaAnalyzer from './schemaAnalyzer.js';
 
 export { dataProvider, OpenApiAdmin, OpenApiAdminProps, schemaAnalyzer };
diff --git a/src/openapi/schemaAnalyzer.ts b/src/openapi/schemaAnalyzer.ts
index b350c48..29a9783 100644
--- a/src/openapi/schemaAnalyzer.ts
+++ b/src/openapi/schemaAnalyzer.ts
@@ -2,8 +2,8 @@ import type { Field, Resource } from '@api-platform/api-doc-parser';
 import {
   getFiltersParametersFromSchema,
   getOrderParametersFromSchema,
-} from '../schemaAnalyzer';
-import type { SchemaAnalyzer } from '../types';
+} from '../schemaAnalyzer.js';
+import type { SchemaAnalyzer } from '../types.js';
 
 /**
  * @param schema The schema of a resource
diff --git a/src/schemaAnalyzer.ts b/src/schemaAnalyzer.ts
index 3ce9d6e..4795abc 100644
--- a/src/schemaAnalyzer.ts
+++ b/src/schemaAnalyzer.ts
@@ -1,5 +1,5 @@
 import type { Resource } from '@api-platform/api-doc-parser';
-import type { FilterParameter } from './types';
+import type { FilterParameter } from './types.js';
 
 /**
  * @param schema The schema of a resource
diff --git a/src/useIntrospect.ts b/src/useIntrospect.ts
index 58583c2..59c7d1e 100644
--- a/src/useIntrospect.ts
+++ b/src/useIntrospect.ts
@@ -1,7 +1,10 @@
 import { useQuery } from 'react-query';
 import { useDataProvider } from 'react-admin';
 import type { UseQueryOptions } from 'react-query';
-import type { ApiPlatformAdminDataProvider, IntrospectPayload } from './types';
+import type {
+  ApiPlatformAdminDataProvider,
+  IntrospectPayload,
+} from './types.js';
 
 const useIntrospect = (options?: UseQueryOptions<IntrospectPayload, Error>) => {
   const dataProvider = useDataProvider<ApiPlatformAdminDataProvider>();
diff --git a/src/useIntrospection.ts b/src/useIntrospection.ts
index 47ca520..b13ff80 100644
--- a/src/useIntrospection.ts
+++ b/src/useIntrospection.ts
@@ -1,5 +1,5 @@
 import { useContext } from 'react';
-import IntrospectionContext from './IntrospectionContext';
+import IntrospectionContext from './IntrospectionContext.js';
 
 const useIntrospection = () => useContext(IntrospectionContext).introspect;
 
diff --git a/src/useMercureSubscription.ts b/src/useMercureSubscription.ts
index 7401514..25366fc 100644
--- a/src/useMercureSubscription.ts
+++ b/src/useMercureSubscription.ts
@@ -1,8 +1,8 @@
 import { useEffect, useRef } from 'react';
 import { useDataProvider } from 'react-admin';
 import type { Identifier } from 'react-admin';
-import { useUpdateCache } from './dataProvider';
-import type { ApiPlatformAdminDataProvider } from './types';
+import { useUpdateCache } from './dataProvider/index.js';
+import type { ApiPlatformAdminDataProvider } from './types.js';
 
 export default function useMercureSubscription(
   resource: string | undefined,
diff --git a/tsconfig.build.json b/tsconfig.build.json
deleted file mode 100644
index 07310ec..0000000
--- a/tsconfig.build.json
+++ /dev/null
@@ -1,4 +0,0 @@
-{
-  "extends": "./tsconfig.json",
-  "exclude": ["./src/**/*.test.ts", "./src/**/*.test.tsx"]
-}
diff --git a/tsconfig.cjs.json b/tsconfig.cjs.json
deleted file mode 100644
index 6065468..0000000
--- a/tsconfig.cjs.json
+++ /dev/null
@@ -1,7 +0,0 @@
-{
-  "extends": "./tsconfig.build.json",
-  "compilerOptions": {
-    "module": "commonjs",
-    "outDir": "./lib/cjs",
-  }
-}
diff --git a/tsconfig.eslint.json b/tsconfig.eslint.json
new file mode 100644
index 0000000..a8d4317
--- /dev/null
+++ b/tsconfig.eslint.json
@@ -0,0 +1,4 @@
+{
+  "extends": "./tsconfig.json",
+  "exclude": []
+}
diff --git a/tsconfig.esm.json b/tsconfig.esm.json
deleted file mode 100644
index e48bf3e..0000000
--- a/tsconfig.esm.json
+++ /dev/null
@@ -1,8 +0,0 @@
-{
-  "extends": "./tsconfig.build.json",
-  "compilerOptions": {
-    "module": "esnext",
-    "moduleResolution": "node",
-    "outDir": "./lib/esm",
-  }
-}
diff --git a/tsconfig.json b/tsconfig.json
index 7a8c9a3..6992dd4 100644
--- a/tsconfig.json
+++ b/tsconfig.json
@@ -2,10 +2,10 @@
   "compilerOptions": {
     "target": "ES6",
     "lib": ["ESNext", "dom", "dom.iterable"],
-    "module": "commonjs",
+    "module": "esnext",
     "moduleResolution": "node",
     "sourceMap": true,
-    "outDir": "./lib/cjs",
+    "outDir": "./lib",
     "declaration": true,
     "declarationMap": true,
     "rootDir": "./src",
@@ -21,5 +21,6 @@
     "noImplicitReturns": true,
     "noUncheckedIndexedAccess": true
   },
+  "exclude": ["./src/**/*.test.ts", "./src/**/*.test.tsx"],
   "include": ["./src"]
 }


Test patch:
diff --git a/src/AdminGuesser.test.tsx b/src/AdminGuesser.test.tsx
index ff4d77f..374c448 100644
--- a/src/AdminGuesser.test.tsx
+++ b/src/AdminGuesser.test.tsx
@@ -1,13 +1,13 @@
 import React from 'react';
 import ReactTestRenderer from 'react-test-renderer/shallow';
-import { AdminResourcesGuesser } from './AdminGuesser';
-import ResourceGuesser from './ResourceGuesser';
-import resources from './__fixtures__/resources';
-import { API_DATA } from './__fixtures__/parsedData';
+import { AdminResourcesGuesser } from './AdminGuesser.js';
+import ResourceGuesser from './ResourceGuesser.js';
+import resources from './__fixtures__/resources.js';
+import { API_DATA } from './__fixtures__/parsedData.js';
 import type {
   ApiPlatformAdminDataProvider,
   ApiPlatformAdminRecord,
-} from './types';
+} from './types.js';
 
 const dataProvider: ApiPlatformAdminDataProvider = {
   getList: () => Promise.resolve({ data: [], total: 0 }),
diff --git a/src/InputGuesser.test.tsx b/src/InputGuesser.test.tsx
index 321358c..48e4aec 100644
--- a/src/InputGuesser.test.tsx
+++ b/src/InputGuesser.test.tsx
@@ -9,15 +9,15 @@ import { fireEvent, render, screen, waitFor } from '@testing-library/react';
 import userEvent from '@testing-library/user-event';
 import { Resource } from '@api-platform/api-doc-parser';
 
-import InputGuesser from './InputGuesser';
-import SchemaAnalyzerContext from './SchemaAnalyzerContext';
-import schemaAnalyzer from './hydra/schemaAnalyzer';
+import InputGuesser from './InputGuesser.js';
+import SchemaAnalyzerContext from './SchemaAnalyzerContext.js';
+import schemaAnalyzer from './hydra/schemaAnalyzer.js';
 import type {
   ApiPlatformAdminDataProvider,
   ApiPlatformAdminRecord,
-} from './types';
+} from './types.js';
 
-import { API_FIELDS_DATA } from './__fixtures__/parsedData';
+import { API_FIELDS_DATA } from './__fixtures__/parsedData.js';
 
 const hydraSchemaAnalyzer = schemaAnalyzer();
 const dataProvider: ApiPlatformAdminDataProvider = {
diff --git a/src/ResourceGuesser.test.tsx b/src/ResourceGuesser.test.tsx
index d968e1d..8fac3b7 100644
--- a/src/ResourceGuesser.test.tsx
+++ b/src/ResourceGuesser.test.tsx
@@ -1,6 +1,6 @@
 import React from 'react';
 import ReactTestRenderer from 'react-test-renderer/shallow';
-import ResourceGuesser from './ResourceGuesser';
+import ResourceGuesser from './ResourceGuesser.js';
 
 describe('<ResourceGuesser />', () => {
   const renderer = ReactTestRenderer.createRenderer();
diff --git a/src/ShowGuesser.test.tsx b/src/ShowGuesser.test.tsx
index c58d448..0fdad4e 100644
--- a/src/ShowGuesser.test.tsx
+++ b/src/ShowGuesser.test.tsx
@@ -3,15 +3,15 @@ import { AdminContext, ResourceContextProvider, TextField } from 'react-admin';
 import { render, screen, waitFor } from '@testing-library/react';
 import { Resource } from '@api-platform/api-doc-parser';
 
-import ShowGuesser from './ShowGuesser';
-import SchemaAnalyzerContext from './SchemaAnalyzerContext';
-import schemaAnalyzer from './hydra/schemaAnalyzer';
+import ShowGuesser from './ShowGuesser.js';
+import SchemaAnalyzerContext from './SchemaAnalyzerContext.js';
+import schemaAnalyzer from './hydra/schemaAnalyzer.js';
 import type {
   ApiPlatformAdminDataProvider,
   ApiPlatformAdminRecord,
-} from './types';
+} from './types.js';
 
-import { API_FIELDS_DATA } from './__fixtures__/parsedData';
+import { API_FIELDS_DATA } from './__fixtures__/parsedData.js';
 
 const hydraSchemaAnalyzer = schemaAnalyzer();
 const dataProvider: ApiPlatformAdminDataProvider = {
diff --git a/src/hydra/dataProvider.test.ts b/src/hydra/dataProvider.test.ts
index cbecf23..33ccc63 100644
--- a/src/hydra/dataProvider.test.ts
+++ b/src/hydra/dataProvider.test.ts
@@ -3,9 +3,9 @@ import { Response } from 'node-fetch';
 import type { parseHydraDocumentation } from '@api-platform/api-doc-parser';
 import dataProviderFactory, {
   transformJsonLdDocumentToReactAdminDocument,
-} from './dataProvider';
-import { API_DATA } from '../__fixtures__/parsedData';
-import type fetchHydra from './fetchHydra';
+} from './dataProvider.js';
+import { API_DATA } from '../__fixtures__/parsedData.js';
+import type fetchHydra from './fetchHydra.js';
 
 const EMBEDDED_ITEM = {
   '@id': '/books/2',