-
-
Notifications
You must be signed in to change notification settings - Fork 9.1k
Closed
Description
Bug report
What is the current behavior?
webpack 5
config:
output: {
filename: 'index.js',
libraryTarget: 'commonjs2',
library: 'talkable-ui-kit',
},
import { UIStaffBadge } from 'talkable-ui-kit'
console.log('UIStaffBadge', UIStaffBadge);
UIStaffBadge undefined
dist output
module.exports["talkable-ui-kit"]=function(){var e={310:function(e,t,n){"use strict";n.r(t),n.d(t,{BodyD:function(){return va},BodyM:function(){return ga},BodyS:function(){return ba},H1:function(){return pa},H2
What is the expected behavior?
webpack 4
config:
output: {
filename: 'index.js',
libraryTarget: 'commonjs2',
library: 'talkable-ui-kit',
},
import { UIStaffBadge } from 'talkable-ui-kit'
console.log('UIStaffBadge', UIStaffBadge);
UIStaffBadge ƒ dt(e) {
dist output:
module.exports=function(e){var t={};function n(a){if(t[a])return t[a].exports;var r=t[a]={i:a,l:!1,exports:{}};return e[a].call(r.exports,r,r.exports,n)
Other relevant information:
webpack version: 5.2.0
Node.js version: 14.14.0
Operating System: macOS
Additional tools: yarn 1.22.10
UPD:
remove library
field fixed that, updated config:
output: {
filename: 'index.js',
libraryTarget: 'commonjs2',
},
the documentation says:
Note that output.library is omitted, thus it is not required for this particular output.libraryTarget.
https://webpack.js.org/configuration/output/#module-definition-systems
Looks like library
key should be ignored if commonjs2
is used