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

Warnings displayed by webpack when using source-map-loader #64

Closed
TobiasKrogh opened this issue Apr 29, 2016 · 5 comments · Fixed by #182
Closed

Warnings displayed by webpack when using source-map-loader #64

TobiasKrogh opened this issue Apr 29, 2016 · 5 comments · Fixed by #182
Assignees

Comments

@TobiasKrogh
Copy link

TobiasKrogh commented Apr 29, 2016

Hey,

just a minor thing. Might not even be worth mentioning it in the README. When using the source-map-loader to extract source maps without any excludes ng2-redux 2.2.3 displays warnings.

WARNING in ./~/ng2-redux/lib/index.js
Cannot find source file '../src/index.ts': Error: Cannot resolve 'file' or 'directory' ../src/index.ts in /vagrant/styleguide/node_modules/ng2-redux/lib

WARNING in ./~/ng2-redux/lib/components/provider.js
Cannot find source file '../../src/components/provider.ts': Error: Cannot resolve 'file' or 'directory' ../../src/components/provider.ts in /vagrant/app/node_modules/ng2-redux/lib/components

WARNING in ./~/ng2-redux/lib/components/ng-redux.js
Cannot find source file '../../src/components/ng-redux.ts': Error: Cannot resolve 'file' or 'directory' ../../src/components/ng-redux.ts in /vagrant/app/node_modules/ng2-redux/lib/components

WARNING in ./~/ng2-redux/lib/utils/shallowEqual.js
Cannot find source file '../../src/utils/shallowEqual.ts': Error: Cannot resolve 'file' or 'directory' ../../src/utils/shallowEqual.ts in /vagrant/app/node_modules/ng2-redux/lib/utils

WARNING in ./~/ng2-redux/lib/utils/wrapActionCreators.js
Cannot find source file '../../src/utils/wrapActionCreators.ts': Error: Cannot resolve 'file' or 'directory' ../../src/utils/wrapActionCreators.ts in /vagrant/app/node_modules/ng2-redux/lib/utils

The app still works. To avoid the warnings it can be simply excluded.

test: /\.js$/,
loader: 'source-map-loader',
exclude: [
  /node_modules\/ng2-redux/
]

Cheers,
Tobi

@e-schultz
Copy link
Member

@TobiasKrogh thanks for letting us know. Wondering if including the src with the npm package might be useful though for development/debugging purposes.

@TobiasKrogh
Copy link
Author

@e-schultz I basically just followed the default configuration for the source-map-loader. I am fairly new to webpack, angular2 and ng2-redux. Just wondered about the warnings. However excluding ng2-redux from this loader works fine from my point of view. Just wanted to let you know in case this has some other implications or others stumble upon it.

@sethreidnz
Copy link

sethreidnz commented Jun 3, 2016

How does one get rid of these warning when using cheap-module-source-map?

I have been using the config in this starter kit

And adding the above mentioned to the config/webpack.common.js doesn't do the trick. There is also the config/webpack.dev.js that uses the cheap-module-source-map option.. I can't find anywhere how you are supposed to exclude files this way..

These warnings are fine but then if I pass it onto another dev they might get worried!

@TobiasKrogh
Copy link
Author

@JustSayNO I looked up the mentioned starter kit and it would seem they already do such excludes for node_modules in webpack.common.js (which is merged into webpack.dev.js) and webpack.test.js

Example from webpack.common.js

      {
        test: /\.js$/,
        loader: 'source-map-loader',
        exclude: [
          // these packages have problems with their sourcemaps
          helpers.root('node_modules/rxjs'),
          helpers.root('node_modules/@angular'),
        ]
      }

You should be able to add one entry in the exclude array like helpers.root('node_modules/ng2-redux'). I shortly tested that and I do not see any warnings. Same applies of course to the webpack.test.js.

Webpack seems to recommend using the include over the exclude when possible (see Example in https://webpack.github.io/docs/configuration.html#module-loaders). In general the include / exclude works by passing one condition or an array of conditions which in turn can be path references or regular expressions.

Hope this helps.

@sethreidnz
Copy link

Yeah I tried adding that line before I made my post.. I'm not sure why its not effecting the output tbh. My loader for that looks like this:

{
  test: /\.js$/,
  loader: 'source-map-loader',
  exclude: [
    // these packages have problems with their sourcemaps
    helpers.root('node_modules/rxjs'),
    helpers.root('node_modules/@angular'),
    helpers.root('node_modules/ng2-redux')
  ]
}

SethDavenport pushed a commit to SethDavenport/ng2-redux that referenced this issue Aug 5, 2016
Suppresses some warnings from angular-cli@webpack

May also fix angular-redux#64.
@SethDavenport SethDavenport self-assigned this Aug 5, 2016
e-schultz pushed a commit that referenced this issue Aug 10, 2016
Suppresses some warnings from angular-cli@webpack

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

Successfully merging a pull request may close this issue.

4 participants