Skip to content

Commit

Permalink
Add native ESM support
Browse files Browse the repository at this point in the history
  • Loading branch information
wojtekmaj committed Jul 27, 2023
1 parent 763b57c commit 8da6822
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 12 deletions.
21 changes: 15 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,27 @@
"name": "@wojtekmaj/react-datetimerange-picker",
"version": "5.3.0",
"description": "A datetime range picker for your React app.",
"main": "dist/cjs/index.js",
"module": "dist/esm/index.js",
"source": "src/index.ts",
"types": "dist/cjs/index.d.ts",
"type": "module",
"sideEffects": [
"*.css"
],
"main": "./dist/cjs/index.js",
"module": "./dist/esm/index.js",
"source": "./src/index.ts",
"types": "./dist/cjs/index.d.ts",
"exports": {
".": {
"import": "./dist/esm/index.js",
"require": "./dist/cjs/index.js"
},
"./dist/DateTimeRangePicker.css": "./dist/DateTimeRangePicker.css"
},
"scripts": {
"build": "yarn build-js && yarn copy-styles",
"build-js": "yarn build-js-esm && yarn build-js-cjs",
"build-js": "yarn build-js-esm && yarn build-js-cjs && yarn build-js-cjs-package",
"build-js-esm": "tsc --project tsconfig.build.json --outDir dist/esm --module esnext",
"build-js-cjs": "tsc --project tsconfig.build.json --outDir dist/cjs --module commonjs",
"build-js-cjs-package": "echo '{\n \"type\": \"commonjs\"\n}' > dist/cjs/package.json",
"clean": "rimraf dist",
"copy-styles": "cpy 'src/**/*.css' dist",
"lint": "eslint . --ext .js,.jsx,.ts,.tsx",
Expand All @@ -23,7 +32,7 @@
"test": "yarn lint && yarn tsc && yarn prettier && yarn unit",
"tsc": "tsc --noEmit",
"unit": "vitest",
"watch": "yarn build-js-esm --watch & yarn build-js-cjs --watch & nodemon --watch src --ext css --exec \"yarn copy-styles\""
"watch": "yarn build-js-esm --watch & yarn build-js-cjs --watch & yarn build-js-cjs-package & nodemon --watch src --ext css --exec \"yarn copy-styles\""
},
"keywords": [
"calendar",
Expand Down
2 changes: 1 addition & 1 deletion src/DateTimeRangePicker.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import React from 'react';
import { act, fireEvent, render, waitFor, waitForElementToBeRemoved } from '@testing-library/react';
import userEvent from '@testing-library/user-event';

import DateTimeRangePicker from './DateTimeRangePicker';
import DateTimeRangePicker from './DateTimeRangePicker.js';

async function waitForElementToBeRemovedOrHidden(callback: () => HTMLElement | null) {
const element = callback();
Expand Down
11 changes: 9 additions & 2 deletions src/DateTimeRangePicker.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,17 @@ import Fit from 'react-fit';

import DateTimeInput from 'react-datetime-picker/dist/cjs/DateTimeInput';

import { isMaxDate, isMinDate, rangeOf } from './shared/propTypes';
import { isMaxDate, isMinDate, rangeOf } from './shared/propTypes.js';

import type { ReactNodeArray } from 'prop-types';
import type { ClassName, CloseReason, Detail, LooseValue, OpenReason, Value } from './shared/types';
import type {
ClassName,
CloseReason,
Detail,
LooseValue,
OpenReason,
Value,
} from './shared/types.js';

const baseClassName = 'react-datetimerange-picker';
const outsideActionEvents = ['mousedown', 'focusin', 'touchstart'] as const;
Expand Down
4 changes: 2 additions & 2 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import DateTimeRangePicker from './DateTimeRangePicker';
import DateTimeRangePicker from './DateTimeRangePicker.js';

export type { DateTimeRangePickerProps } from './DateTimeRangePicker';
export type { DateTimeRangePickerProps } from './DateTimeRangePicker.js';

export { DateTimeRangePicker };

Expand Down
2 changes: 1 addition & 1 deletion src/shared/propTypes.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import PropTypes from 'prop-types';

import type { Requireable, Validator } from 'prop-types';
import type { Range } from './types';
import type { Range } from './types.js';

export const isMinDate: Validator<Date | null | undefined> = function isMinDate(
props,
Expand Down

0 comments on commit 8da6822

Please sign in to comment.