Skip to content

Commit fec057b

Browse files
feat: make it possible to add modules for use in templates
1 parent d8b125e commit fec057b

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

js/src/esmVueTemplate.js

+9
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,15 @@ export function getAsyncComponent(sfcStr, mixin) {
4040
return Vue.defineAsyncComponent(() => compileSfc(sfcStr, mixin));
4141
}
4242

43+
export async function addModule(name, module) {
44+
await init();
45+
importShim.addImportMap({
46+
"imports": {
47+
[name]: expose(module),
48+
}
49+
})
50+
}
51+
4352
let _init_promise = null;
4453
async function init() {
4554
if (!_init_promise) {

js/src/index.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,6 @@ export { TemplateModel } from './Template';
77
export { ForceLoadModel } from './ForceLoad';
88
export { vueRender } from './VueRenderer';
99
export { VueComponentModel } from './VueComponentModel';
10-
export { getAsyncComponent } from './esmVueTemplate';
10+
export { getAsyncComponent, addModule } from './esmVueTemplate';
1111

1212
export const { version } = require('../package.json'); // eslint-disable-line global-require

0 commit comments

Comments
 (0)