Compare commits
5 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 6657af7ca0 | |||
| e3080467c9 | |||
| e84b62f4d6 | |||
| 06c668b587 | |||
| 56fa26acc8 |
@@ -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": "7fd5e15105cef21d2b1c3da860c53c5033f66256",
|
"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"
|
||||||
|
|||||||
@@ -0,0 +1,36 @@
|
|||||||
|
import {createRequire} from "node:module";
|
||||||
|
import path from "node:path";
|
||||||
|
|
||||||
|
// Resolve build dependencies from the package's locked node_modules, not from
|
||||||
|
// the helper's own Nix-store location. This program runs only during the build.
|
||||||
|
const require = createRequire(path.join(process.cwd(), "package.json"));
|
||||||
|
const {build} = require("esbuild");
|
||||||
|
const options = JSON.parse(process.argv[2]);
|
||||||
|
const platform = new Map([
|
||||||
|
["react", "/__quixos/platform/react/v18.mjs"],
|
||||||
|
["react/jsx-runtime", "/__quixos/platform/react-jsx-runtime/v18.mjs"],
|
||||||
|
["react/jsx-dev-runtime", "/__quixos/platform/react-jsx-dev-runtime/v18.mjs"],
|
||||||
|
["@quixos/web-studio-react-runtime", "/__quixos/platform/web-studio-react-runtime/v1.mjs"],
|
||||||
|
]);
|
||||||
|
await build({...options, plugins: [{name: "quixos-browser-source", setup(api) {
|
||||||
|
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");
|
||||||
|
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}) => {
|
||||||
|
const browser = await build({entryPoints: [entry], bundle: true, write: false, outfile: "component.mjs",
|
||||||
|
format: "esm", platform: "browser", target: "es2022", metafile: true,
|
||||||
|
plugins: [{name: "quixos-platform", setup(browserApi) {
|
||||||
|
browserApi.onResolve({filter: /.*/}, ({path: name}) => platform.has(name) ? {path: platform.get(name), external: true} : undefined);
|
||||||
|
}}]});
|
||||||
|
const js = browser.outputFiles.find(file => file.path.endsWith(".mjs"));
|
||||||
|
if (!js) throw new Error("Browser source build produced no JavaScript");
|
||||||
|
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 (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` : "");
|
||||||
|
return {contents: `export default ${JSON.stringify(source)};`, loader: "js", watchFiles: Object.keys(browser.metafile.inputs)};
|
||||||
|
});
|
||||||
|
}}]});
|
||||||
@@ -539,7 +539,6 @@ EOF
|
|||||||
# An exact, compiler-produced BindingSchema JSON artifact and a backend.
|
# An exact, compiler-produced BindingSchema JSON artifact and a backend.
|
||||||
# Other language helpers can consume the same schema with their own generator/runtime.
|
# Other language helpers can consume the same schema with their own generator/runtime.
|
||||||
bindings ? null,
|
bindings ? null,
|
||||||
bindingOptions ? { },
|
|
||||||
# A dedicated entrypoint calling SDK serveMigration; never start the
|
# A dedicated entrypoint calling SDK serveMigration; never start the
|
||||||
# normal package server in the isolated migration execution boundary.
|
# normal package server in the isolated migration execution boundary.
|
||||||
migrationEntrypoint ? null,
|
migrationEntrypoint ? null,
|
||||||
@@ -593,14 +592,19 @@ EOF
|
|||||||
resources = bindingConfig.resources or [ ];
|
resources = bindingConfig.resources or [ ];
|
||||||
});
|
});
|
||||||
bindingOutput = if bindingConfig == null then "src/gen/qx.ts" else bindingConfig.output or "src/gen/qx.ts";
|
bindingOutput = if bindingConfig == null then "src/gen/qx.ts" else bindingConfig.output or "src/gen/qx.ts";
|
||||||
|
authoringCheck = builtins.fromJSON (builtins.readFile "${packageRoot}/quixos.check.json");
|
||||||
bindingOptionsFile = if bindingConfig == null then null else
|
bindingOptionsFile = if bindingConfig == null then null else
|
||||||
pkgs.writeText "qx-typescript-options.json" (builtins.toJSON (bindingConfig.options or bindingOptions));
|
pkgs.writeText "qx-typescript-options.json" (builtins.toJSON (authoringCheck.options or { }));
|
||||||
bindingCommand = if bindingConfig == null then "" else ''
|
bindingCommand = if bindingConfig == null then "" else ''
|
||||||
mkdir -p ${lib.escapeShellArg (dirOf bindingOutput)}
|
mkdir -p ${lib.escapeShellArg (dirOf bindingOutput)}
|
||||||
${bindingConfig.generator}/bin/quixos-codegen-ts \
|
${bindingConfig.generator}/bin/quixos-codegen-ts \
|
||||||
${lib.escapeShellArg (toString bindingSchema)} \
|
${lib.escapeShellArg (toString bindingSchema)} \
|
||||||
${lib.escapeShellArg bindingConfig.packageRevisionId} \
|
${lib.escapeShellArg bindingConfig.packageRevisionId} \
|
||||||
${lib.escapeShellArg bindingOutput} ${bindingOptionsFile}
|
${lib.escapeShellArg bindingOutput} ${bindingOptionsFile}
|
||||||
|
${lib.optionalString (installServer != null && descriptorPath != null) ''
|
||||||
|
${bindingConfig.generator}/bin/quixos-qx package-descriptor ${lib.escapeShellArg (toString bindingSchema)} \
|
||||||
|
${lib.escapeShellArg bindingConfig.packageRevisionId} > ${lib.escapeShellArg descriptorPath}
|
||||||
|
''}
|
||||||
'';
|
'';
|
||||||
generateBindings = pkgs.writeShellApplication {
|
generateBindings = pkgs.writeShellApplication {
|
||||||
name = "qx-generate-bindings";
|
name = "qx-generate-bindings";
|
||||||
@@ -625,7 +629,14 @@ EOF
|
|||||||
bundleCommand =
|
bundleCommand =
|
||||||
if bundle == null
|
if bundle == null
|
||||||
then ""
|
then ""
|
||||||
else ''
|
else if bundleConfig.browserSources or false then ''
|
||||||
|
${nodejs}/bin/node ${./browser-source.mjs} ${lib.escapeShellArg (builtins.toJSON {
|
||||||
|
entryPoints = [ bundleConfig.entry ]; bundle = true; platform = bundlePlatform;
|
||||||
|
target = bundleTarget; format = bundleFormat; alias = bundleAliases;
|
||||||
|
preserveSymlinks = bundleConfig.preserveSymlinks or true;
|
||||||
|
banner.js = bundleBanner; outfile = bundleOutfile;
|
||||||
|
})}
|
||||||
|
'' else ''
|
||||||
esbuild ${lib.escapeShellArg bundleConfig.entry} \
|
esbuild ${lib.escapeShellArg bundleConfig.entry} \
|
||||||
--bundle \
|
--bundle \
|
||||||
--platform=${bundlePlatform} \
|
--platform=${bundlePlatform} \
|
||||||
@@ -693,6 +704,7 @@ EOF
|
|||||||
runHook preBuild
|
runHook preBuild
|
||||||
${exportsFor (callOption buildEnv)}
|
${exportsFor (callOption buildEnv)}
|
||||||
${bindingCommand}
|
${bindingCommand}
|
||||||
|
${lib.optionalString (bindingConfig != null && bundle != null) "${bindingConfig.generator}/bin/quixos-qx bundle-policy src"}
|
||||||
${lib.optionalString (bindingConfig != null) "yarn exec tsc --noEmit"}
|
${lib.optionalString (bindingConfig != null) "yarn exec tsc --noEmit"}
|
||||||
${lib.optionalString (bindingConfig != null) "cp ${lib.escapeShellArg bindingOutput} .qx-checked-bindings"}
|
${lib.optionalString (bindingConfig != null) "cp ${lib.escapeShellArg bindingOutput} .qx-checked-bindings"}
|
||||||
${buildCommand}
|
${buildCommand}
|
||||||
|
|||||||
Reference in New Issue
Block a user