-
-
Notifications
You must be signed in to change notification settings - Fork 516
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Crashes without luxon #344
Comments
Hi, are you able to create a sample project that reproduces this? Thanks! |
So the issue here appears to be that, currently, luxon is actually a required dependency (not optional). This package's main entry point, In order to make luxon an optional dependency, it either needs to be dynamically imported (via The dynamic import route might look like this: // src/datewithzone.ts
import dateutil from './dateutil'
try {
import('luxon').then(luxon => DateWithZone.luxon = luxon).catch()
} catch (e) {}
export class DateWithZone {
static luxon: { fromJSDate(date: Date): any } | undefined;
// other stuff ...
public rezonedDate () {
if (this.isUTC) {
return this.date
}
else if (!DateWithZone.luxon) {
console.error(
'Using TZID without Luxon available is unsupported. ' +
'Returned times are in UTC, not the requested time zone'
)
return this.date;
}
const datetime = DateWithZone.luxon
.fromJSDate(this.date)
const rezoned = datetime.setZone(this.tzid!, { keepLocalTime: true })
return rezoned.toJSDate()
}
} There are a few problems with this though.
I think moving this code into a separate and optional package entry point is the right solution. This might look like: // src/datewithzone.ts
import dateutil from './dateutil'
export class DateWithZone {
static luxon: { fromJSDate(date: Date): any } | undefined;
// other stuff ...
public rezonedDate () {
if (this.isUTC) {
return this.date
}
else if (!DateWithZone.luxon) {
console.error(
'Using TZID without Luxon available is unsupported. ' +
'Returned times are in UTC, not the requested time zone'
)
return this.date;
}
const datetime = DateWithZone.luxon
.fromJSDate(this.date)
const rezoned = datetime.setZone(this.tzid!, { keepLocalTime: true })
return rezoned.toJSDate()
}
} and // src/luxon/index.ts
import { DateWithZone } from '../datewithzone';
import { DateTime } from 'luxon';
DateWithZone.luxon = DateTime; Usage would be like import { RRule } from 'rrule';
import 'rrule/luxon';
// ... do stuff A separate, This would also be a breaking change, as all apps making use of rrule's timezone support (which appears to be 99% of folks) would need to // ./rrule.ts
import 'rrule/luxon';
export * from 'rrule'; And then import from this local file, rather than Edit: |
Hi, |
All the progress is contained on this page. |
After few months i try to remove from project luxon but still see this issue
project is with angular 11 and we already using moment.js
|
Similar issue happened for me. In my case downgrade from |
Luxon is an optional dependency and I'd rather not include it since my project already has moment and I don't need timezone support in my rrule usage.
So I installed it:
So far so good. But then as soon as I bundle with webpack and run, it crashes in
./node_modules/rrule/dist/esm/src/datewithzone.js
with "Module not found: Error: Can't resolve 'luxon'
". Is this a limitation of webpack? How can I use rrule without luxon?The text was updated successfully, but these errors were encountered: