Compare commits
2 Commits
e84b62f4d6
...
6657af7ca0
| Author | SHA1 | Date | |
|---|---|---|---|
| 6657af7ca0 | |||
| e3080467c9 |
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"version": 1,
|
"version": 1,
|
||||||
"sourceRepo": "https://gitea-external.egads.tutti.syntaxblitz.net/quixos/quixos",
|
"sourceRepo": "https://gitea-external.egads.tutti.syntaxblitz.net/quixos/quixos",
|
||||||
"sourceCommit": "fc13e9b8411c2210b12db5e558e2b4fa7785505e",
|
"sourceCommit": "8484d99fcf78a49341a17597bc62211e5f1807dd",
|
||||||
"sourcePath": "quixos-instance/quixos-nix-helpers",
|
"sourcePath": "quixos-instance/quixos-nix-helpers",
|
||||||
"exportName": "quixos-nix-helpers",
|
"exportName": "quixos-nix-helpers",
|
||||||
"mirrorRemote": "https://gitea-external.egads.tutti.syntaxblitz.net/quixos/quixos-nix-helpers.git"
|
"mirrorRemote": "https://gitea-external.egads.tutti.syntaxblitz.net/quixos/quixos-nix-helpers.git"
|
||||||
|
|||||||
+5
-3
@@ -13,9 +13,11 @@ const platform = new Map([
|
|||||||
["@quixos/web-studio-react-runtime", "/__quixos/platform/web-studio-react-runtime/v1.mjs"],
|
["@quixos/web-studio-react-runtime", "/__quixos/platform/web-studio-react-runtime/v1.mjs"],
|
||||||
]);
|
]);
|
||||||
await build({...options, plugins: [{name: "quixos-browser-source", setup(api) {
|
await build({...options, plugins: [{name: "quixos-browser-source", setup(api) {
|
||||||
api.onResolve({filter: /\?browser-source$/}, ({path: specifier, resolveDir}) => {
|
api.onResolve({filter: /\?browser-source$/}, async ({path: specifier, resolveDir}) => {
|
||||||
if (!specifier.startsWith("./") && !specifier.startsWith("../")) throw new Error("Browser source imports must name a relative compiled module");
|
if (!specifier.startsWith("./") && !specifier.startsWith("../")) throw new Error("Browser source imports must name a relative compiled module");
|
||||||
return {path: path.resolve(resolveDir, specifier.slice(0, -"?browser-source".length)), namespace: "browser-source"};
|
const resolved = await api.resolve(specifier.slice(0, -"?browser-source".length), {resolveDir, kind: "import-statement"});
|
||||||
|
if (resolved.errors.length) return {errors: resolved.errors};
|
||||||
|
return {path: resolved.path, namespace: "browser-source"};
|
||||||
});
|
});
|
||||||
api.onLoad({filter: /.*/, namespace: "browser-source"}, async ({path: entry}) => {
|
api.onLoad({filter: /.*/, namespace: "browser-source"}, async ({path: entry}) => {
|
||||||
const browser = await build({entryPoints: [entry], bundle: true, write: false, outfile: "component.mjs",
|
const browser = await build({entryPoints: [entry], bundle: true, write: false, outfile: "component.mjs",
|
||||||
@@ -26,7 +28,7 @@ await build({...options, plugins: [{name: "quixos-browser-source", setup(api) {
|
|||||||
const js = browser.outputFiles.find(file => file.path.endsWith(".mjs"));
|
const js = browser.outputFiles.find(file => file.path.endsWith(".mjs"));
|
||||||
if (!js) throw new Error("Browser source build produced no JavaScript");
|
if (!js) throw new Error("Browser source build produced no JavaScript");
|
||||||
const css = browser.outputFiles.find(file => file.path.endsWith(".css"));
|
const css = browser.outputFiles.find(file => file.path.endsWith(".css"));
|
||||||
if (css && Object.values(browser.metafile.outputs).some(output => output.exports.includes("styles"))) throw new Error("Use either imported CSS or an explicit styles export, not both");
|
if (css && Object.values(browser.metafile.outputs).some(output => output.exports?.includes("styles"))) throw new Error("Use either imported CSS or an explicit styles export, not both");
|
||||||
if (browser.outputFiles.some(file => !file.path.endsWith(".mjs") && !file.path.endsWith(".css"))) throw new Error("Browser assets must be embedded, not emitted as unserved files");
|
if (browser.outputFiles.some(file => !file.path.endsWith(".mjs") && !file.path.endsWith(".css"))) throw new Error("Browser assets must be embedded, not emitted as unserved files");
|
||||||
const source = js.text + (css ? `\nexport const styles = ${JSON.stringify(css.text)};\n` : "");
|
const source = js.text + (css ? `\nexport const styles = ${JSON.stringify(css.text)};\n` : "");
|
||||||
return {contents: `export default ${JSON.stringify(source)};`, loader: "js", watchFiles: Object.keys(browser.metafile.inputs)};
|
return {contents: `export default ${JSON.stringify(source)};`, loader: "js", watchFiles: Object.keys(browser.metafile.inputs)};
|
||||||
|
|||||||
Reference in New Issue
Block a user