angular-cache icon indicating copy to clipboard operation
angular-cache copied to clipboard

Source map corrupted

Open Delagen opened this issue 9 years ago • 12 comments

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 avatar May 04 '16 08:05 Delagen

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

Delagen avatar May 04 '16 08:05 Delagen

Still not solved

Delagen avatar Sep 12 '16 09:09 Delagen

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

jmdobry avatar Sep 19 '16 17:09 jmdobry

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

Delagen avatar Sep 19 '16 20:09 Delagen

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

Delagen avatar Sep 19 '16 20:09 Delagen

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

jmdobry avatar Sep 19 '16 22:09 jmdobry

angular.js.map that for unminified dist

Delagen avatar Sep 20 '16 03:09 Delagen

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.

zentoaku avatar Jun 05 '17 10:06 zentoaku

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 avatar Jul 27 '17 12:07 nfriend

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.

nfriend avatar Jul 27 '17 13:07 nfriend

From https://github.com/mozilla/source-map/issues/247 comments:

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

Might need to do the same here.

deini avatar Aug 07 '17 20:08 deini

From mozilla/source-map#247 comments:

In particular I was following: https://github.com/rollup/rollup/issues/1254

tromey avatar Aug 07 '17 20:08 tromey