@tothalex/nulljs 0.0.57 → 0.0.58
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli.js +4 -70
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -440,69 +440,7 @@ var init_server = __esm(() => {
|
|
|
440
440
|
import { basename, extname } from "path";
|
|
441
441
|
import react from "@vitejs/plugin-react";
|
|
442
442
|
import tailwindcss from "@tailwindcss/vite";
|
|
443
|
-
var
|
|
444
|
-
const entry = basename(filePath, extname(filePath));
|
|
445
|
-
const virtualPrefix = `virtual:config/${entry}.tsx`;
|
|
446
|
-
return {
|
|
447
|
-
name: "nulljs-config-plugin",
|
|
448
|
-
apply: "build",
|
|
449
|
-
config: async (config, { command }) => {
|
|
450
|
-
if (command !== "build") {
|
|
451
|
-
return config;
|
|
452
|
-
}
|
|
453
|
-
return {
|
|
454
|
-
build: {
|
|
455
|
-
ssr: true,
|
|
456
|
-
rollupOptions: {
|
|
457
|
-
input: {
|
|
458
|
-
[entry]: virtualPrefix
|
|
459
|
-
},
|
|
460
|
-
external: ["react", "react/jsx-runtime"],
|
|
461
|
-
output: {
|
|
462
|
-
entryFileNames: "[name].js"
|
|
463
|
-
},
|
|
464
|
-
preserveEntrySignatures: "strict"
|
|
465
|
-
}
|
|
466
|
-
}
|
|
467
|
-
};
|
|
468
|
-
},
|
|
469
|
-
resolveId: (id) => {
|
|
470
|
-
if (id === virtualPrefix) {
|
|
471
|
-
return id;
|
|
472
|
-
}
|
|
473
|
-
return null;
|
|
474
|
-
},
|
|
475
|
-
load: (id) => {
|
|
476
|
-
if (id === virtualPrefix) {
|
|
477
|
-
const script = `
|
|
478
|
-
import { config } from "${filePath.replace(/\\/g, "\\\\")}";
|
|
479
|
-
|
|
480
|
-
export default config;
|
|
481
|
-
`;
|
|
482
|
-
return script;
|
|
483
|
-
}
|
|
484
|
-
return null;
|
|
485
|
-
},
|
|
486
|
-
transform: (code, id) => {
|
|
487
|
-
if (id === filePath) {
|
|
488
|
-
const configMatch = code.match(/export const config = \{[^}]*\};/);
|
|
489
|
-
return configMatch ? { code: configMatch[0], map: null } : null;
|
|
490
|
-
}
|
|
491
|
-
}
|
|
492
|
-
};
|
|
493
|
-
}, spaConfigConfig = (filePath) => {
|
|
494
|
-
return {
|
|
495
|
-
logLevel: "error",
|
|
496
|
-
plugins: [
|
|
497
|
-
jsConfig({
|
|
498
|
-
filePath
|
|
499
|
-
})
|
|
500
|
-
],
|
|
501
|
-
build: {
|
|
502
|
-
outDir: "/tmp"
|
|
503
|
-
}
|
|
504
|
-
};
|
|
505
|
-
}, jsSpa = ({ filePath }) => {
|
|
443
|
+
var jsSpa = ({ filePath }) => {
|
|
506
444
|
const entry = basename(filePath, extname(filePath));
|
|
507
445
|
const virtualPrefix = `virtual:spa/${entry}.tsx`;
|
|
508
446
|
return {
|
|
@@ -520,7 +458,9 @@ var jsConfig = ({ filePath }) => {
|
|
|
520
458
|
},
|
|
521
459
|
external: ["cloud"],
|
|
522
460
|
output: {
|
|
523
|
-
entryFileNames: "[name].js"
|
|
461
|
+
entryFileNames: "[name].js",
|
|
462
|
+
chunkFileNames: "[name]-[hash].js",
|
|
463
|
+
assetFileNames: "[name]-[hash][extname]"
|
|
524
464
|
}
|
|
525
465
|
}
|
|
526
466
|
},
|
|
@@ -725,14 +665,8 @@ var deployedHashes, clearDeployCache = () => {
|
|
|
725
665
|
return { deployed: true, skipped: false };
|
|
726
666
|
}, deployReact = async (filePath, privateKey, apiUrl) => {
|
|
727
667
|
const fileName = basename2(filePath);
|
|
728
|
-
const configResult = await build(spaConfigConfig(filePath));
|
|
729
|
-
const configOutput = configResult.output.find((output) => output.type === "chunk" && output.fileName === "index.js");
|
|
730
|
-
if (!configOutput) {
|
|
731
|
-
throw new Error("Config build failed: config file not found in output");
|
|
732
|
-
}
|
|
733
668
|
const result = await build(spaClientConfig(filePath));
|
|
734
669
|
const assets3 = [];
|
|
735
|
-
assets3.push({ fileName: "config.js", code: configOutput.code });
|
|
736
670
|
for (const output of result.output) {
|
|
737
671
|
if (output.type === "chunk") {
|
|
738
672
|
assets3.push({ fileName: output.fileName, code: output.code });
|