jmdobry / angular-cache

angular-cache is a very useful replacement for the Angular 1 $cacheFactory.
http://jmdobry.github.io/angular-cache
MIT License
1.39k stars 156 forks source link

Source map corrupted #225

Open Delagen opened 8 years ago

Delagen commented 8 years ago

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 commented 8 years ago

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

Delagen commented 8 years ago

Still not solved

jmdobry commented 8 years ago

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

Delagen commented 8 years ago

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

Delagen commented 8 years ago

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 commented 8 years ago

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

Delagen commented 8 years ago

angular.js.map that for unminified dist

zentoaku commented 7 years ago

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 commented 7 years ago

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 commented 7 years ago

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

deini commented 7 years ago

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.

tromey commented 7 years ago

From mozilla/source-map#247 comments:

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