Skip to content
This repository was archived by the owner on Mar 21, 2025. It is now read-only.

Commit b82dc47

Browse files
fix(requires): require array doesn't have options
allows to add objects or string in the require array in configuration object
1 parent c4918fb commit b82dc47

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

src/collectors.js

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,21 @@ export const setters = function () {
1717

1818
export const requires = function () {
1919
config.require.forEach(value => {
20-
if (typeof value !== 'string') {
20+
if (typeof value !== 'string' && typeof value !== 'object') {
2121
throw new Error(
2222
'[vue-analytics] Wrong configuration in the plugin options. \n' +
23-
'The "require" array requires each item to be a string.'
23+
'The "require" array requires each item to be a string or to have a "name" and an "options" property.'
2424
)
2525
}
2626

27-
_require(value)
27+
const pluginName = value.name || value
28+
29+
if (value.options) {
30+
_require(pluginName, value.options)
31+
return
32+
}
33+
34+
_require(pluginName)
2835
})
2936
}
3037

0 commit comments

Comments
 (0)