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

Sourcemap from bundle is not utf-8 encoded #1035

Closed
SimenB opened this issue May 4, 2015 · 18 comments
Closed

Sourcemap from bundle is not utf-8 encoded #1035

SimenB opened this issue May 4, 2015 · 18 comments

Comments

@SimenB
Copy link
Contributor

SimenB commented May 4, 2015

This can be seen in sourcemap

image

This is the actual bundle generated

image

The letter å is wrong. Not sure if it's Webpack's fault or Sourcemap's?

Using Linux if that matters. Using devtool: '#source-map'

This is a letter only used in comments, not actual source, so shouldn't be a real problem.

@sokra
Copy link
Member

sokra commented May 11, 2015

https://github.com/webpack/webpack/blob/master/lib/SourceMapDevToolPlugin.js#L155

"utf-8" missing here. Would you like the write a PR?

@SimenB
Copy link
Contributor Author

SimenB commented May 18, 2015

@sokra Sure, but I'm unsure where you mean I should put utf-8? Default encoding is utf-8 (https://nodejs.org/api/buffer.html#buffer_new_buffer_str_encoding & https://nodejs.org/api/buffer.html#buffer_buf_tostring_encoding_start_end)

@disjukr
Copy link

disjukr commented Jul 30, 2015

i think same issue here: #859

@rjruizes
Copy link

I came across this issue because I had a Unicode code point in my javascript that was being scrambled as â–¾. My main.js and the outputted bundle.js were like so:
main.js: console.log("\u25BE").
bundle.js (UTF-8): console.log("▾");

My workaround: console.log(String.fromCodePoint(0x25BE))
The workaround prevents webpack from unescaping the code point, and makes it to display correctly.

@sokra
Copy link
Member

sokra commented Oct 13, 2015

Did you send the correct UTF-8 HTTP Header from your server? Or did you add the utf-8 meta tag to the HTML page?

@rickihastings
Copy link

I'm still getting this issue. Specifically some files being produced are non-utf8 so they cannot be understood by Sentry when I'm uploading them as release artifacts.

That aside, from what I can gather the PR #1797 just seems to fix them when they're data-uri sourcemaps? How can I ensure that all files webpack outputs are utf-8 (using Windows)?

@bebraw
Copy link
Contributor

bebraw commented Dec 24, 2016

Is this valid still? I can see the related PR was merged.

@SimenB
Copy link
Contributor Author

SimenB commented Dec 24, 2016

Seeing as @rickihastings stil had the issue a couple of months later, probably not.

I don't have a code base available to reproduce on

@jordanmkoncz
Copy link

I'm also having this issue, and like @rickihastings, I came upon this issue due to my source map not being readable by Sentry because the file is not utf8. I'm currently using Webpack 1.13.0 on macOS Sierra. I'm going to try updating to Webpack 1.14.0 and seeing if that resolves this issue - if it does then I'll report back here.

@yuri1992
Copy link

@jordanmkoncz did it worked for you ?

@katranci
Copy link
Contributor

katranci commented Jun 15, 2017

@bebraw I believe this issue is still valid. I'm using webpack@2.5.1 and I've got a multi-entry configuration. When I run file -bi *.map I can see that not all sourcemap files are in utf-8.

text/plain; charset=us-ascii
text/plain; charset=us-ascii
text/plain; charset=utf-8
text/plain; charset=us-ascii
text/plain; charset=utf-8
text/plain; charset=us-ascii
text/plain; charset=utf-8

What could cause a sourcemap file to be encoded in non-utf8 character set?

@mikeaustin
Copy link

mikeaustin commented Jul 27, 2017

Not sure if this is related, but I just fond I need to add charset="utf-8" to the bundle.js script tag:

<script src="bundle.js" type="text/javascript" charset="utf-8"></script>

Without the charset attribute, I get weird characters even with just &#9632;

@paul-sachs
Copy link

paul-sachs commented Aug 14, 2017

Also running into this. Doesn't seem to be any pattern, i have files either encoded as utf-8 or us-ascii.

0.e6063d8a791459c43093.chunk.js.map:                 text/plain; charset=us-ascii
1.e6063d8a791459c43093.chunk.js.map:                 text/plain; charset=utf-8
10.e6063d8a791459c43093.chunk.js.map:                text/plain; charset=utf-8
11.e6063d8a791459c43093.chunk.js.map:                text/plain; charset=utf-8
12.e6063d8a791459c43093.chunk.js.map:                text/plain; charset=utf-8
13.e6063d8a791459c43093.chunk.js.map:                text/plain; charset=utf-8
14.e6063d8a791459c43093.chunk.js.map:                text/plain; charset=utf-8
15.e6063d8a791459c43093.chunk.js.map:                text/plain; charset=utf-8
16.e6063d8a791459c43093.chunk.js.map:                text/plain; charset=us-ascii

In fact, this is not limited to source maps. My bundles are also scattered, some utf-8, some us-ascii. I'd like them to all be utf-8 encoded. Can this be forced? I tried webpack-encoding-plugin but it didn't work.

Using webpack 3.2

@sokra
Copy link
Member

sokra commented Aug 15, 2017

They are always utf-8 encoded. If you only use characters from the ascii range, us-ascii and utf-8 encoding look equal.

> Buffer.from("abc", "utf-8")
<Buffer 61 62 63>
> Buffer.from("abc", "ascii")
<Buffer 61 62 63>

> Buffer.from("abcä", "ascii")
<Buffer 61 62 63 e4>
> Buffer.from("abcä", "utf-8")
<Buffer 61 62 63 c3 a4>

@paul-sachs
Copy link

hmm, interesting. I am trying to use a tool (sentry-cli) that uploads sourcemaps and it explodes saying "stream did not contain valid UTF-8". Might be something specific on their end in that case.

@newtonsheikh
Copy link

Thank you. Was facing the same problem text/plain; charset=utf-8 solved similar problem in our code. Cheers!

ddt-nishiwaki pushed a commit to ddt-nishiwaki/learningWebpack that referenced this issue Sep 6, 2018
TODO: 日本語がソースマップ場で文字化けしてしまう現象があるので対応方法を検討する

// 参考サイト: https://qiita.com/kenfdev/items/0ed70a1692bd2f119b69
// 参考サイト: webpack/webpack#1035
@webpack-bot
Copy link
Contributor

This issue had no activity for at least half a year.

It's subject to automatic issue closing if there is no activity in the next 15 days.

@webpack-bot
Copy link
Contributor

Issue was closed because of inactivity.

If you think this is still a valid issue, please file a new issue with additional information.

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