-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
ES6 Module Support? #313
Comments
try this |
When i import like that i receive an error
Is there something i have not configured properly with typescript perhaps? |
Have you ever tried the |
Script tag workaround helps in browser, but I can't test (jest) my ES6 modules which use dayjs. |
🎉 This is included in version 1.8.1 🎉 The release is available on: Your semantic-release bot 📦🚀 |
One issue with --allowSyntheticDefaultImports is that, as library developers we can't rely on this to be set. We really need way to use this library without this flag. |
Why is this issue closed? I still get this error when using import dayjs from '/node_modules/dayjs/dayjs.min.js'; |
like this I could use it in ES6 directly (without minification) import dayjs from '../../node_modules/dayjs/esm/index.js' |
@iamkun |
Should we use esm in this way?
|
@iamkun at least when using Angular, that would cause "deep import" warnings. If you fixed |
Detailed discussion about this on firebase repository: firebase/firebase-js-sdk#3315 (comment) |
If we follow NodeJS documentation "main": "dayjs.min.js",
"module": "esm/index.js",
"browser": "esm/index.js" |
Cool, I'm not sure if |
I try that: import * as dayjs from 'dayjs'
var someDate = dayjs(new Date()).add(28, 'day') and I get |
@hiredgunhouse |
# [1.10.0](v1.9.8...v1.10.0) (2021-01-03) ### Bug Fixes * add ordinal to localeData plugin ([#1266](#1266)) ([fd229fa](fd229fa)) * add preParsePostFormat plugin & update Arabic [ar] locale ([#1255](#1255)) ([f2e4790](f2e4790)) * add type support for plural forms of units ([#1289](#1289)) ([de49bb1](de49bb1)) * escape last period to match only milliseconds ([#1239](#1239)) ([#1295](#1295)) ([64037e6](64037e6)) ### Features * add ES6 Module Support, package.json module point to "esm/index.js" ([#1298](#1298)) ([f63375d](f63375d)), closes [#598](#598) [#313](#313)
🎉 This issue has been resolved in version 1.10.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |
I'm running version 1.10.5 and I have the original problem still.
Transpiled TypeScript to deployed JavaScript looks like this in browser:
|
Same problem here. the downside is for this workaround are: It will be better if dayjs include minified esm bundle version for browsers. |
# [1.10.0](iamkun/dayjs@v1.9.8...v1.10.0) (2021-01-03) ### Bug Fixes * add ordinal to localeData plugin ([#1266](iamkun/dayjs#1266)) ([fd229fa](iamkun/dayjs@fd229fa)) * add preParsePostFormat plugin & update Arabic [ar] locale ([#1255](iamkun/dayjs#1255)) ([f2e4790](iamkun/dayjs@f2e4790)) * add type support for plural forms of units ([#1289](iamkun/dayjs#1289)) ([de49bb1](iamkun/dayjs@de49bb1)) * escape last period to match only milliseconds ([#1239](iamkun/dayjs#1239)) ([#1295](iamkun/dayjs#1295)) ([64037e6](iamkun/dayjs@64037e6)) ### Features * add ES6 Module Support, package.json module point to "esm/index.js" ([#1298](iamkun/dayjs#1298)) ([f63375d](iamkun/dayjs@f63375d)), closes [#598](iamkun/dayjs#598) [#313](iamkun/dayjs#313)
# [1.10.0](iamkun/dayjs@v1.9.8...v1.10.0) (2021-01-03) ### Bug Fixes * add ordinal to localeData plugin ([#1266](iamkun/dayjs#1266)) ([fd229fa](iamkun/dayjs@fd229fa)) * add preParsePostFormat plugin & update Arabic [ar] locale ([#1255](iamkun/dayjs#1255)) ([f2e4790](iamkun/dayjs@f2e4790)) * add type support for plural forms of units ([#1289](iamkun/dayjs#1289)) ([de49bb1](iamkun/dayjs@de49bb1)) * escape last period to match only milliseconds ([#1239](iamkun/dayjs#1239)) ([#1295](iamkun/dayjs#1295)) ([64037e6](iamkun/dayjs@64037e6)) ### Features * add ES6 Module Support, package.json module point to "esm/index.js" ([#1298](iamkun/dayjs#1298)) ([f63375d](iamkun/dayjs@f63375d)), closes [#598](iamkun/dayjs#598) [#313](iamkun/dayjs#313)
import dayjs from 'node_modules/dayjs/esm/index'; works fine for my angular project. |
Is there still no ES module support for deployment directly to browsers? |
# [1.10.0](iamkun/dayjs@v1.9.8...v1.10.0) (2021-01-03) ### Bug Fixes * add ordinal to localeData plugin ([#1266](iamkun/dayjs#1266)) ([fd229fa](iamkun/dayjs@fd229fa)) * add preParsePostFormat plugin & update Arabic [ar] locale ([#1255](iamkun/dayjs#1255)) ([f2e4790](iamkun/dayjs@f2e4790)) * add type support for plural forms of units ([#1289](iamkun/dayjs#1289)) ([de49bb1](iamkun/dayjs@de49bb1)) * escape last period to match only milliseconds ([#1239](iamkun/dayjs#1239)) ([#1295](iamkun/dayjs#1295)) ([64037e6](iamkun/dayjs@64037e6)) ### Features * add ES6 Module Support, package.json module point to "esm/index.js" ([#1298](iamkun/dayjs#1298)) ([f63375d](iamkun/dayjs@f63375d)), closes [#598](iamkun/dayjs#598) [#313](iamkun/dayjs#313)
I am trying to use this library in a polymer 3 typescript project. Would it be possible to add support for es6 modules?
Code
Result
Workaround
The text was updated successfully, but these errors were encountered: