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

Source map URLs shouldn't be prefixed with a local path #4518

Closed
japgolly opened this issue Mar 19, 2017 · 8 comments
Closed

Source map URLs shouldn't be prefixed with a local path #4518

japgolly opened this issue Mar 19, 2017 · 8 comments

Comments

@japgolly
Copy link

japgolly commented Mar 19, 2017

Do you want to request a feature or report a bug?

Bug.

What is the current behavior?

Some libraries (i.e. nearly all created via Scala.JS) have URLs in their source maps. However when being used with webpack, webpack is prepending a ./ to all the URLs results in trillions of warnings like this:

[info] Cannot find source file 'https://raw.githubusercontent.com/scala/scala/v2.12.1/src/library/scala/collection/immutable/Vector.scala': Error: Can't resolve './https://raw.githubusercontent.com/scala/scala/v2.12.1/src/library/scala/collection/immutable/Vector.scala' in '/home/golly/projects/misc/target/scala-2.12/scalajs-bundler/main'
[info]  @ ./fastopt-launcher.js 1:0-91
[info] 
[info] WARNING in ./demo-fastopt.js
[info] Cannot find source file 'https://raw.githubusercontent.com/scala/scala/v2.12.1/src/library/scala/collection/immutable/List.scala': Error: Can't resolve './https://raw.githubusercontent.com/scala/scala/v2.12.1/src/library/scala/collection/immutable/List.scala' in '/home/golly/projects/misc/target/scala-2.12/scalajs-bundler/main'
[info]  @ ./fastopt-launcher.js 1:0-91
[info] 
[info] WARNING in ./demo-fastopt.js
[info] Cannot find source file 'https://raw.githubusercontent.com/scala/scala/v2.12.1/src/library/scala/collection/immutable/Stream.scala': Error: Can't resolve './https://raw.githubusercontent.com/scala/scala/v2.12.1/src/library/scala/collection/immutable/Stream.scala' in '/home/golly/projects/misc/target/scala-2.12/scalajs-bundler/main'
[info]  @ ./fastopt-launcher.js 1:0-91
[info] 
[info] WARNING in ./demo-fastopt.js
[info] Cannot find source file 'https://raw.githubusercontent.com/scala/scala/v2.12.1/src/library/scala/collection/immutable/StringOps.scala': Error: Can't resolve './https://raw.githubusercontent.com/scala/scala/v2.12.1/src/library/scala/collection/immutable/StringOps.scala' in '/home/golly/projects/misc/target/scala-2.12/scalajs-bundler/main'
[info]  @ ./fastopt-launcher.js 1:0-91
[info] 
[info] WARNING in ./demo-fastopt.js
[info] Cannot find source file 'https://raw.githubusercontent.com/scala/scala/v2.12.1/src/library/scala/collection/immutable/WrappedString.scala': Error: Can't resolve './https://raw.githubusercontent.com/scala/scala/v2.12.1/src/library/scala/collection/immutable/WrappedString.scala' in '/home/golly/projects/misc/target/scala-2.12/scalajs-bundler/main'
[info]  @ ./fastopt-launcher.js 1:0-91

And resulting in a final source map that no longer works for those libraries.

If the current behavior is a bug, please provide the steps to reproduce.

Setup any dummy project with Scala.JS and scalajs-bundler which runs everything through webpack.

What is the expected behavior?

Source map links that can be identified as absolute URLs should be used as is, without modification.

I believe the fix would be a very simple test like this before prepending:
https://github.com/jantimon/html-webpack-plugin/pull/619/files

Please mention other relevant information such as the browser version, Node.js version, webpack version and Operating System.

Using webpack 2.2.1, Node.JS 7.7.3.

@sokra
Copy link
Member

sokra commented Mar 21, 2017

I wonder where this message origin in Cannot find source file ...

Could you run it with --display-error-details (errorDetails: true in stats)?

@japgolly
Copy link
Author

Hi @sokra, I tried with errorDetails: true and the output was the same as before. I set stats: "verbose" and still didn't get any additional, useful info (snippet below). I also set stats: "none" to confirm my settings we being detected and they were.

[info] WARNING in ./demo-fastopt.js
[info] Cannot find source file 'https://raw.githubusercontent.com/japgolly/scalajs-react/v1.0.0-RC1/core/src/main/scala/japgolly/scalajs/react/CtorType.scala': Error: Can't resolve './https://raw.githubusercontent.com/japgolly/scalajs-react/v1.0.0-RC1/core/src/main/scala/japgolly/scalajs/react/CtorType.scala' in '/home/golly/projects/misc/target/scala-2.12/scalajs-bundler/main'
[info]  @ ./fastopt-launcher.js 1:0-91
[info] 
[info] WARNING in ./demo-fastopt.js
[info] Cannot find source file 'https://raw.githubusercontent.com/japgolly/scalajs-react/v1.0.0-RC1/core/src/main/scala/japgolly/scalajs/react/Callback.scala': Error: Can't resolve './https://raw.githubusercontent.com/japgolly/scalajs-react/v1.0.0-RC1/core/src/main/scala/japgolly/scalajs/react/Callback.scala' in '/home/golly/projects/misc/target/scala-2.12/scalajs-bundler/main'
[info]  @ ./fastopt-launcher.js 1:0-91
[info] 
[info] WARNING in ./demo-fastopt.js
[info] Cannot find source file 'https://raw.githubusercontent.com/japgolly/scalajs-react/v1.0.0-RC1/core/src/main/scala/japgolly/scalajs/react/package.scala': Error: Can't resolve './https://raw.githubusercontent.com/japgolly/scalajs-react/v1.0.0-RC1/core/src/main/scala/japgolly/scalajs/react/package.scala' in '/home/golly/projects/misc/target/scala-2.12/scalajs-bundler/main'
[info]  @ ./fastopt-launcher.js 1:0-91
[info] 
[info] WARNING in ./demo-fastopt.js
[info] Cannot find source file 'https://raw.githubusercontent.com/japgolly/scalajs-react/v1.0.0-RC1/core/src/main/scala/japgolly/scalajs/react/component/ScalaBuilder.scala': Error: Can't resolve './https://raw.githubusercontent.com/japgolly/scalajs-react/v1.0.0-RC1/core/src/main/scala/japgolly/scalajs/react/component/ScalaBuilder.scala' in '/home/golly/projects/misc/target/scala-2.12/scalajs-bundler/main'
[info]  @ ./fastopt-launcher.js 1:0-91
[info] 
[info] WARNING in ./demo-fastopt.js

@japgolly
Copy link
Author

japgolly commented Mar 22, 2017

Cannot find source file seems to be coming from here:
https://github.com/webpack-contrib/source-map-loader/blob/v0.2.0/index.js#L65

I'm not too worried about that though because it just seems to be wrapping the underlying error which is:

Error: Can't resolve './https://raw.githubusercontent.com/japgolly/scalajs-react/v1.0.0-RC1/core/src/main/scala/japgolly/scalajs/react/CtorType.scala' in '/home/golly/projects/misc/target/scala-2.12/scalajs-bundler/main'

I submitted a PR to loader-utils to stop the prefixing, that's where that was happening:
webpack/loader-utils#79

Unfortunately I'm still getting the same errors, just the prefix has been correctly removed:

Error: Can't resolve 'https://raw.githubusercontent.com/japgolly/scalajs-react/v1.0.0-RC1/core/src/main/scala/japgolly/scalajs/react/internal/Semigroup.scala' in '/home/golly/projects/misc/target/scala-2.12/scalajs-bundler/main'
 @ ./target/scala-2.12/scalajs-bundler/main/fastopt-launcher.js 1:0-91

@jhnns
Copy link
Member

jhnns commented Mar 22, 2017

Looks like scalajs-bundler is using the source-map-loader. The source-map-loader uses webpack's resolver to resolve the source-map. webpack's resolver, however, cannot resolve remote resources via http and such.

So, why are they using the source-map-loader at all?

And: I'm also not sure if it's a good idea to point the sourceMappingURL to raw.githubusercontent.com...

sokra added a commit that referenced this issue Mar 22, 2017
add info about emitting an Error

#4518
sokra added a commit that referenced this issue Mar 22, 2017
add info about emitting an Error

#4518
sokra added a commit that referenced this issue Mar 22, 2017
add info about emitting an Error

#4518
zastavnitskiy pushed a commit to zastavnitskiy/webpack that referenced this issue Apr 2, 2017
add info about emitting an Error

webpack#4518
smelukov pushed a commit to smelukov/webpack that referenced this issue Apr 3, 2017
add info about emitting an Error

webpack#4518
@julienrf
Copy link

So, why are they using the source-map-loader at all?

We use source-map-loader to preserve (as most as possible) source-map continuity across libraries.

@nartamonov
Copy link

Any update on this, guys?

@alexander-akait
Copy link
Member

@webpack-bot move to webpack-contrib/source-map-loader

@webpack-bot
Copy link
Contributor

I've moved it to webpack-contrib/source-map-loader.

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

8 participants