Chrome Version : 60.0.3100.0 (Official Build) dev (64-bit) Linux (V8 6.0.205)
URLs (if applicable) :http://www.movable-type.co.uk/dev/es-modules/classic-script-string.htmlhttp://www.movable-type.co.uk/dev/es-modules/classic-script-const.htmlhttp://www.movable-type.co.uk/dev/es-modules/module-script-string.htmlhttp://www.movable-type.co.uk/dev/es-modules/module-script-const.htmlWhat steps will reproduce the problem?
visit URLs above & view console.log output; 'classic' versions work correctly, 'module' versions don't handle non-ASCII UTF-8 characters.
What is the expected result?
'script-string.html' URLs should show 'π' in the console; 'script-const.html' URLs should show '3.141592653589793' in the console.
What happens instead?
- 'classic' versions run correctly
- module-script-string.html shows 'Ï€' instead of 'π'
- module-script-const.html shows 'Uncaught SyntaxError: Missing initializer in const declaration'
Please provide any additional information below. Attach a screenshot ifpossible.
Both 'classic' & 'module' versions of 'string' load .js file containing 'console.log('π');'.
Both 'classic' & 'module' versions of 'const' load .js file containing 'const π = Math.PI; console.log(π);'.
The 'module' versions use 'type="module"' to load the .js file.
It would appear that '<script type="module">' is treating file encoding as ASCII instead of UTF-8?
Able to reproduce the issue on Windows 7, Mac 10.12.4 & Ubuntu 14.04 using chrome stable#58.0.3029.110, reported version#60.0.3100.0 & latest Canary#61.0.3114.0 as per the above steps & URL's.
Observed 'blank output' in Console log of dev tools for the below module related URL's are :
http://www.movable-type.co.uk/dev/es-modules/module-script-string.htmlhttp://www.movable-type.co.uk/dev/es-modules/module-script-const.html
Observed 'π' for classic-script-string.html & '3.141592653589793' for classic-script-const.html file in Devtools-> Console.
Observed the same behavior from M30 (30.0.1549.0 ) builds to latest Canary, hence marking it as 'Untriaged' to get more inputs from dev for further investigation.
Please find the attached screencast for reference.
Thank you..!!
Update: I have managed to resolve this by setting charset for Content-Type:application/javascript to 'utf-8' (using Apache 'AddDefaultCharset utf-8' and/or 'AddCharset utf-8 .js').
Why this is required for ES modules .js files and not for classic script .js files I don't know!
Fixed.
Issue 732893 remains open, but I think we can unblock 594639 now because Issue 732893 has been existed for a long time (for classic scripts), and fixing it will take more time.
Comment 1 by nyerramilli@chromium.org
, May 24 2017