use an inline esm instead

This commit is contained in:
Norbert de Langen 2022-11-17 14:40:10 +01:00
parent 7743017cd0
commit 7dc6abf10c
No known key found for this signature in database
GPG Key ID: FD0E78AF9A837762
2 changed files with 7 additions and 18 deletions

View File

@ -41,7 +41,12 @@
<% } %>
</script>
<% } %>
<script id="storybook-script" type="module" src="sb-preview/index.mjs" data-files="<%= htmlWebpackPlugin.files.js.join(', ') %>"></script>
<script type="module">
import './sb-preview/index.mjs';
<% htmlWebpackPlugin.files.js.forEach(file => { %>
import './<%= file %>';
<% }); %>
</script>
</body>
</html>

View File

@ -21,19 +21,3 @@ import * as STORE from './store';
(globalThis as any).__STORYBOOK_MODULE_CORE_EVENTS__ = CORE_EVENTS;
(globalThis as any).__STORYBOOK_MODULE_PREVIEW_WEB__ = PREVIEW_WEB;
(globalThis as any).__STORYBOOK_MODULE_STORE__ = STORE;
const element = document.getElementById('storybook-script');
if (element) {
const { files } = element.dataset;
if (files) {
const sources = files.split(',').map((file) => file.trim());
sources.forEach((source) => {
const imported = document.createElement('script');
imported.src = source;
document.body.append(imported);
});
}
}