Can't specify an object for library for differing names per targets
See original GitHub issueAs per the documentation:
https://webpack.js.org/configuration/output/#outputlibrary
// Since webpack 3.1.0, you may specify an object for library for differing names per targets:
module.exports = {
//...
output: {
library: {
root: 'MyLibrary',
amd: 'my-library',
commonjs: 'my-common-library',
},
libraryTarget: 'umd',
},
};
libraryTarget: 'system'
However, using
library: {
root: 'MyLibrary',
amd: 'my-library',
commonjs: 'my-common-library',
},
Throws an error with AssignLibraryPlugin: https://github.com/webpack/webpack/blob/master/lib/library/AssignLibraryPlugin.js#L126
Library name must be a string, string array or unset
It looks like the normalized library options passed into parseOptions is merging everything under name:
{
type: 'this',
auxiliaryComment: undefined,
export: undefined,
name: {
amd: 'my-library',
commonjs: 'my-common-library',
root: 'MyLibrary'
},
umdNamedDefine: undefined
}
Note that it’s a bit strange that the type is this
, even though I pass libraryTarget: 'umd'
As a result it ends up going to AssignLibraryPlugin:
Other relevant information:
webpack version:
Node.js version: v12.16.1
Operating System: Linux
Issue Analytics
- State:
- Created 2 years ago
- Comments:6 (4 by maintainers)
Top Results From Across the Web
Object Libraries - propagate target_link_libraries to final target
Linking PUBLIC ly to an object library can't propagate the object files to all dependents or they'd each get copies and duplicate symbols....
Read more >target_link_libraries — CMake 3.25.1 Documentation
Specify libraries or flags to use when linking a given target and/or its dependents. Usage requirements from linked library targets will be propagated....
Read more >CMake link to external library - Stack Overflow
I would simply like to add an alternative to his answer: You could add an "imported" library target, instead of a link-directory.
Read more >Save Restore Object (SAVRSTOBJ) - IBM
The objects can be restored to the same library or a different library. ... The contents of a save file can be saved...
Read more >Using LD, the GNU linker - Command Line Options
Thus the filter object can be used to select a subset of the symbols provided by the object name . Some older linkers...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Just updating, it was 100% an issue in our repo, we had been mutating somewhere where we shouldn’t have, and a stray config ended up with type: ‘this’ instead of type: ‘umd’, which branched to the wrong plugin (in this case, AssignLibraryPlugin).
Will be better about following the template and reproducer guidelines next time!
Looks like I wasn’t able to create a minimal reproducer, so there may be other configuration issues I have to figure out first, sorry about that! Will re-open if I’m able to distill the right context