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

Module import doesn't work in the latest Chrome #4203

Closed
arcady-zherdev opened this issue Oct 5, 2017 · 7 comments
Closed

Module import doesn't work in the latest Chrome #4203

arcady-zherdev opened this issue Oct 5, 2017 · 7 comments

Comments

@arcady-zherdev
Copy link

Description of the Issue and Steps to Reproduce:

Latest version of Chrome declares native modules import support. But the feature requires full module file name to be provided (including ".js" extension).
In the library code "import ..." entries don't have ".js" extensions which results 404 errors in the browser.

FYI: One thing that might (and does on some platforms) hide this issue is a web-server configuration.
Apache web-server on OSX seems has "MultiViews" setting enabled by default (which makes the server find "moment.js" file if there is no "moment" file found), but on Ubuntu, for example, this web-server option is disabled which make the module loading fail.

Environment:

Chrome 61.0.3163.100 (64 bit) on Ubuntu 16.04

console.log( (new Date()).toString())
console.log((new Date()).toLocaleString())
console.log( (new Date()).getTimezoneOffset())
console.log( navigator.userAgent)
VM3015:1 Thu Oct 05 2017 19:30:43 GMT+0600 (+06)
VM3015:2 05.10.2017, 19:30:43
VM3015:3 -360
VM3015:4 Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/61.0.3163.100 Safari/537.36

moment.js version is 2.18.1

@nnmrts
Copy link

nnmrts commented Jan 8, 2018

This is not just a chrome thing. As far as i know, the es6 module spec requires a file name in the FromClause and not just a string. Rollup and Webpack are working fine without the file extension, but that's only to make bundling easier.

And overall it's better to avoid letting any loader guess the extension, so yeah, the FromClauses should really be full file names.

@TremayneChrist
Copy link
Contributor

Would be really good to get this sorted as neither the source version nor the compiled version works when using a module import in browsers which support it.

It should be a quick fix of just adding file extensions to the imports.
Also for people wanting to use the compiled version - for global use of Moment, the global property needs to fallback to window as this is undefined.

@marwahaha
Copy link
Member

This would be best solved by a community-driven PR!

@nnmrts
Copy link

nnmrts commented Apr 4, 2018

here ya go

@rdehuyss
Copy link

rdehuyss commented Aug 8, 2018

This would be great for usage in a Polymer webcomponent. Now, I do not succeed to use moment js in a standard ES6 webcomponent due to this.

@marwahaha
Copy link
Member

Is this still an issue? I'm worried adding file extensions will cause Moment.js to break for some other subset of users ...

@marwahaha
Copy link
Member

I think this is a duplicate of #4713

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants