fix hmr-static! misc

This commit is contained in:
Seth Trowbridge 2025-10-09 17:19:24 -04:00
parent 102f8a74d2
commit 93d953877e
3 changed files with 22 additions and 21 deletions

View File

@ -1,8 +1,5 @@
import ReactDOM from "react-dom/client";
import React from "react";
export function App(){
const [countGet, countSet] = React.useState(2);
@ -17,9 +14,7 @@ export const Other =()=>{
return <p>other app component</p>
}
export function Root()
export default function Root()
{
return <div><h1>rooted</h1><App/><Other/></div>
}
ReactDOM.createRoot(document.body).render(<Root/>);

View File

@ -64,11 +64,11 @@ const findNextExport =(inFile:string, inIndex=0, inLocal:Array<string>, inForeig
}
else
{
const members = inFile.substring(nextCharInd+1, endBracketInd).replace(/\s/g, '');
const members = inFile.substring(nextCharInd+1, endBracketInd);
members.split(",").forEach(part=>
{
const renamed = part.split(" as ");
inLocal.push(renamed[1] || renamed[0]);
inLocal.push((renamed[1] || renamed[0]).replace(/\s/g, ''));
});
}
@ -130,15 +130,16 @@ ${ foreign.join(";\n") }`;
};
// ///////////////////////////////////////////////
// const [local, global] = Exports(`
// // export in comment
// export * from "react";
// const fakeexport =()=>{};
// export{ thing1 as remapped, thing2}
// export { thing1 as remapped, thing2} from 'React';
// export
// export const func=()=>{};
// `);
//
// console.log(local, global);
///////////////////////////////////////////////
const [local, global] = ModuleShape(`
// export in comment
export { A as B }
export * from "react";
const fakeexport =()=>{};
export{ thing1 as remapped, thing2}
export { thing1 as remapped, thing2} from 'React';
export
export const func=()=>{};
`);
console.log(local);

View File

@ -5,6 +5,11 @@
<title>Document</title>
</head>
<body>
<script type="module" src="/app.tsx"></script>
<script type="module">
import ReactDOM from "react-dom/client";
import React from "react";
import App from "/app.tsx";
ReactDOM.createRoot(document.body).render(React.createElement(App));
</script>
</body>
</html>