You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
I was trying to migrate from moment to dayjs. I have monorepo setup along with typescript. For the reusability, i was trying to move dayjs with necessary extends inside a util library inside nx which looks something like this -
import dayjs from 'dayjs/esm';
import duration from 'dayjs/esm/plugin/duration';
import isBetween from 'dayjs/esm/plugin/isBetween';
import isSameOrAfter from 'dayjs/esm/plugin/isSameOrAfter';
import isSameOrBefore from 'dayjs/esm/plugin/isSameOrBefore';
import timezone from 'dayjs/esm/plugin/timezone';
import utc from 'dayjs/esm/plugin/utc';
dayjs.extend(isBetween);
dayjs.extend(utc);
dayjs.extend(timezone);
dayjs.extend(duration);
dayjs.extend(isSameOrAfter);
dayjs.extend(isSameOrBefore);
export const dayjsExt = dayjs;
I don't want to enable allowSyntheticDefaultImports and esModuleInterop so I have added a patch -
diff --git a/node_modules/dayjs/esm/index.d.ts b/node_modules/dayjs/esm/index.d.ts
index cd159dc..46c227a 100644
--- a/node_modules/dayjs/esm/index.d.ts
+++ b/node_modules/dayjs/esm/index.d.ts
@@ -1,6 +1,6 @@
/// <reference path="./locale/index.d.ts" />
-export = dayjs;
+export default dayjs;
declare function dayjs (date?: dayjs.ConfigType): dayjs.Dayjs
diff --git a/node_modules/dayjs/esm/index.js b/node_modules/dayjs/esm/index.js
index a82986b..fce6b4d 100644
--- a/node_modules/dayjs/esm/index.js
+++ b/node_modules/dayjs/esm/index.js
@@ -1,6 +1,6 @@
-import * as C from './constant';
-import en from './locale/en';
-import U from './utils';
+import * as C from './constant.js';
+import en from './locale/en.js';
+import U from './utils.js';
var L = 'en'; // global locale
var Ls = {}; // global loaded locale
diff --git a/node_modules/dayjs/esm/plugin/duration/index.d.ts b/node_modules/dayjs/esm/plugin/duration/index.d.ts
index dc974a5..05ee1cc 100644
--- a/node_modules/dayjs/esm/plugin/duration/index.d.ts
+++ b/node_modules/dayjs/esm/plugin/duration/index.d.ts
@@ -3,7 +3,7 @@ import { OpUnitType, UnitTypeLongPlural } from 'dayjs/esm';
declare const plugin: PluginFunc
export as namespace plugin;
-export = plugin
+export default plugin
declare namespace plugin {
/**
diff --git a/node_modules/dayjs/esm/plugin/duration/index.js b/node_modules/dayjs/esm/plugin/duration/index.js
index a241d4b..ee2cdd1 100644
--- a/node_modules/dayjs/esm/plugin/duration/index.js
+++ b/node_modules/dayjs/esm/plugin/duration/index.js
@@ -1,4 +1,4 @@
-import { MILLISECONDS_A_DAY, MILLISECONDS_A_HOUR, MILLISECONDS_A_MINUTE, MILLISECONDS_A_SECOND, MILLISECONDS_A_WEEK, REGEX_FORMAT } from '../../constant';
+import { MILLISECONDS_A_DAY, MILLISECONDS_A_HOUR, MILLISECONDS_A_MINUTE, MILLISECONDS_A_SECOND, MILLISECONDS_A_WEEK, REGEX_FORMAT } from '../../constant.js';
var MILLISECONDS_A_YEAR = MILLISECONDS_A_DAY * 365;
var MILLISECONDS_A_MONTH = MILLISECONDS_A_YEAR / 12;
var durationRegex = /^(-|\+)?P(?:([-+]?[0-9,.]*)Y)?(?:([-+]?[0-9,.]*)M)?(?:([-+]?[0-9,.]*)W)?(?:([-+]?[0-9,.]*)D)?(?:T(?:([-+]?[0-9,.]*)H)?(?:([-+]?[0-9,.]*)M)?(?:([-+]?[0-9,.]*)S)?)?$/;
diff --git a/node_modules/dayjs/esm/plugin/isBetween/index.d.ts b/node_modules/dayjs/esm/plugin/isBetween/index.d.ts
index 1c62711..e4761fd 100644
--- a/node_modules/dayjs/esm/plugin/isBetween/index.d.ts
+++ b/node_modules/dayjs/esm/plugin/isBetween/index.d.ts
@@ -1,7 +1,7 @@
import { PluginFunc, ConfigType, OpUnitType } from 'dayjs/esm'
declare const plugin: PluginFunc
-export = plugin
+export default plugin
declare module 'dayjs/esm' {
interface Dayjs {
diff --git a/node_modules/dayjs/esm/plugin/isSameOrAfter/index.d.ts b/node_modules/dayjs/esm/plugin/isSameOrAfter/index.d.ts
index 7b6d239..c16bde4 100644
--- a/node_modules/dayjs/esm/plugin/isSameOrAfter/index.d.ts
+++ b/node_modules/dayjs/esm/plugin/isSameOrAfter/index.d.ts
@@ -1,7 +1,7 @@
import { PluginFunc, ConfigType, OpUnitType } from 'dayjs/esm'
declare const plugin: PluginFunc
-export = plugin
+export default plugin
declare module 'dayjs/esm' {
interface Dayjs {
diff --git a/node_modules/dayjs/esm/plugin/isSameOrBefore/index.d.ts b/node_modules/dayjs/esm/plugin/isSameOrBefore/index.d.ts
index 7ec009f..3c35df3 100644
--- a/node_modules/dayjs/esm/plugin/isSameOrBefore/index.d.ts
+++ b/node_modules/dayjs/esm/plugin/isSameOrBefore/index.d.ts
@@ -1,7 +1,7 @@
import { PluginFunc, ConfigType, OpUnitType } from 'dayjs/esm'
declare const plugin: PluginFunc
-export = plugin
+export default plugin
declare module 'dayjs/esm' {
interface Dayjs {
diff --git a/node_modules/dayjs/esm/plugin/timezone/index.d.ts b/node_modules/dayjs/esm/plugin/timezone/index.d.ts
index 5a2d9f2..d618a7a 100644
--- a/node_modules/dayjs/esm/plugin/timezone/index.d.ts
+++ b/node_modules/dayjs/esm/plugin/timezone/index.d.ts
@@ -1,7 +1,7 @@
import { PluginFunc, ConfigType } from 'dayjs/esm'
declare const plugin: PluginFunc
-export = plugin
+export default plugin
declare module 'dayjs/esm' {
interface Dayjs {
diff --git a/node_modules/dayjs/esm/plugin/timezone/index.js b/node_modules/dayjs/esm/plugin/timezone/index.js
index 2f63de2..5f0e435 100644
--- a/node_modules/dayjs/esm/plugin/timezone/index.js
+++ b/node_modules/dayjs/esm/plugin/timezone/index.js
@@ -1,4 +1,4 @@
-import { MIN, MS } from '../../constant';
+import { MIN, MS } from '../../constant.js';
var typeToPos = {
year: 0,
month: 1,
diff --git a/node_modules/dayjs/esm/plugin/utc/index.d.ts b/node_modules/dayjs/esm/plugin/utc/index.d.ts
index 15c61fe..04a2d14 100644
--- a/node_modules/dayjs/esm/plugin/utc/index.d.ts
+++ b/node_modules/dayjs/esm/plugin/utc/index.d.ts
@@ -1,7 +1,7 @@
import { PluginFunc, ConfigType } from 'dayjs/esm'
declare const plugin: PluginFunc
-export = plugin
+export default plugin
declare module 'dayjs/esm' {
interface Dayjs {
diff --git a/node_modules/dayjs/esm/plugin/utc/index.js b/node_modules/dayjs/esm/plugin/utc/index.js
index a8a05f5..552551e 100644
--- a/node_modules/dayjs/esm/plugin/utc/index.js
+++ b/node_modules/dayjs/esm/plugin/utc/index.js
@@ -1,4 +1,4 @@
-import { MILLISECONDS_A_MINUTE, MIN } from '../../constant';
+import { MILLISECONDS_A_MINUTE, MIN } from '../../constant.js';
var REGEX_VALID_OFFSET_FORMAT = /[+-]\d\d(?::?\d\d)?/g;
var REGEX_OFFSET_HOURS_MINUTES_FORMAT = /([+-]|\d\d)/g;
diff --git a/node_modules/dayjs/esm/utils.js b/node_modules/dayjs/esm/utils.js
index b5a8131..7df153a 100644
--- a/node_modules/dayjs/esm/utils.js
+++ b/node_modules/dayjs/esm/utils.js
@@ -1,4 +1,4 @@
-import * as C from './constant';
+import * as C from './constant.js';
var padStart = function padStart(string, length, pad) {
var s = String(string);
diff --git a/node_modules/dayjs/package.json b/node_modules/dayjs/package.json
index d3e7c31..aaa63a0 100644
--- a/node_modules/dayjs/package.json
+++ b/node_modules/dayjs/package.json
@@ -1,8 +1,9 @@
{
"name": "dayjs",
+ "type": "module",
"version": "1.11.13",
"description": "2KB immutable date time library alternative to Moment.js with the same modern API ",
- "main": "dayjs.min.js",
+ "main": "esm/index.js",
"types": "index.d.ts",
"scripts": {
"test": "TZ=Pacific/Auckland npm run test-tz && TZ=Europe/London npm run test-tz && TZ=America/Whitehorse npm run test-tz && npm run test-tz && jest",
diff --git a/node_modules/dayjs/plugin/duration.d.ts b/node_modules/dayjs/plugin/duration.d.ts
index 9675a80..7c03040 100644
--- a/node_modules/dayjs/plugin/duration.d.ts
+++ b/node_modules/dayjs/plugin/duration.d.ts
@@ -3,7 +3,7 @@ import { OpUnitType, UnitTypeLongPlural } from 'dayjs';
declare const plugin: PluginFunc
export as namespace plugin;
-export = plugin
+export default plugin
declare namespace plugin {
/**
diff --git a/node_modules/dayjs/plugin/isBetween.d.ts b/node_modules/dayjs/plugin/isBetween.d.ts
index 431fff8..94388bf 100644
--- a/node_modules/dayjs/plugin/isBetween.d.ts
+++ b/node_modules/dayjs/plugin/isBetween.d.ts
@@ -1,7 +1,7 @@
import { PluginFunc, ConfigType, OpUnitType } from 'dayjs'
declare const plugin: PluginFunc
-export = plugin
+export default plugin
declare module 'dayjs' {
interface Dayjs {
diff --git a/node_modules/dayjs/plugin/isSameOrAfter.d.ts b/node_modules/dayjs/plugin/isSameOrAfter.d.ts
index 916bc80..8edcf3d 100644
--- a/node_modules/dayjs/plugin/isSameOrAfter.d.ts
+++ b/node_modules/dayjs/plugin/isSameOrAfter.d.ts
@@ -1,7 +1,7 @@
import { PluginFunc, ConfigType, OpUnitType } from 'dayjs'
declare const plugin: PluginFunc
-export = plugin
+export default plugin
declare module 'dayjs' {
interface Dayjs {
diff --git a/node_modules/dayjs/plugin/isSameOrBefore.d.ts b/node_modules/dayjs/plugin/isSameOrBefore.d.ts
index d52b095..8b64a12 100644
--- a/node_modules/dayjs/plugin/isSameOrBefore.d.ts
+++ b/node_modules/dayjs/plugin/isSameOrBefore.d.ts
@@ -1,7 +1,7 @@
import { PluginFunc, ConfigType, OpUnitType } from 'dayjs'
declare const plugin: PluginFunc
-export = plugin
+export default plugin
declare module 'dayjs' {
interface Dayjs {
diff --git a/node_modules/dayjs/plugin/timezone.d.ts b/node_modules/dayjs/plugin/timezone.d.ts
index 049bb08..19b21bf 100644
--- a/node_modules/dayjs/plugin/timezone.d.ts
+++ b/node_modules/dayjs/plugin/timezone.d.ts
@@ -1,7 +1,7 @@
import { PluginFunc, ConfigType } from 'dayjs'
declare const plugin: PluginFunc
-export = plugin
+export default plugin
declare module 'dayjs' {
interface Dayjs {
diff --git a/node_modules/dayjs/plugin/utc.d.ts b/node_modules/dayjs/plugin/utc.d.ts
index 544ea4e..be9d1f4 100644
--- a/node_modules/dayjs/plugin/utc.d.ts
+++ b/node_modules/dayjs/plugin/utc.d.ts
@@ -1,7 +1,7 @@
import { PluginFunc, ConfigType } from 'dayjs'
declare const plugin: PluginFunc
-export = plugin
+export default plugin
declare module 'dayjs' {
interface Dayjs {
Expected behavior
On usage files, if I try to use dayjsExt.duration or even in the same file, I am getting Property 'duration' does not exist on type 'typeof dayjs'. which should not be the case.
Information
Day.js Version 1.11.13
OS: macOS
Browser Chrome 128.0.6613.84
Time zone: GMT+05:30 IST (Indian Standard Time)
The text was updated successfully, but these errors were encountered:
Describe the bug
I was trying to migrate from moment to dayjs. I have monorepo setup along with typescript. For the reusability, i was trying to move dayjs with necessary extends inside a util library inside nx which looks something like this -
I don't want to enable
allowSyntheticDefaultImports
andesModuleInterop
so I have added a patch -Expected behavior
On usage files, if I try to use
dayjsExt.duration
or even in the same file, I am gettingProperty 'duration' does not exist on type 'typeof dayjs'.
which should not be the case.Information
The text was updated successfully, but these errors were encountered: