Skip to content

Commit 5da2679

Browse files
Add more descriptive library name message
1 parent c9fd311 commit 5da2679

2 files changed

Lines changed: 14 additions & 1 deletion

File tree

lib/DrupalLibrariesPlugin.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ class DrupalLibrariesPlugin {
115115
const metadata = new DrupalLibraryMetadata(libraryName, chunk)
116116

117117
if (entries[metadata.name]) {
118-
throw new DrupalLibraryMetadata.KeyCollisionError('Two webpack chunks resulted in the same library name.')
118+
throw new DrupalLibraryMetadata.KeyCollisionError(`Two webpack chunks resulted in the same library name: "${metadata.name}"`)
119119
}
120120

121121
const promises = []

test/collision.test.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
const path = require('path'),
2+
runWebpack = require('./lib/webpack-wrapper')
3+
4+
test('Stops the webpack build if two chunks generate the same library name', async () => {
5+
await expect(
6+
runWebpack({
7+
entry: {
8+
'a': path.resolve(__dirname, './fixtures/a.es6.js'),
9+
'b': path.resolve(__dirname, './fixtures/b.es6.js'),
10+
},
11+
}, { nameGenerator: chunk => 'test' })
12+
).rejects.toEqual(new Error('Two webpack chunks resulted in the same library name: "test"'))
13+
})

0 commit comments

Comments
 (0)