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 corrupted #225

Open
Delagen opened this issue May 4, 2016 · 12 comments
Open

Source map corrupted #225

Delagen opened this issue May 4, 2016 · 12 comments
Labels

Comments

@Delagen
Copy link

Delagen commented May 4, 2016

Error when using with webpack with source-map-loader

imports?this=>window&module=>undefined&exports=>undefined&define=>undefined!angular-cache

Module build failed: TypeError: Cannot read property 'substr' of undefined
    at Function.<anonymous> (...\node_modules\imports-loader\node_modules\source-map\lib\source-map\source-node.js:100:32)
@Delagen
Copy link
Author

Delagen commented May 4, 2016

When used manually min version all OK
imports?this=>window&module=>undefined&exports=>undefined&define=>undefined!angular-cache/dist/angular-cache.min

@Delagen
Copy link
Author

Delagen commented Sep 12, 2016

Still not solved

@jmdobry
Copy link
Owner

jmdobry commented Sep 19, 2016

The source maps are generated by Rollup.js. I don't have any idea what to do about this.

@jmdobry jmdobry added the bug label Sep 19, 2016
@Delagen
Copy link
Author

Delagen commented Sep 19, 2016

I think this is due paths with parenthesis (../) in paths or other issue

@Delagen
Copy link
Author

Delagen commented Sep 19, 2016

I think you can postprocess source file with something like

uglifyjs dist/angular-cache.js --in-source-map dist/angular-cache.js.map  -o dist/angular-cache.min.js --source-map dist/angular-cache.min.map --source-map-root=dist --source-map-url angular-cache.min.map --source-map-include-sources -v -b --comments all

@jmdobry
Copy link
Owner

jmdobry commented Sep 19, 2016

Which of the two source maps is the one that you're saying is corrupted?

@Delagen
Copy link
Author

Delagen commented Sep 20, 2016

angular.js.map that for unminified dist

@zentoaku
Copy link

zentoaku commented Jun 5, 2017

Issue is still there. I've run into the same bug with webpack 2.2. Defining babel loader for this file solves it but I don't want to add babel only for one lib.

@nfriend
Copy link

nfriend commented Jul 27, 2017

My workaround was to alias this module to the .min.js file in my webpack.config.js:

{
  resolve: {
    alias: {
      'angular-cache': path.resolve(__dirname, 'node_modules/angular-cache/dist/angular-cache.min.js'),
    }
  }
}

@nfriend
Copy link

nfriend commented Jul 27, 2017

A couple of other issues related to this module's source maps:

  • The source map for the minified .js file should be named "angular-cache.min.js.map". Currently it is named "angular-cache.min.map". This doesn't break anything, but it's not the standard naming convention.
  • The source maps refer to a source file "dist/angular-cache.min.js". However, this file is a direct sibling of the source map, so the path should instead be "angular-cache.min.js". My webpack build throws an error when it tries to ingest this source map since the path is incorrect: Cannot find source file 'dist/angular-cache.js'. Changing all occurrences of "dist/angular-cache.min.js" to "angular-cache.min.js" in the .min file ("angular-cache.min.map") fixes this error.

@deini
Copy link

deini commented Aug 7, 2017

From mozilla/source-map#247 comments:

Changing preact to use a newer version of rollup fixed the preact source map.

Might need to do the same here.

@tromey
Copy link

tromey commented Aug 7, 2017

From mozilla/source-map#247 comments:

In particular I was following: rollup/rollup#1254

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

No branches or pull requests

6 participants