From 6534bdfbcd097c0c82ab92553c0dce591f4704ee Mon Sep 17 00:00:00 2001 From: Wojciech Maj Date: Mon, 31 Jul 2023 10:03:22 +0200 Subject: [PATCH] Default to ESM imports, use CJS imports in CJS builds --- package.json | 4 +- src/DateTimeRangePicker.tsx | 2 +- yarn.lock | 196 +++++++++++++++++++++++++++++++++++- 3 files changed, 195 insertions(+), 7 deletions(-) diff --git a/package.json b/package.json index beda7f7..01d4d55 100644 --- a/package.json +++ b/package.json @@ -19,10 +19,11 @@ }, "scripts": { "build": "yarn build-js && yarn copy-styles", - "build-js": "yarn build-js-esm && yarn build-js-cjs && yarn build-js-cjs-package", + "build-js": "yarn build-js-esm && yarn build-js-cjs && yarn build-js-cjs-package && yarn build-js-cjs-replace", "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", + "build-js-cjs-replace": "replace-in-files --string='/dist/esm/' --replacement='/dist/cjs/' dist/cjs/**/*", "clean": "rimraf dist", "copy-styles": "cpy 'src/**/*.css' dist", "lint": "eslint . --ext .js,.jsx,.ts,.tsx", @@ -79,6 +80,7 @@ "pretty-quick": "^3.1.0", "react": "^18.2.0", "react-dom": "^18.2.0", + "replace-in-files-cli": "^2.2.0", "rimraf": "^3.0.0", "typescript": "^5.0.0", "vitest": "^0.30.1", diff --git a/src/DateTimeRangePicker.tsx b/src/DateTimeRangePicker.tsx index 29c5e5f..0ec4bcf 100644 --- a/src/DateTimeRangePicker.tsx +++ b/src/DateTimeRangePicker.tsx @@ -9,7 +9,7 @@ import Calendar from 'react-calendar'; import Clock from 'react-clock'; import Fit from 'react-fit'; -import DateTimeInput from 'react-datetime-picker/dist/cjs/DateTimeInput'; +import DateTimeInput from 'react-datetime-picker/dist/esm/DateTimeInput'; import { isMaxDate, isMinDate, rangeOf } from './shared/propTypes.js'; diff --git a/yarn.lock b/yarn.lock index ff7952f..c29c342 100644 --- a/yarn.lock +++ b/yarn.lock @@ -562,7 +562,7 @@ __metadata: languageName: node linkType: hard -"@types/normalize-package-data@npm:^2.4.1": +"@types/normalize-package-data@npm:^2.4.0, @types/normalize-package-data@npm:^2.4.1": version: 2.4.1 resolution: "@types/normalize-package-data@npm:2.4.1" checksum: e87bccbf11f95035c89a132b52b79ce69a1e3652fe55962363063c9c0dae0fe2477ebc585e03a9652adc6f381d24ba5589cc5e51849df4ced3d3e004a7d40ed5 @@ -855,6 +855,7 @@ __metadata: react-datetime-picker: ^5.5.1 react-dom: ^18.2.0 react-fit: ^1.7.0 + replace-in-files-cli: ^2.2.0 rimraf: ^3.0.0 typescript: ^5.0.0 vitest: ^0.30.1 @@ -1082,6 +1083,13 @@ __metadata: languageName: node linkType: hard +"array-union@npm:^3.0.1": + version: 3.0.1 + resolution: "array-union@npm:3.0.1" + checksum: 47b29f88258e8f37ffb93ddaa327d4308edd950b52943c172b73558afdd3fa74cfd68816ba5aa4b894242cf281fa3c6d0362ae057e4a18bddbaedbe46ebe7112 + languageName: node + linkType: hard + "array.prototype.flat@npm:^1.3.1": version: 1.3.1 resolution: "array.prototype.flat@npm:1.3.1" @@ -1308,6 +1316,18 @@ __metadata: languageName: node linkType: hard +"camelcase-keys@npm:^7.0.0": + version: 7.0.2 + resolution: "camelcase-keys@npm:7.0.2" + dependencies: + camelcase: ^6.3.0 + map-obj: ^4.1.0 + quick-lru: ^5.1.1 + type-fest: ^1.2.1 + checksum: b5821cc48dd00e8398a30c5d6547f06837ab44de123f1b3a603d0a03399722b2fc67a485a7e47106eb02ef543c3b50c5ebaabc1242cde4b63a267c3258d2365b + languageName: node + linkType: hard + "camelcase-keys@npm:^8.0.2": version: 8.0.2 resolution: "camelcase-keys@npm:8.0.2" @@ -1320,6 +1340,13 @@ __metadata: languageName: node linkType: hard +"camelcase@npm:^6.3.0": + version: 6.3.0 + resolution: "camelcase@npm:6.3.0" + checksum: 8c96818a9076434998511251dcb2761a94817ea17dbdc37f47ac080bd088fc62c7369429a19e2178b993497132c8cbcf5cc1f44ba963e76782ba469c0474938d + languageName: node + linkType: hard + "camelcase@npm:^7.0.0": version: 7.0.1 resolution: "camelcase@npm:7.0.1" @@ -1644,6 +1671,16 @@ __metadata: languageName: node linkType: hard +"decamelize-keys@npm:^1.1.0": + version: 1.1.1 + resolution: "decamelize-keys@npm:1.1.1" + dependencies: + decamelize: ^1.1.0 + map-obj: ^1.0.0 + checksum: fc645fe20b7bda2680bbf9481a3477257a7f9304b1691036092b97ab04c0ab53e3bf9fcc2d2ae382536568e402ec41fb11e1d4c3836a9abe2d813dd9ef4311e0 + languageName: node + linkType: hard + "decamelize-keys@npm:^2.0.1": version: 2.0.1 resolution: "decamelize-keys@npm:2.0.1" @@ -1656,6 +1693,20 @@ __metadata: languageName: node linkType: hard +"decamelize@npm:^1.1.0": + version: 1.2.0 + resolution: "decamelize@npm:1.2.0" + checksum: ad8c51a7e7e0720c70ec2eeb1163b66da03e7616d7b98c9ef43cce2416395e84c1e9548dd94f5f6ffecfee9f8b94251fc57121a8b021f2ff2469b2bae247b8aa + languageName: node + linkType: hard + +"decamelize@npm:^5.0.0": + version: 5.0.1 + resolution: "decamelize@npm:5.0.1" + checksum: 7c3b1ed4b3e60e7fbc00a35fb248298527c1cdfe603e41dfcf05e6c4a8cb9efbee60630deb677ed428908fb4e74e322966c687a094d1478ddc9c3a74e9dc7140 + languageName: node + linkType: hard + "decamelize@npm:^6.0.0": version: 6.0.0 resolution: "decamelize@npm:6.0.0" @@ -2067,7 +2118,7 @@ __metadata: languageName: node linkType: hard -"escape-string-regexp@npm:5.0.0": +"escape-string-regexp@npm:5.0.0, escape-string-regexp@npm:^5.0.0": version: 5.0.0 resolution: "escape-string-regexp@npm:5.0.0" checksum: 20daabe197f3cb198ec28546deebcf24b3dbb1a5a269184381b3116d12f0532e06007f4bc8da25669d6a7f8efb68db0758df4cd981f57bc5b57f521a3e12c59e @@ -2472,7 +2523,7 @@ __metadata: languageName: node linkType: hard -"fast-glob@npm:^3.2.12, fast-glob@npm:^3.2.9, fast-glob@npm:^3.3.0": +"fast-glob@npm:^3.2.12, fast-glob@npm:^3.2.7, fast-glob@npm:^3.2.9, fast-glob@npm:^3.3.0": version: 3.3.1 resolution: "fast-glob@npm:3.3.1" dependencies: @@ -2810,6 +2861,20 @@ __metadata: languageName: node linkType: hard +"globby@npm:^12.0.2": + version: 12.2.0 + resolution: "globby@npm:12.2.0" + dependencies: + array-union: ^3.0.1 + dir-glob: ^3.0.1 + fast-glob: ^3.2.7 + ignore: ^5.1.9 + merge2: ^1.4.1 + slash: ^4.0.0 + checksum: 2539379a7fff3473d3e7c68b4540ba38f36970f43f760e36e301515d5cb98a0c5736554957d90390906bee632327beb2f9518d1acd6911f61e436db11b0da5b5 + languageName: node + linkType: hard + "globby@npm:^13.1.3, globby@npm:^13.1.4": version: 13.2.2 resolution: "globby@npm:13.2.2" @@ -3039,7 +3104,7 @@ __metadata: languageName: node linkType: hard -"ignore@npm:^5.1.4, ignore@npm:^5.2.0, ignore@npm:^5.2.4": +"ignore@npm:^5.1.4, ignore@npm:^5.1.9, ignore@npm:^5.2.0, ignore@npm:^5.2.4": version: 5.2.4 resolution: "ignore@npm:5.2.4" checksum: 3d4c309c6006e2621659311783eaea7ebcd41fe4ca1d78c91c473157ad6666a57a2df790fe0d07a12300d9aac2888204d7be8d59f9aaf665b1c7fcdb432517ef @@ -3381,6 +3446,13 @@ __metadata: languageName: node linkType: hard +"is-typedarray@npm:^1.0.0": + version: 1.0.0 + resolution: "is-typedarray@npm:1.0.0" + checksum: 3508c6cd0a9ee2e0df2fa2e9baabcdc89e911c7bd5cf64604586697212feec525aa21050e48affb5ffc3df20f0f5d2e2cf79b08caa64e1ccc9578e251763aef7 + languageName: node + linkType: hard + "is-weakmap@npm:^2.0.1": version: 2.0.1 resolution: "is-weakmap@npm:2.0.1" @@ -3809,7 +3881,14 @@ __metadata: languageName: node linkType: hard -"map-obj@npm:^4.3.0": +"map-obj@npm:^1.0.0": + version: 1.0.1 + resolution: "map-obj@npm:1.0.1" + checksum: 9949e7baec2a336e63b8d4dc71018c117c3ce6e39d2451ccbfd3b8350c547c4f6af331a4cbe1c83193d7c6b786082b6256bde843db90cb7da2a21e8fcc28afed + languageName: node + linkType: hard + +"map-obj@npm:^4.1.0, map-obj@npm:^4.3.0": version: 4.3.0 resolution: "map-obj@npm:4.3.0" checksum: fbc554934d1a27a1910e842bc87b177b1a556609dd803747c85ece420692380827c6ae94a95cce4407c054fa0964be3bf8226f7f2cb2e9eeee432c7c1985684e @@ -3825,6 +3904,26 @@ __metadata: languageName: node linkType: hard +"meow@npm:^10.1.1": + version: 10.1.5 + resolution: "meow@npm:10.1.5" + dependencies: + "@types/minimist": ^1.2.2 + camelcase-keys: ^7.0.0 + decamelize: ^5.0.0 + decamelize-keys: ^1.1.0 + hard-rejection: ^2.1.0 + minimist-options: 4.1.0 + normalize-package-data: ^3.0.2 + read-pkg-up: ^8.0.0 + redent: ^4.0.0 + trim-newlines: ^4.0.2 + type-fest: ^1.2.2 + yargs-parser: ^20.2.9 + checksum: dd5f0caa4af18517813547dc66741dcbf52c4c23def5062578d39b11189fd9457aee5c1f2263a5cd6592a465023df8357e8ac876b685b64dbcf545e3f66c23a7 + languageName: node + linkType: hard + "meow@npm:^12.0.1": version: 12.0.1 resolution: "meow@npm:12.0.1" @@ -4758,6 +4857,13 @@ __metadata: languageName: node linkType: hard +"quick-lru@npm:^5.1.1": + version: 5.1.1 + resolution: "quick-lru@npm:5.1.1" + checksum: a516faa25574be7947969883e6068dbe4aa19e8ef8e8e0fd96cddd6d36485e9106d85c0041a27153286b0770b381328f4072aa40d3b18a19f5f7d2b78b94b5ed + languageName: node + linkType: hard + "quick-lru@npm:^6.1.1": version: 6.1.1 resolution: "quick-lru@npm:6.1.1" @@ -4938,6 +5044,17 @@ __metadata: languageName: node linkType: hard +"read-pkg-up@npm:^8.0.0": + version: 8.0.0 + resolution: "read-pkg-up@npm:8.0.0" + dependencies: + find-up: ^5.0.0 + read-pkg: ^6.0.0 + type-fest: ^1.0.1 + checksum: fe4c80401656b40b408884457fffb5a8015c03b1018cfd8e48f8d82a5e9023e24963603aeb2755608d964593e046c15b34d29b07d35af9c7aa478be81805209c + languageName: node + linkType: hard + "read-pkg-up@npm:^9.1.0": version: 9.1.0 resolution: "read-pkg-up@npm:9.1.0" @@ -4949,6 +5066,18 @@ __metadata: languageName: node linkType: hard +"read-pkg@npm:^6.0.0": + version: 6.0.0 + resolution: "read-pkg@npm:6.0.0" + dependencies: + "@types/normalize-package-data": ^2.4.0 + normalize-package-data: ^3.0.2 + parse-json: ^5.2.0 + type-fest: ^1.0.1 + checksum: 0cebdff381128e923815c643074a87011070e5fc352bee575d327d6485da3317fab6d802a7b03deeb0be7be8d3ad1640397b3d5d2f044452caf4e8d1736bf94f + languageName: node + linkType: hard + "read-pkg@npm:^7.1.0": version: 7.1.0 resolution: "read-pkg@npm:7.1.0" @@ -5019,6 +5148,21 @@ __metadata: languageName: node linkType: hard +"replace-in-files-cli@npm:^2.2.0": + version: 2.2.0 + resolution: "replace-in-files-cli@npm:2.2.0" + dependencies: + escape-string-regexp: ^5.0.0 + globby: ^12.0.2 + meow: ^10.1.1 + normalize-path: ^3.0.0 + write-file-atomic: ^3.0.3 + bin: + replace-in-files: cli.js + checksum: 6c4b020c428257d8522bc1fbb91555600d158dd912c9471b4c36bec310ce894f3e819a28263efcca379c3b78e1a6d2101d4f78f27947ddbd5043092617d5393b + languageName: node + linkType: hard + "requires-port@npm:^1.0.0": version: 1.0.0 resolution: "requires-port@npm:1.0.0" @@ -5693,6 +5837,13 @@ __metadata: languageName: node linkType: hard +"trim-newlines@npm:^4.0.2": + version: 4.1.1 + resolution: "trim-newlines@npm:4.1.1" + checksum: 5b09f8e329e8f33c1111ef26906332ba7ba7248cde3e26fc054bb3d69f2858bf5feedca9559c572ff91f33e52977c28e0d41c387df6a02a633cbb8c2d8238627 + languageName: node + linkType: hard + "trim-newlines@npm:^5.0.0": version: 5.0.0 resolution: "trim-newlines@npm:5.0.0" @@ -5751,6 +5902,13 @@ __metadata: languageName: node linkType: hard +"type-fest@npm:^1.0.1, type-fest@npm:^1.2.1, type-fest@npm:^1.2.2": + version: 1.4.0 + resolution: "type-fest@npm:1.4.0" + checksum: b011c3388665b097ae6a109a437a04d6f61d81b7357f74cbcb02246f2f5bd72b888ae33631b99871388122ba0a87f4ff1c94078e7119ff22c70e52c0ff828201 + languageName: node + linkType: hard + "type-fest@npm:^2.0.0, type-fest@npm:^2.13.0, type-fest@npm:^2.5.0": version: 2.19.0 resolution: "type-fest@npm:2.19.0" @@ -5776,6 +5934,15 @@ __metadata: languageName: node linkType: hard +"typedarray-to-buffer@npm:^3.1.5": + version: 3.1.5 + resolution: "typedarray-to-buffer@npm:3.1.5" + dependencies: + is-typedarray: ^1.0.0 + checksum: 99c11aaa8f45189fcfba6b8a4825fd684a321caa9bd7a76a27cf0c7732c174d198b99f449c52c3818107430b5f41c0ccbbfb75cb2ee3ca4a9451710986d61a60 + languageName: node + linkType: hard + "typescript@npm:^5.0.0": version: 5.0.4 resolution: "typescript@npm:5.0.4" @@ -6150,6 +6317,18 @@ __metadata: languageName: node linkType: hard +"write-file-atomic@npm:^3.0.3": + version: 3.0.3 + resolution: "write-file-atomic@npm:3.0.3" + dependencies: + imurmurhash: ^0.1.4 + is-typedarray: ^1.0.0 + signal-exit: ^3.0.2 + typedarray-to-buffer: ^3.1.5 + checksum: c55b24617cc61c3a4379f425fc62a386cc51916a9b9d993f39734d005a09d5a4bb748bc251f1304e7abd71d0a26d339996c275955f527a131b1dcded67878280 + languageName: node + linkType: hard + "ws@npm:^8.13.0": version: 8.13.0 resolution: "ws@npm:8.13.0" @@ -6186,6 +6365,13 @@ __metadata: languageName: node linkType: hard +"yargs-parser@npm:^20.2.9": + version: 20.2.9 + resolution: "yargs-parser@npm:20.2.9" + checksum: 8bb69015f2b0ff9e17b2c8e6bfe224ab463dd00ca211eece72a4cd8a906224d2703fb8a326d36fdd0e68701e201b2a60ed7cf81ce0fd9b3799f9fe7745977ae3 + languageName: node + linkType: hard + "yargs-parser@npm:^21.1.1": version: 21.1.1 resolution: "yargs-parser@npm:21.1.1"