mirror of
https://github.com/elastic/kibana.git
synced 2025-04-23 17:28:26 -04:00
[uiBundlerEnv] add a method for exporting global import aliases for special cases
This commit is contained in:
parent
b841c917f9
commit
4969d660df
3 changed files with 11 additions and 18 deletions
|
@ -67,14 +67,11 @@ export default (kibana) => {
|
|||
});
|
||||
},
|
||||
|
||||
modules: {
|
||||
__globalImportAliases__: {
|
||||
ng_mock$: fromRoot('src/core_plugins/dev_mode/public/ng_mock'),
|
||||
'angular-mocks$': require.resolve('./webpackShims/angular-mocks'),
|
||||
fixtures: fromRoot('src/fixtures'),
|
||||
test_utils: fromRoot('src/test_utils'),
|
||||
'angular-mocks': {
|
||||
path: require.resolve('angular-mocks'),
|
||||
imports: 'angular'
|
||||
},
|
||||
}
|
||||
}
|
||||
});
|
||||
|
|
2
src/core_plugins/tests_bundle/webpackShims/angular-mocks.js
vendored
Normal file
2
src/core_plugins/tests_bundle/webpackShims/angular-mocks.js
vendored
Normal file
|
@ -0,0 +1,2 @@
|
|||
require('angular');
|
||||
require('../../../../node_modules/angular-mocks/angular-mocks.js');
|
|
@ -77,6 +77,13 @@ module.exports = class UiBundlerEnv {
|
|||
return (plugin, spec) => {
|
||||
for (const re of arr(spec)) this.addNoParse(re);
|
||||
};
|
||||
|
||||
case '__globalImportAliases__':
|
||||
return (plugin, spec) => {
|
||||
for (const key of Object.keys(spec)) {
|
||||
this.aliases[key] = spec[key];
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -91,17 +98,4 @@ module.exports = class UiBundlerEnv {
|
|||
addNoParse(regExp) {
|
||||
this.noParse.push(regExp);
|
||||
}
|
||||
|
||||
claim(id, pluginId) {
|
||||
const owner = pluginId ? `Plugin ${pluginId}` : 'Kibana Server';
|
||||
|
||||
// TODO(spalger): we could do a lot more to detect colliding module defs
|
||||
const existingOwner = this.aliasOwners[id] || this.aliasOwners[`${id}$`];
|
||||
|
||||
if (existingOwner) {
|
||||
throw new TypeError(`${owner} attempted to override export "${id}" from ${existingOwner}`);
|
||||
}
|
||||
|
||||
this.aliasOwners[id] = owner;
|
||||
}
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue