Skip to content

Commit

Permalink
fix: change module resolution to nodenext so that extensions are requ…
Browse files Browse the repository at this point in the history
…ired on import

This is required for ESM only packages.
  • Loading branch information
ericvera committed May 16, 2024
1 parent dc20970 commit df06dc5
Show file tree
Hide file tree
Showing 20 changed files with 70 additions and 70 deletions.
2 changes: 1 addition & 1 deletion src/__test__/setFakeTimer.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { fromZonedTime } from 'date-fns-tz'
import { vi } from 'vitest'
import { TestLocalTimeZone } from './constants'
import { TestLocalTimeZone } from './constants.js'

export const setFakeTimer = (
isoDateTime: string,
Expand Down
18 changes: 9 additions & 9 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
export * from './constants'
export * from './sDate'
export * from './sTime'
export * from './sTimestamp'
export * from './sWeekdays'
export * from './constants.js'
export * from './sDate.js'
export * from './sTime.js'
export * from './sTimestamp.js'
export * from './sWeekdays.js'

export type * from './internal/SDate'
export type * from './internal/STime'
export type * from './internal/STimestamp'
export type * from './internal/SWeekdays'
export type * from './internal/SDate.js'
export type * from './internal/STime.js'
export type * from './internal/STimestamp.js'
export type * from './internal/SWeekdays.js'
2 changes: 1 addition & 1 deletion src/internal/SDate.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { validateISODate } from './date'
import { validateISODate } from './date.js'

/**
* SDate represents a date in the ISO-8601 format (YYYY-MM-DD)
Expand Down
2 changes: 1 addition & 1 deletion src/internal/STime.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { validateISOTime } from './time'
import { validateISOTime } from './time.js'

/**
* STime represents a time in the ISO-8601 format (HH:MM)
Expand Down
2 changes: 1 addition & 1 deletion src/internal/STimestamp.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { validateISOTimestamp } from './timestamp'
import { validateISOTimestamp } from './timestamp.js'

/**
* STimestamp represents a timestamp in the ISO-8601 format (YYYY-MM-DDTHH:MM)
Expand Down
2 changes: 1 addition & 1 deletion src/internal/SWeekdays.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { validateWeekdays } from './weekdays'
import { validateWeekdays } from './weekdays.js'

/**
* SWeekdays represents a string of weekdays in the format 'SMTWTFS' where each
Expand Down
2 changes: 1 addition & 1 deletion src/internal/constants.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Weekday } from '../constants'
import { Weekday } from '../constants.js'

export const DayToWeekday: Weekday[] = [
Weekday.Sun,
Expand Down
2 changes: 1 addition & 1 deletion src/internal/date.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { UTCDateMini } from '@date-fns/utc'
import { SDate } from './SDate'
import { SDate } from './SDate.js'

export const getISOYearFromISODate = (isoDate: string): string => {
const EndOfYearIndex = 4
Expand Down
6 changes: 3 additions & 3 deletions src/internal/timestamp.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { UTCDateMini } from '@date-fns/utc'
import { STimestamp } from './STimestamp'
import { getISODateFromZonedDate, validateISODate } from './date'
import { getISOTimeFromDate, validateISOTime } from './time'
import { STimestamp } from './STimestamp.js'
import { getISODateFromZonedDate, validateISODate } from './date.js'
import { getISOTimeFromDate, validateISOTime } from './time.js'

export const getISODateFromISOTimestamp = (isoTimestamp: string): string => {
const EndOfDateIndex = 10
Expand Down
4 changes: 2 additions & 2 deletions src/internal/weekdays.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Weekday } from '../constants'
import { DayToWeekday } from './constants'
import { Weekday } from '../constants.js'
import { DayToWeekday } from './constants.js'

export const validateWeekdays = (weekdays: string): void => {
const ValidWeekdays = /^[S-][M-][T-][W-][T-][F-][S-]$/
Expand Down
8 changes: 4 additions & 4 deletions src/internal/zoned.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { UTCDateMini } from '@date-fns/utc'
import { getTimezoneOffset, toZonedTime } from 'date-fns-tz'
import { SDate } from './SDate'
import { STimestamp } from './STimestamp'
import { getDateAsUTCDateMini } from './date'
import { getTimestampAsUTCDateMini } from './timestamp'
import { SDate } from './SDate.js'
import { STimestamp } from './STimestamp.js'
import { getDateAsUTCDateMini } from './date.js'
import { getTimestampAsUTCDateMini } from './timestamp.js'

const getValidatedTimeZoneOffset = (timeZone: string, utcDate: UTCDateMini) => {
const timeZoneOffset = getTimezoneOffset(timeZone, utcDate)
Expand Down
8 changes: 4 additions & 4 deletions src/sDate.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ import { beforeEach, describe, expect, it, vi } from 'vitest'
import {
TestLocalTimeZone,
TestLocalTimeZoneWithDaylight,
} from './__test__/constants'
import { setFakeTimer } from './__test__/setFakeTimer'
import { Weekday } from './constants'
} from './__test__/constants.js'
import { setFakeTimer } from './__test__/setFakeTimer.js'
import { Weekday } from './constants.js'
import {
addDaysToDate,
addMonthsToDate,
Expand Down Expand Up @@ -33,7 +33,7 @@ import {
isSameDateOrAfter,
isSameDateOrBefore,
sDate,
} from './sDate'
} from './sDate.js'

beforeEach(() => {
vi.useRealTimers()
Expand Down
14 changes: 7 additions & 7 deletions src/sDate.ts
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
import { Weekday } from './constants'
import { SDate } from './internal/SDate'
import { Weekday } from './constants.js'
import { SDate } from './internal/SDate.js'
import {
DayToWeekday,
DaysInWeek,
MillisecondsInDay,
} from './internal/constants'
} from './internal/constants.js'
import {
getDateAsUTCDateMini,
getISODateFromISODate,
getISODateFromZonedDate,
getISOMonthFromISODate,
getISOYearFromISODate,
} from './internal/date'
import { getAtIndex } from './internal/utils'
import { getIndexForWeekday } from './internal/weekdays'
} from './internal/date.js'
import { getAtIndex } from './internal/utils.js'
import { getIndexForWeekday } from './internal/weekdays.js'
import {
getMillisecondsInUTCFromDate,
getTimeZonedDate,
} from './internal/zoned'
} from './internal/zoned.js'

export interface SDateShortStringOptions {
includeWeekday: boolean
Expand Down
8 changes: 4 additions & 4 deletions src/sTime.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { beforeEach, describe, expect, it, vi } from 'vitest'
import { TestLocalTimeZone } from './__test__/constants'
import { setFakeTimer } from './__test__/setFakeTimer'
import { MinutesInDay, MinutesInHour } from './internal/constants'
import { TestLocalTimeZone } from './__test__/constants.js'
import { setFakeTimer } from './__test__/setFakeTimer.js'
import { MinutesInDay, MinutesInHour } from './internal/constants.js'
import {
addMinutesToTime,
get12HourTimeString,
Expand All @@ -20,7 +20,7 @@ import {
isSameTimeOrBefore,
isTimePM,
sTime,
} from './sTime'
} from './sTime.js'

beforeEach(() => {
vi.useRealTimers()
Expand Down
8 changes: 4 additions & 4 deletions src/sTime.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { STime } from './internal/STime'
import { MinutesInDay, MinutesInHour } from './internal/constants'
import { STime } from './internal/STime.js'
import { MinutesInDay, MinutesInHour } from './internal/constants.js'
import {
getISOHoursFromISOTime,
getISOMinutesFromISOTime,
getISOTimeFromDate,
} from './internal/time'
import { getTimeZonedDate } from './internal/zoned'
} from './internal/time.js'
import { getTimeZonedDate } from './internal/zoned.js'

/**
* --- Factory ---
Expand Down
12 changes: 6 additions & 6 deletions src/sTimestamp.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ import { beforeEach, describe, expect, it, vi } from 'vitest'
import {
TestLocalTimeZone,
TestLocalTimeZoneWithDaylight,
} from './__test__/constants'
import { setFakeTimer } from './__test__/setFakeTimer'
import { SecondsInHour, SecondsInMinute } from './internal/constants'
import { sDate } from './sDate'
import { sTime } from './sTime'
} from './__test__/constants.js'
import { setFakeTimer } from './__test__/setFakeTimer.js'
import { SecondsInHour, SecondsInMinute } from './internal/constants.js'
import { sDate } from './sDate.js'
import { sTime } from './sTime.js'
import {
addDaysToTimestamp,
addMinutesToTimestamp,
Expand All @@ -24,7 +24,7 @@ import {
isSameTimestampOrAfter,
isSameTimestampOrBefore,
sTimestamp,
} from './sTimestamp'
} from './sTimestamp.js'

beforeEach(() => {
vi.useRealTimers()
Expand Down
16 changes: 8 additions & 8 deletions src/sTimestamp.ts
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
import { SDate } from './internal/SDate'
import { STime } from './internal/STime'
import { STimestamp } from './internal/STimestamp'
import { SDate } from './internal/SDate.js'
import { STime } from './internal/STime.js'
import { STimestamp } from './internal/STimestamp.js'
import {
MillisecondsInMinute,
MillisecondsInSecond,
} from './internal/constants'
} from './internal/constants.js'
import {
getISODateFromISOTimestamp,
getISOTimeFromISOTimestamp,
getISOTimestampFromZonedDate,
getTimestampAsUTCDateMini,
} from './internal/timestamp'
} from './internal/timestamp.js'
import {
getMillisecondsInUTCFromTimestamp,
getTimeZonedDate,
} from './internal/zoned'
import { getShortDateString, sDate } from './sDate'
import { get12HourTimeString, sTime } from './sTime'
} from './internal/zoned.js'
import { getShortDateString, sDate } from './sDate.js'
import { get12HourTimeString, sTime } from './sTime.js'

export interface STimestampShortStringOptions {
includeWeekday: boolean
Expand Down
6 changes: 3 additions & 3 deletions src/sWeekdays.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { beforeEach, describe, expect, it, vi } from 'vitest'
import { Weekday } from './constants'
import { sDate } from './sDate'
import { Weekday } from './constants.js'
import { sDate } from './sDate.js'
import {
addWeekdayToWeekdays,
doesWeekdaysHaveOverlapWithWeekdays,
Expand All @@ -11,7 +11,7 @@ import {
getWeekdaysWithNoneIncluded,
sWeekdays,
shiftWeekdaysForward,
} from './sWeekdays'
} from './sWeekdays.js'

beforeEach(() => {
vi.useRealTimers()
Expand Down
14 changes: 7 additions & 7 deletions src/sWeekdays.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,20 @@
* --- Factory ---
*/

import { Weekday } from './constants'
import { SDate } from './internal/SDate'
import { SWeekdays } from './internal/SWeekdays'
import { DayToWeekday, DaysInWeek } from './internal/constants'
import { getAtIndex, hasFlag } from './internal/utils'
import { getIndexForWeekday } from './internal/weekdays'
import { Weekday } from './constants.js'
import { SDate } from './internal/SDate.js'
import { SWeekdays } from './internal/SWeekdays.js'
import { DayToWeekday, DaysInWeek } from './internal/constants.js'
import { getAtIndex, hasFlag } from './internal/utils.js'
import { getIndexForWeekday } from './internal/weekdays.js'
import {
addDaysToDate,
getDaysBetweenDates,
getWeekdayFromDate,
isAfterDate,
isSameDateOrBefore,
sDate,
} from './sDate'
} from './sDate.js'

const AllWeekdaysIncludedMask = 'SMTWTFS'
const NotIncludedDay = '-'
Expand Down
4 changes: 2 additions & 2 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@
"target": "ESNext" /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */,

/* Modules */
"module": "ESNext" /* Specify what module code is generated. */,
"module": "NodeNext" /* Specify what module code is generated. */,
"rootDir": "src" /* Specify the root folder within your source files. */,
"moduleResolution": "Bundler" /* Specify how TypeScript looks up a file from a given module specifier. */,
"moduleResolution": "NodeNext" /* Specify how TypeScript looks up a file from a given module specifier. */,

/* Emit */
"outDir": "dist" /* Specify an output folder for all emitted files. */,
Expand Down

0 comments on commit df06dc5

Please sign in to comment.