angelnikolov / ts-cacheable

Observable/Promise Cache Decorator
https://npmjs.com/package/ts-cacheable
ISC License
340 stars 42 forks source link

Source maps are broken #77

Closed wilson353 closed 4 years ago

wilson353 commented 4 years ago

Source maps reference files that are not present. This leads to warnings during a production build with vendor sourceMaps enabled.

ng build --prod
"sourceMap": {
  "hidden": true,
  "scripts": true,
  "styles": true,
  "vendor": true
}
WARNING in ./node_modules/ngx-cacheable/esm2015/common/DOMStorageStrategy.js
Module Warning (from ./node_modules/source-map-loader/index.js):
(Emitted value instead of an instance of Error) Cannot find source file '../../../common/DOMStorageStrategy.ts': Error: Can't resolve '../../../common/DOMStorageStrategy.ts' in '.../node_modules/ngx-cacheable/esm2015/common'

Thoughts on disabling sourceMaps for dist?

angelnikolov commented 4 years ago

I need to investigate this.. Will get back to you when I find time to do that. Also, if you can make a PR I can review, that'd be even better. :)

stale[bot] commented 4 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

TacticalVilius commented 4 years ago

Same problem here, using version 1.4.1. Get the warnings during build and during 'ng serve'. Output from serve:

WARNING in ./node_modules/ngx-cacheable/esm2015/common/DOMStorageStrategy.js
Module Warning (from ./node_modules/source-map-loader/index.js):
(Emitted value instead of an instance of Error) Cannot find source file '../../../common/DOMStorageStrategy.ts': Error: Can't resolve '../../../common/DOMStorageStrategy.ts' in 'C:\repos\HR\app\node_modules\ngx-cacheable\esm2015\common'

WARNING in ./node_modules/ngx-cacheable/esm2015/common/IAsyncStorageStrategy.js
Module Warning (from ./node_modules/source-map-loader/index.js):
(Emitted value instead of an instance of Error) Cannot find source file '../../../common/IAsyncStorageStrategy.ts': Error: Can't resolve '../../../common/IAsyncStorageStrategy.ts' in 'C:\repos\HR\app\node_modules\ngx-cacheable\esm2015\common'

WARNING in ./node_modules/ngx-cacheable/esm2015/common/IStorageStrategy.js
Module Warning (from ./node_modules/source-map-loader/index.js):
(Emitted value instead of an instance of Error) Cannot find source file '../../../common/IStorageStrategy.ts': Error: Can't resolve '../../../common/IStorageStrategy.ts' in 'C:\repos\HR\app\node_modules\ngx-cacheable\esm2015\common'

WARNING in ./node_modules/ngx-cacheable/esm2015/common/InMemoryStorageStrategy.js
Module Warning (from ./node_modules/source-map-loader/index.js):
(Emitted value instead of an instance of Error) Cannot find source file '../../../common/InMemoryStorageStrategy.ts': Error: Can't resolve '../../../common/InMemoryStorageStrategy.ts' in 'C:\repos\HR\app\node_modules\ngx-cacheable\esm2015\common'

WARNING in ./node_modules/ngx-cacheable/esm2015/common/index.js
Module Warning (from ./node_modules/source-map-loader/index.js):
(Emitted value instead of an instance of Error) Cannot find source file '../../../common/index.ts': Error: Can't resolve '../../../common/index.ts' in 'C:\repos\HR\app\node_modules\ngx-cacheable\esm2015\common'

WARNING in ./node_modules/ngx-cacheable/esm2015/cache-buster.decorator.js
Module Warning (from ./node_modules/source-map-loader/index.js):
(Emitted value instead of an instance of Error) Cannot find source file '../../cache-buster.decorator.ts': Error: Can't resolve '../../cache-buster.decorator.ts' in 'C:\repos\HR\app\node_modules\ngx-cacheable\esm2015'

WARNING in ./node_modules/ngx-cacheable/esm2015/cacheable.decorator.js
Module Warning (from ./node_modules/source-map-loader/index.js):
(Emitted value instead of an instance of Error) Cannot find source file '../../cacheable.decorator.ts': Error: Can't resolve '../../cacheable.decorator.ts' in 'C:\repos\HR\app\node_modules\ngx-cacheable\esm2015'

WARNING in ./node_modules/ngx-cacheable/esm2015/index.js
Module Warning (from ./node_modules/source-map-loader/index.js):
(Emitted value instead of an instance of Error) Cannot find source file '../../index.ts': Error: Can't resolve '../../index.ts' in 'C:\repos\HR\app\node_modules\ngx-cacheable\esm2015'

WARNING in ./node_modules/ngx-cacheable/esm2015/promise.cache-buster.decorator.js
Module Warning (from ./node_modules/source-map-loader/index.js):
(Emitted value instead of an instance of Error) Cannot find source file '../../promise.cache-buster.decorator.ts': Error: Can't resolve '../../promise.cache-buster.decorator.ts' in 'C:\repos\HR\app\node_modules\ngx-cacheable\esm2015'

WARNING in ./node_modules/ngx-cacheable/esm2015/promise.cacheable.decorator.js
Module Warning (from ./node_modules/source-map-loader/index.js):
(Emitted value instead of an instance of Error) Cannot find source file '../../promise.cacheable.decorator.ts': Error: Can't resolve '../../promise.cacheable.decorator.ts' in 'C:\repos\HR\app\node_modules\ngx-cacheable\esm2015'

To me it seems like the path it searches for the files is wrong. The "../../../" takes it back to the node_modules folder, where there is no 'common' folder. Inside node_modules/ngx-cacheable/esm2015/common folder the files exist, but with "d.ts" extension, instead of ".ts".

angelnikolov commented 4 years ago

Hm, can you show me your angular.json config for serve? I can't reproduce that during serve. Also I assume you are using DomStorageStrategy right?

angelnikolov commented 4 years ago

@TacticalVilius Okay, I think I managed to find the issue. I was not publishing the source code, which in case of vendor source map building is required. Can you please try it out with the version below and let me know if it works. Then I will release it @ latest. cc @wilson353 http://npmjs.com/package/ngx-cacheable/v/1.4.2-beta.1

TacticalVilius commented 4 years ago

@angelnikolov , it works, the warnings are gone. Thanks for the quick fix!

angelnikolov commented 4 years ago

Right, will publish version in latest later. Thanks!

angelnikolov commented 4 years ago

1.4.2 is now published. Thanks again!