Skip to content

Commit

Permalink
Merge branch 'develop' into i18n/live-codes/daisyui-starter
Browse files Browse the repository at this point in the history
  • Loading branch information
hatemhosny authored Mar 6, 2025
2 parents b071549 + 725e023 commit c714d09
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions src/livecodes/result/result-page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,7 @@ export const createResultPage = async ({
hasDefaultExport(code.script.compiled) &&
!hasCustomJsxRuntime(code.script.content || '', config) &&
!importFromScript;
const hasPreact = getImports(code.script.compiled).find((mod) => mod === 'preact');

let compilerImports = {};

Expand Down Expand Up @@ -274,8 +275,9 @@ export const createResultPage = async ({

const styleExtension = getLanguageExtension(code.style.language);

const externalModules =
jsxRuntime === reactRuntime
const externalModules = hasPreact
? 'preact'
: jsxRuntime === reactRuntime
? 'react,react-dom'
: [config.markup.language, config.script.language].find((lang) => lang.startsWith('vue'))
? 'vue'
Expand Down Expand Up @@ -349,9 +351,16 @@ export const createResultPage = async ({
delete userImports[userKey as keyof typeof userImports];
});

// avoid duplicate react instances
// avoid duplicate (p)react instances
const reactImports = (() => {
if (!externalModules) return {};
if (hasPreact) {
const preactUrl = modulesService.getModuleUrl('preact');
return {
preact: preactUrl,
'preact/': preactUrl + '/',
};
}
const reactUrl = modulesService.getModuleUrl('react');
const reactDomUrl = modulesService.getModuleUrl('react-dom');
return {
Expand Down

0 comments on commit c714d09

Please sign in to comment.