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
Having both the common JS and EcmaScript modules is great. A problem is that when consuming libraries (which are libraries themselves) wish to export both formats with a transpiling workflow, transpiled code will have been forced to selected either commonJS or ES modules. That is:
pre transpile: import { utcToZonedTime } from 'date-fns-tz/esm' // this will be the ESM code & doesn't need transpiling
post transpile to CJS var utcToZonedTime = require('date-fns-tz/esm') // Error here - not CJS
The solution would seem to be replacing the package.json line
by leaving all the other exports, I do not believe this would be a breaking change - it will also require something like "engines":{"node":">=14.0.0"} - I am not sure of the lowest version of Node that began supported conditional exports, but it is around 14. Note Node 13 is no longer supported, so this should not be a huge change.
The text was updated successfully, but these errors were encountered:
Having both the common JS and EcmaScript modules is great. A problem is that when consuming libraries (which are libraries themselves) wish to export both formats with a transpiling workflow, transpiled code will have been forced to selected either commonJS or ES modules. That is:
pre transpile:
import { utcToZonedTime } from 'date-fns-tz/esm'
// this will be the ESM code & doesn't need transpilingpost transpile to CJS
var utcToZonedTime = require('date-fns-tz/esm') // Error here - not CJS
The solution would seem to be replacing the
package.json
linewith
by leaving all the other exports,
I do not believe this would be a breaking change- it will also require something like"engines":{"node":">=14.0.0"}
- I am not sure of the lowest version of Node that began supported conditional exports, but it is around 14. Note Node 13 is no longer supported, so this should not be a huge change.The text was updated successfully, but these errors were encountered: