-
-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Fix esm plugin typings and add test. #1544
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
base: dev
Are you sure you want to change the base?
Conversation
Codecov Report
@@ Coverage Diff @@
## dev #1544 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 176 177 +1
Lines 1980 1986 +6
Branches 502 503 +1
=========================================
+ Hits 1980 1986 +6
Continue to review full report at Codecov.
|
| @@ -0,0 +1,11 @@ | |||
| import dayjs from 'dayjs/esm'; | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what's this file used for, please?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Test esm generated files.
|
e.g. in file |
Yes, it’s just changing plugin directories. |
seems we don't have to change the path here? |
Locale is ok, plug-ins generates a folder due to typings. |
Can you please detail it? Seems there's no plugin has the import statement |
|
Honestly I don’t know why Babel adds it. Probably due to typings. dayjs/types/plugin/duration.d.ts Line 2 in 8e32164
Changing that to dayjs may fix the problem too I will test.
|
|
The error is just with duration plugin. |
| const filePath = path.join(localeDir, l) | ||
| const readFile = await promisify(fs.readFile)(filePath, 'utf8') | ||
| const result = readFile.replace("'dayjs'", "'../index'") | ||
| const result = readFile.replace(/'dayjs'/g, "'dayjs/esm'") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
seems ../index should be the same file as dayjs/esm, don't it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, for locale, it’s just to match plugins logic.
Plugins generated structure is different due to typings.
translation/en.js vs plugins/duration/index.js
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can check the final file here https://unpkg.com/browse/dayjs@1.10.6/esm/locale/af.js
../index refers to esm/index.js, which I think it's correct?

Generated esm plugins are generated like
plugin/duration/index.js, but import still points toimport dayjs from '../index', but it should beimport dayjs from '../../index'.