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

Combination of devtool: 'source-map' and library: ['Foo', '[name]'] throws error #6634

Closed
tmilloff opened this issue Mar 1, 2018 · 8 comments · Fixed by #6641
Closed

Combination of devtool: 'source-map' and library: ['Foo', '[name]'] throws error #6634

tmilloff opened this issue Mar 1, 2018 · 8 comments · Fixed by #6641

Comments

@tmilloff
Copy link
Contributor

tmilloff commented Mar 1, 2018

Do you want to request a feature or report a bug?
Bug

What is the current behavior?
With the following configuration, webpack throws the following error

module.exports = {
  devtool: 'source-map',
  output: {
    library: ['Foo', '[name]']
  }
}
webpack-bug-test$ npm run build                                                                                                                                                                                 

> webpack-bug-test@1.0.0 build /Users/jason/Projects/webpack-bug-test
> webpack

/Users/jason/Projects/webpack-bug-test/node_modules/webpack-cli/bin/webpack.js:439
                                throw err;
                                ^

ValidationError: SourceMap DevTool Plugin Invalid Options

options.namespace should be string

If the current behavior is a bug, please provide the steps to reproduce.
The proceeding config is enough to produce the issue.

What is the expected behavior?
The proceeding config should build without issue, as was the case with versions prior to 4.

If this is a feature request, what is motivation or use case for changing the behavior?
N/A

Please mention other relevant information such as the browser version, Node.js version, webpack version, and Operating System.
4.0.1 (Previously working on 3.8.1)

@tmilloff
Copy link
Contributor Author

tmilloff commented Mar 1, 2018

After some investigation, it seems the error is originally thrown in lib/SourceMapDevToolPlugin.js:59. It seems that options.namespace is expected to be a string, but is getting the value of output.library which is an array in this case. As the docs state that an array is an acceptable value of output.library, perhaps there is a missing conversion step before this line is reached?

@montogeek
Copy link
Member

@tmilloff Where does it says that library supports an array? I couldn't find any reference in this page https://webpack.js.org/guides/author-libraries/

@tmilloff
Copy link
Contributor Author

tmilloff commented Mar 1, 2018

Ah, you're right. It appears it's not actually in the documentation, but it is in this examples page https://github.com/webpack/webpack/tree/master/examples/multi-part-library

@montogeek
Copy link
Member

Yep, just saw it, Can you try adding filename option: filename: "MyLibrary.[name].js",?

@tmilloff
Copy link
Contributor Author

tmilloff commented Mar 1, 2018

Just tried it. I'm still seeing the same error with that addition.

@sokra
Copy link
Member

sokra commented Mar 1, 2018

Array for library is valid (it does mean Foo.[name]).
When passing library as namespace we should use [].concat(output.library).join("."). Somebody wants to send a PR?

@lorefnon
Copy link

I am still facing this issue when I have a library config with different names per target:

This configuration from example here :

output: {
  library: {
    root: "MyLibrary",
    amd: "my-library",
    commonjs: "my-common-library"
  },
  libraryTarget: "umd"
}

Throws the same error for me:

ValidationError: SourceMap DevTool Plugin Invalid Options

options.namespace should be string

Would you like me to create a new issue for this ?

@alexander-akait
Copy link
Member

@lorefnon check you SourceMap DevTool Plugin configuration

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

Successfully merging a pull request may close this issue.

6 participants