Skip to content
This repository has been archived by the owner on Dec 5, 2019. It is now read-only.

Unnecessary warning on "invalid source map" for JSON files #283

Closed
stnwk opened this issue Apr 28, 2018 · 6 comments · Fixed by #284
Closed

Unnecessary warning on "invalid source map" for JSON files #283

stnwk opened this issue Apr 28, 2018 · 6 comments · Fixed by #284

Comments

@stnwk
Copy link

stnwk commented Apr 28, 2018

Hi everyone :)

When import()ing a json file, the generated source map is valid but "empty", which causes https://github.com/webpack-contrib/uglifyjs-webpack-plugin/pull/268/files#diff-8968c62593320351ced6a0ef776ef599R8 to fail and emit a warning.

See #268

Example:

data.json

{
	"hello": "world"
}

generates the following source map:

{
 "version":1,
 "sources":[],
 "names":[],
 "mappings":"",
 "file":"data.8efcc96623969177ff47.js",
 "sourceRoot":""
}

Unfortunately this causes isSourceMap() from https://github.com/webpack-contrib/uglifyjs-webpack-plugin/pull/268/files#diff-8968c62593320351ced6a0ef776ef599 to not recognize it as a valid source map. (mappings check fails).

Even when using SourceMapDevToolPlugin() https://webpack.js.org/plugins/source-map-dev-tool-plugin/ and explicitely excluding source maps for such files the warning will still be added. This should definitely not happen, I guess? Of course there is "no valid source map", because there is no source map at all.

Ultimately it adds the following warning to the webpack compiler output:

data.8efcc96623969177ff47.js contain invalid source map

Sidenote: There is a typo, it should be "contains".

Side-Sidenote: This "warning" comes without any "error stack" and is really, really hard to debug. Also searching on google / stackoverflow etc. is extremely hard because it's so generic and there is no way of knowing who warned me. Is it webpack? Babel? Typescript?

I only found the cause by change after intense searching and almost losing my mind. 🤪
Would love to see some improved message here too :)

Cheers and thank you,
Stefan

@alexander-akait
Copy link
Member

@stnwk Looks as bug, empty string interpreted as false, feel free to PR

Sidenote: There is a typo, it should be "contains".

need fix, PR welcome

Side-Sidenote: This "warning" comes without any "error stack" and is really, really hard to debug. Also searching on google / stackoverflow etc. is extremely hard because it's so generic and there is no way of knowing who warned me. Is it webpack? Babel? Typescript?

This warning can't has error stack, because we don't have error stack. It is just warnings.

What message you expected?

@alexander-akait
Copy link
Member

@stnwk

Side-Sidenote: This "warning" comes without any "error stack" and is really, really hard to debug. Also searching on google / stackoverflow etc. is extremely hard because it's so generic and there is no way of knowing who warned me. Is it webpack? Babel? Typescript?

We already work in webpack to better warnings/errors logging, it is not part of uglify plugin. Feel free to opoen issue/send PR in webpack to improve this mechanism.

@creage
Copy link

creage commented Jun 15, 2018

I still see this warning for JSON file, which generates following sourcemap

{"version":3,"sources":[],"names":[],"mappings":"","file":"chunks/1.df2663.js","sourceRoot":""}

which is, according to this fix should be treated as an emptyRawSourceMap, and should be a valid one

expect(utils.isSourceMap(emptyRawSourceMap)).toBe(true);

But I still see
WARNING in chunks/1.df2663.js contain invalid source map

@alexander-akait
Copy link
Member

@creage please create new issue

@emmenko
Copy link

emmenko commented Jun 18, 2018

The problem is that the fix has not been released/published yet

image

/cc @sokra

emmenko added a commit to commercetools/merchant-center-application-kit that referenced this issue Oct 8, 2018
Fixes empty source map validation (patch is unreleased upstream)
webpack-contrib/uglifyjs-webpack-plugin#283
@iamcristos
Copy link

I'm currently getting this warning anyone with the fix can reach out

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

Successfully merging a pull request may close this issue.

5 participants