Skip to content

Commit

Permalink
stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
arshaw committed Mar 5, 2024
1 parent 42dcb53 commit 095bf68
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 17 deletions.
6 changes: 1 addition & 5 deletions packages/temporal-polyfill/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,7 @@
"./global": {
"types": "typeOverrides/global",
"iife": true
}
}
},
"disabledBuildConfig": {
"export": {
},
"./fns/instant": {
"src": "funcApi/instant"
},
Expand Down
19 changes: 17 additions & 2 deletions packages/temporal-polyfill/scripts/bundle.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ async function buildConfigs(pkgDir, isDev) {
const chunkNamesEnabled = isDev
const chunkBase = 'chunks/' + (chunkNamesEnabled ? '[name]' : '[hash]')
const internalSrcBase = resolvePath(pkgDir, 'dist/.tsc', 'internal') + pathSep
const funcApiSrcBase = resolvePath(pkgDir, 'dist/.tsc', 'funcApi') + pathSep

for (const exportPath in exportMap) {
const exportConfig = exportMap[exportPath]
Expand Down Expand Up @@ -136,7 +137,7 @@ async function buildConfigs(pkgDir, isDev) {
// because temporal-spec/global was being imported from index.
{
renderChunk(code) {
return code.replace(/^import ['"][^'"]*['"](;|$)/m, '')
return code.replace(/^import ['"][^'"]*['"](;|$)/gm, '')
},
},
],
Expand All @@ -146,7 +147,21 @@ async function buildConfigs(pkgDir, isDev) {
entryFileNames: '[name]' + extensions.dts,
chunkFileNames: chunkBase + extensions.dts,
minifyInternalExports: false,
manualChunks: manuallyResolveChunk,
manualChunks(id) {
// HACK to ensure fns/* files own their own stuff
if (id.startsWith(funcApiSrcBase)) {
const moduleName = id
.substring(funcApiSrcBase.length)
.replace(/\.d\.ts/, '')
if (!moduleName.includes(pathSep)) {
return 'fns/' + moduleName
}
}

if (id.startsWith(internalSrcBase)) {
return 'internal'
}
},
},
})
}
Expand Down
21 changes: 11 additions & 10 deletions packages/temporal-polyfill/src/internal/optionsRefine.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { Temporal as TemporalSpec } from 'temporal-spec'
import {
requireObjectLike,
requirePropDefined,
Expand Down Expand Up @@ -105,47 +106,47 @@ export interface LargestUnitOptions<UN extends UnitName> {
}

export interface TotalUnitOptions {
unit: UnitName | DurationFieldName
unit: UnitName
}

export type InstantDisplayOptions<TA> = { timeZone?: TA } & TimeDisplayOptions

export type InstantDisplayTuple<TA> = [TA | undefined, ...TimeDisplayTuple]

export interface OverflowOptions {
overflow?: keyof typeof overflowMap
overflow?: TemporalSpec.AssignmentOptions['overflow']
}

export interface EpochDisambigOptions {
disambiguation?: keyof typeof epochDisambigMap
disambiguation?: TemporalSpec.ToInstantOptions['disambiguation']
}

export interface OffsetDisambigOptions {
offset?: keyof typeof offsetDisambigMap
offset?: TemporalSpec.OffsetDisambiguationOptions['offset']
}

export interface CalendarDisplayOptions {
calendarName?: keyof typeof calendarDisplayMap
calendarName?: TemporalSpec.ShowCalendarOption['calendarName']
}

export interface TimeZoneDisplayOptions {
timeZoneName?: keyof typeof timeZoneDisplayMap
timeZoneName?: TemporalSpec.ZonedDateTimeToStringOptions['timeZoneName']
}

export interface OffsetDisplayOptions {
offset?: keyof typeof offsetDisplayMap
offset?: TemporalSpec.ZonedDateTimeToStringOptions['offset']
}

export interface RoundingModeOptions {
roundingMode?: keyof typeof roundingModeMap
roundingMode?: TemporalSpec.DifferenceOptions<any>['roundingMode']
}

export interface RoundingIncOptions {
roundingIncrement?: number
roundingIncrement?: TemporalSpec.DifferenceOptions<any>['roundingIncrement']
}

export interface SubsecDigitsOptions {
fractionalSecondDigits?: SubsecDigits
fractionalSecondDigits?: SubsecDigits // TODO: accept 'auto' ?
}

// Config
Expand Down

0 comments on commit 095bf68

Please sign in to comment.