Skip to content

Commit

Permalink
fix: give unique filename for each demo
Browse files Browse the repository at this point in the history
  • Loading branch information
jeffwcx committed Jun 13, 2024
1 parent 7fb3c62 commit 04d45f9
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/client/theme-api/useLiveDemo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ export const useLiveDemo = (
if (renderOpts?.compile) {
try {
entryFileCode = await renderOpts.compile(entryFileCode, {
filename: entryFileName,
filename: `${id}-${entryFileName}`,
});
} catch (error: any) {
setError(error);
Expand Down
2 changes: 1 addition & 1 deletion suites/preset-vue/lib/compiler.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ ${oe.replace(/\nexport (function|const) render/,"$1 render")}
console.warn("Custom preprocessors for <template> and <style> are not supported in the Codeblock.")`),E.styles.some($=>$.module)&&(N=!0,I+=`
console.warn("<style module> is not supported in the the Codeblock.")`);let M=E.script&&E.script.lang||E.scriptSetup&&E.scriptSetup.lang,j=E.styles.some($=>$.scoped),R=a(u,E,j,M||"");if(Array.isArray(R))return R;I+=`
${R}`,j&&(I+=`
${lt}.__scopeId = ${JSON.stringify(`data-v-${u}`)};`);let k="";if(!N){let $=n(u,E);if(Array.isArray($))return $;k=$;}return {js:I,css:k}}return {toCommonJS:i,transformTS:s,compileSFC:o}}var{compileSFC:A_,transformTS:v_,toCommonJS:I_}=yd({babel:{transformSync(...t){return typeof window!==void 0&&"Babel"in window?Babel.transform(...t):(console.error("@babel/standablone is loading!"),null)}},availablePlugins:{"vue-jsx":pd}});function w_(t,{filename:e}){let{lang:r}=No(e);if(["js","jsx","ts","tsx"].includes(r))return v_(t,e,{lang:r,presets:[["env",{modules:"cjs"}]]});let i=(0, md.default)(t),s=A_({id:i,filename:e,code:t});if(Array.isArray(s))throw s[0];let{js:a,css:n}=s;return n&&(a+=`
${lt}.__scopeId = ${JSON.stringify(`data-v-${u}`)};`);let k="";if(!N){let $=n(u,E);if(Array.isArray($))return $;k=$;}return {js:I,css:k}}return {toCommonJS:i,transformTS:s,compileSFC:o}}var{compileSFC:A_,transformTS:v_,toCommonJS:I_}=yd({babel:{transformSync(...t){return typeof window!==void 0&&"Babel"in window?Babel.transform(...t):(console.error("@babel/standablone is loading!"),null)}},availablePlugins:{"vue-jsx":pd}});function w_(t,{filename:e}){let{lang:r}=No(e);if(["js","jsx","ts","tsx"].includes(r))return v_(t,e,{lang:r,presets:[["env",{modules:"cjs"}]]});let i=(0, md.default)(e),s=A_({id:i,filename:e,code:t});if(Array.isArray(s))throw s[0];let{js:a,css:n}=s;return n&&(a+=`
${lt}.__css__ = ${JSON.stringify(n)};`),a+=`
${lt}.__id__ = "${i}";
export default ${lt};`,I_(a)?.code||""}/*! Bundled license information:
Expand Down
2 changes: 1 addition & 1 deletion suites/preset-vue/src/compiler/browser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export default function compile(
presets: [['env', { modules: 'cjs' }]],
});
}
const id = hashId(code);
const id = hashId(filename);
const compiled = compileSFC({ id, filename, code });

if (Array.isArray(compiled)) {
Expand Down

0 comments on commit 04d45f9

Please sign in to comment.