mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-04 02:14:01 +00:00
refactor: separate standalone Vite wiring and provider middleware
This commit is contained in:
1 parent
493acfc6aa
commit
8de1018c21
35 files changed
+8078
-7919
No files matched your search
@@ -3,7 +3,7 @@ import path from 'node:path';
|
||||
import { fileURLToPath, pathToFileURL } from 'node:url';
|
||||
import { build, normalizePath } from 'vite';
|
||||
|
||||
/** Build each browser export group and reject imports outside its declared ownership. */
|
||||
/** Build each browser or Node export group and reject imports outside its declared ownership. */
|
||||
export async function checkPackageBoundaries(root) {
|
||||
root = await realpath(root);
|
||||
const readJson = async (name) =>
|
||||
@@ -24,6 +24,10 @@ export async function checkPackageBoundaries(root) {
|
||||
}
|
||||
const reports = [];
|
||||
for (const [name, group] of Object.entries(groups)) {
|
||||
const node = group.runtime === 'node';
|
||||
if (group.runtime && !['browser', 'node'].includes(group.runtime)) {
|
||||
throw new Error(`Invalid boundary runtime: ${name}`);
|
||||
}
|
||||
if (
|
||||
!Array.isArray(group.modules) ||
|
||||
!group.modules.length ||
|
||||
@@ -55,15 +59,20 @@ export async function checkPackageBoundaries(root) {
|
||||
for (const external of group.external) {
|
||||
if (
|
||||
!Object.hasOwn(pkg.dependencies || {}, external) &&
|
||||
!Object.hasOwn(pkg.peerDependencies || {}, external)
|
||||
!Object.hasOwn(pkg.peerDependencies || {}, external) &&
|
||||
!(node && Object.hasOwn(pkg.devDependencies || {}, external))
|
||||
) {
|
||||
throw new Error(
|
||||
`Boundary external must be a declared runtime dependency: ${external}`,
|
||||
`Boundary external must be a declared dependency for its runtime: ${external}`,
|
||||
);
|
||||
}
|
||||
}
|
||||
const input = group.exports.map((key) => {
|
||||
const target = pkg.exports[key];
|
||||
const declaration = pkg.exports[key];
|
||||
const target = node ? declaration?.node : declaration;
|
||||
if (node && (typeof declaration !== 'object' || Object.keys(declaration).join() !== 'node')) {
|
||||
throw new Error(`Node export must have only a node condition: ${key}`);
|
||||
}
|
||||
if (
|
||||
typeof target !== 'string' ||
|
||||
!target.startsWith('./') ||
|
||||
@@ -79,6 +88,7 @@ export async function checkPackageBoundaries(root) {
|
||||
configFile: false,
|
||||
envFile: false,
|
||||
publicDir: false,
|
||||
ssr: node ? { noExternal: true } : undefined,
|
||||
logLevel: 'silent',
|
||||
plugins: [
|
||||
{
|
||||
@@ -94,6 +104,7 @@ export async function checkPackageBoundaries(root) {
|
||||
},
|
||||
],
|
||||
build: {
|
||||
ssr: node,
|
||||
lib: { entry: input, formats: ['es'] },
|
||||
write: false,
|
||||
minify: false,
|
||||
|
||||
@@ -226,8 +226,8 @@ if [[ ! -f "src/data/cctv.js" ]]; then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if ! grep -q "dataManager.register(cctvLayer)" src/editions/local/data.js; then
|
||||
echo "error: CCTV layer not wired in src/editions/local/data.js"
|
||||
if ! grep -q "dataManager.register(cctvLayer)" src/standalone/data.js; then
|
||||
echo "error: CCTV layer not wired in src/standalone/data.js"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
||||
@@ -20,12 +20,12 @@
|
||||
"src/app/mapLifecycle.test.mjs",
|
||||
"src/app/startupCamera.test.mjs",
|
||||
"src/app/viewer.js",
|
||||
"src/editions/local/application.js",
|
||||
"src/editions/local/controls.js",
|
||||
"src/editions/local/data.js",
|
||||
"src/editions/local/errors.js",
|
||||
"src/editions/local/scene.js",
|
||||
"src/editions/local/startupChrome.js",
|
||||
"src/editions/local/startupChrome.test.mjs",
|
||||
"src/editions/local/tools.js"
|
||||
"src/standalone/application.js",
|
||||
"src/standalone/controls.js",
|
||||
"src/standalone/data.js",
|
||||
"src/standalone/errors.js",
|
||||
"src/standalone/scene.js",
|
||||
"src/standalone/startupChrome.js",
|
||||
"src/standalone/startupChrome.test.mjs",
|
||||
"src/standalone/tools.js"
|
||||
]
|
||||
@@ -10,16 +10,40 @@
|
||||
"src/data/localGeojsonCore.js",
|
||||
"src/data/localGeojsonLod.js"
|
||||
],
|
||||
"external": ["cesium"]
|
||||
"external": [
|
||||
"cesium"
|
||||
]
|
||||
},
|
||||
"application": {
|
||||
"exports": ["./application"],
|
||||
"modules": ["src/app/application.js"],
|
||||
"exports": [
|
||||
"./application"
|
||||
],
|
||||
"modules": [
|
||||
"src/app/application.js"
|
||||
],
|
||||
"external": []
|
||||
},
|
||||
"viewer": {
|
||||
"exports": ["./application/viewer"],
|
||||
"modules": ["src/app/viewer.js"],
|
||||
"external": ["cesium"]
|
||||
"exports": [
|
||||
"./application/viewer"
|
||||
],
|
||||
"modules": [
|
||||
"src/app/viewer.js"
|
||||
],
|
||||
"external": [
|
||||
"cesium"
|
||||
]
|
||||
},
|
||||
"vite-build": {
|
||||
"runtime": "node",
|
||||
"exports": [
|
||||
"./build/vite"
|
||||
],
|
||||
"modules": [
|
||||
"build/vite.js"
|
||||
],
|
||||
"external": [
|
||||
"vite-plugin-cesium"
|
||||
]
|
||||
}
|
||||
}
|
||||
@@ -13,7 +13,7 @@
|
||||
*
|
||||
* Every touched file is restored on exit, including on failure.
|
||||
*
|
||||
* NOTE: two mutations edit vite.config.js, and a running dev server watches that
|
||||
* NOTE: two mutations edit server/providers/local.js, and a running dev server watches that
|
||||
* file and restarts on every write. Writes are therefore content-guarded below
|
||||
* so the file is touched exactly twice per mutation instead of on every
|
||||
* iteration — enough that a dev server survives, but expect it to restart. If
|
||||
@@ -31,7 +31,7 @@ const FILES = {
|
||||
module: path.join(ROOT, 'src', 'firstRunExperience.js'),
|
||||
html: path.join(ROOT, 'index.html'),
|
||||
css: path.join(ROOT, 'style.css'),
|
||||
vite: path.join(ROOT, 'vite.config.js'),
|
||||
vite: path.join(ROOT, 'server/providers/local.js'),
|
||||
main: path.join(ROOT, 'src', 'main.js'),
|
||||
ui: path.join(ROOT, 'src', 'ui.js'),
|
||||
docs: path.join(ROOT, 'docs', 'CURRENT-STATE.md'),
|
||||
|
||||
Reference in new issue
Block a user