Skip to content
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

ie11 (and other 'es5'-browsers) problem with transpile #477

Closed
yyynnn opened this issue Feb 5, 2019 · 10 comments
Closed

ie11 (and other 'es5'-browsers) problem with transpile #477

yyynnn opened this issue Feb 5, 2019 · 10 comments
Labels
☢️Bug Something isn't working help wanted Extra attention is needed

Comments

@yyynnn
Copy link

yyynnn commented Feb 5, 2019

Dayjs not transpiling down to es5 on version 1.8.4, leaving es6 code in bundle. (the babel/ts webpack config is fine)

1.7.4 is the last known working version

@yyynnn yyynnn changed the title ie11 problem with transpile ie11 (and other 'es5'-browsers) problem with transpile Feb 5, 2019
@ghost
Copy link

ghost commented Feb 5, 2019

@yyynnn Just checked the final code in v1.8.4, everything looks fine in es5.

Any further information please?

@paulgv
Copy link

paulgv commented Feb 5, 2019

I've had the same issue after upgrading from 1.7.8 to 1.8.4, IE11 was logging a SyntaxError because of some arrow function in dayjs.
In dev mode, the error pointed to this line: https://github.com/iamkun/dayjs/blob/dev/src/index.js#L8

@gkkirsch
Copy link

gkkirsch commented Feb 6, 2019

This is also happening to us. We are using an ejected version of create react app's webpack build script with minimal changes. The build script isn't able to minify the js. I believe this is because our build script is a little outdated. https://facebook.github.io/create-react-app/docs/troubleshooting#npm-run-build-fails-to-minify

Newer versions of create react app's webpack build script probably include a loader that transpiles node_modules that are included via the module package.json config option. IDK.

Should that change have been a major version bump?

screen shot 2019-02-05 at 5 03 28 pm

@NickHath
Copy link

NickHath commented Feb 6, 2019

When we remove the "module" property pointing to "./src/index.js" in our local dayjs module, our build process works successfully:

screen shot 2019-02-05 at 5 24 40 pm

With the "module" property, it fails:
screen shot 2019-02-05 at 5 24 33 pm

I think it might be related to #451.

@iamkun
Copy link
Owner

iamkun commented Feb 6, 2019

We've added a "module" property in package.json file after v1.8.0+, and pointed to the /src folder which is the source code in es6 with import/export syntax.

This is to made our lib treeshakeable with the help of modern bundle tool like webpack.

This issue is an unexpected behavior, and should be fix in the coming hotfix in a few days.

Just I'm not sure how to fix this, if I point "module" to the compiled es5 code, that makes no sense.

Anyone could help?

@iamkun iamkun added ☢️Bug Something isn't working help wanted Extra attention is needed labels Feb 6, 2019
@Tvrqvoise
Copy link
Contributor

Tvrqvoise commented Feb 6, 2019

@iamkun I think you have two options to fix this:

  1. still transpile the "module" entrypoint, but don't transpile es6 modules. This will let people who support the module entry (webpack et al) use es6 imports with tree shaking and whatnot, but will still run fat arrows, consts, and so on through babel.
  2. publish a new version which removes the module field entirely. Then, publish a new major version with the module field back in and tell people to explicitly pass dayjs through babel themselves. This would mean any webpack users would have to add an exception in their babel loader includes / excludes for dayjs specifically. Not sure what the implication is for other module systems. This would make dayjs harder to use for people, but could have a small benefit in terms of module size.

For what it's worth, I prefer the first option. I could open a PR for this too, if you're interested.

@iamkun
Copy link
Owner

iamkun commented Feb 6, 2019

option 1 pr welcome 😁

Tvrqvoise added a commit to Tvrqvoise/dayjs that referenced this issue Feb 6, 2019
iamkun pushed a commit that referenced this issue Feb 7, 2019
## [1.8.5](v1.8.4...v1.8.5) (2019-02-07)

### Bug Fixes

* Add en-gb locale ([#478](#478)) ([508c3a7](508c3a7))
* **module:** transpile everything except ES6 modules in the 'module' entrypoint ([#477](#477)) ([#480](#480)) ([#482](#482)) ([767017d](767017d))
* update customParseFormat plugin support hh:mm ([54947cc](54947cc)), closes [#484](#484)
* Update module in package.json ([5c5a7a0](5c5a7a0))
@iamkun
Copy link
Owner

iamkun commented Feb 7, 2019

Try hotfix v1.8.5, contains @Tvrqvoise's fix, hope this will help.

@Tvrqvoise
Copy link
Contributor

Confirmed that v1.8.5 works for me. Thanks @iamkun for the quick updates and the great library!

@yyynnn
Copy link
Author

yyynnn commented Feb 8, 2019

yeah cool

@yyynnn yyynnn closed this as completed Feb 8, 2019
andrewhood125ruhuc added a commit to andrewhood125ruhuc/SidRH2 that referenced this issue May 10, 2022
## [1.8.5](iamkun/dayjs@v1.8.4...v1.8.5) (2019-02-07)

### Bug Fixes

* Add en-gb locale ([#478](iamkun/dayjs#478)) ([508c3a7](iamkun/dayjs@508c3a7))
* **module:** transpile everything except ES6 modules in the 'module' entrypoint ([#477](iamkun/dayjs#477)) ([#480](iamkun/dayjs#480)) ([#482](iamkun/dayjs#482)) ([767017d](iamkun/dayjs@767017d))
* update customParseFormat plugin support hh:mm ([54947cc](iamkun/dayjs@54947cc)), closes [#484](iamkun/dayjs#484)
* Update module in package.json ([5c5a7a0](iamkun/dayjs@5c5a7a0))
andrewhood125ruhuc added a commit to andrewhood125ruhuc/SidRH2 that referenced this issue May 10, 2022
## [1.8.5](iamkun/dayjs@v1.8.4...v1.8.5) (2019-02-07)

### Bug Fixes

* Add en-gb locale ([#478](iamkun/dayjs#478)) ([508c3a7](iamkun/dayjs@508c3a7))
* **module:** transpile everything except ES6 modules in the 'module' entrypoint ([#477](iamkun/dayjs#477)) ([#480](iamkun/dayjs#480)) ([#482](iamkun/dayjs#482)) ([767017d](iamkun/dayjs@767017d))
* update customParseFormat plugin support hh:mm ([54947cc](iamkun/dayjs@54947cc)), closes [#484](iamkun/dayjs#484)
* Update module in package.json ([5c5a7a0](iamkun/dayjs@5c5a7a0))
allmoviestvshowslistsfilmography28 added a commit to allmoviestvshowslistsfilmography28/dayjs that referenced this issue Sep 12, 2024
## [1.8.5](iamkun/dayjs@v1.8.4...v1.8.5) (2019-02-07)

### Bug Fixes

* Add en-gb locale ([#478](iamkun/dayjs#478)) ([600d19f](iamkun/dayjs@600d19f))
* **module:** transpile everything except ES6 modules in the 'module' entrypoint ([#477](iamkun/dayjs#477)) ([#480](iamkun/dayjs#480)) ([#482](iamkun/dayjs#482)) ([30cd5cb](iamkun/dayjs@30cd5cb))
* update customParseFormat plugin support hh:mm ([8041cce](iamkun/dayjs@8041cce)), closes [#484](iamkun/dayjs#484)
* Update module in package.json ([c578bd0](iamkun/dayjs@c578bd0))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
☢️Bug Something isn't working help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

6 participants