temp POC solution to load "external" extensions from public folder

This commit is contained in:
Mads Rasmussen
2022-06-07 11:52:58 +02:00
parent 5d82983d25
commit f401ce9743
6 changed files with 12 additions and 6 deletions

View File

@@ -1 +0,0 @@
// TODO: write description

View File

@@ -0,0 +1,5 @@
# The App_Plugins Mock Directory
This App_Plugins directory is a mock for any external extensions/packages files added to the CMS. These files are referenced through manifests.
A [mocked server request](../../src/mocks/domains/manifests.handlers.ts) is made when the app starts to fetch manifest files.

View File

@@ -7,13 +7,14 @@ export function loadExtension(manifest: UmbExtensionManifest): Promise<object |
// TODO: verify if this is acceptable solution.
if (typeof manifest.js === 'string') {
return import(/* @vite-ignore */ manifest.js);
/*
// TODO: change this back to dynamic import after POC. Vite complains about the dynamic imports in the public folder but doesn't include the temp app_plugins folder in the final build.
// return import(/* @vite-ignore */ manifest.js);
return new Promise((resolve, reject) => {
const script = document.createElement('script');
script.type = 'text/javascript';
//script.charset = 'utf-8';
script.async = true;
script.type = 'module';
script.src = manifest.js as string;
script.onload = function () {
resolve(null);
@@ -23,7 +24,6 @@ export function loadExtension(manifest: UmbExtensionManifest): Promise<object |
};
document.body.appendChild(script);
}) as Promise<null>;
*/
}
console.log('-- Extension does not have any referenced JS');

View File

@@ -12,7 +12,8 @@ export const handlers = [
type: 'section',
alias: 'My.Section.Custom',
name: 'Custom Section',
js: '/APP_PLUGINS/section.js',
js: '/App_Plugins/section.js',
elementName: 'my-section-custom',
meta: {
pathname: 'my-custom',
weight: 1,
@@ -22,7 +23,8 @@ export const handlers = [
type: 'propertyEditorUI',
alias: 'My.PropertyEditorUI.Custom',
name: 'My Custom Property Editor UI',
js: '/APP_PLUGINS/property-editor.js',
js: '/App_Plugins/property-editor.js',
elementName: 'my-property-editor-ui-custom',
meta: {
icon: 'document',
group: 'common',