Several people edit one model at once through a server you run yourself (archify-vscode-ext-sync); the files stay ordinary files on each disk. Sign-in through the browser, offline-first with later merge, teammates' cursors in the Source view and text editors, and a Shared section on the model page with people, versions, Compare and Restore. Without a server nothing changes: the sync code is a separate bundle that loads only when a model is shared, after a sign-in, or when a sync command or invite link is used.
98 lines
3.0 KiB
JavaScript
98 lines
3.0 KiB
JavaScript
import * as esbuild from 'esbuild';
|
|
import fs from 'node:fs';
|
|
import path from 'node:path';
|
|
|
|
const production = process.argv.includes('--production');
|
|
const watch = process.argv.includes('--watch');
|
|
const tests = process.argv.includes('--tests');
|
|
|
|
const common = {
|
|
bundle: true,
|
|
format: 'cjs',
|
|
platform: 'node',
|
|
target: 'node20',
|
|
sourcemap: !production,
|
|
minify: production,
|
|
logLevel: 'info',
|
|
// jsonc-parser's UMD entry uses dynamic requires esbuild cannot follow.
|
|
mainFields: ['module', 'main'],
|
|
};
|
|
|
|
// codemirror-json-schema formats schema descriptions with markdown-it and
|
|
// shiki (about 400 KB); a small stub does what our descriptions need.
|
|
const stubMarkdown = {
|
|
name: 'stub-markdown',
|
|
setup(build) {
|
|
build.onResolve({ filter: /utils\/markdown(\.js)?$/ }, (args) =>
|
|
args.importer.includes('codemirror-json-schema') ? { path: path.resolve('src/webview/source/markdownStub.ts') } : undefined,
|
|
);
|
|
},
|
|
};
|
|
|
|
if (tests) {
|
|
// Unit tests cover the modules that do not import 'vscode'; the
|
|
// integration suite runs inside VS Code, which provides it.
|
|
const entryPoints = fs.readdirSync('test')
|
|
.filter((file) => file.endsWith('.test.ts'))
|
|
.map((file) => path.join('test', file));
|
|
await esbuild.build({ ...common, entryPoints, outdir: 'out/test', sourcemap: true });
|
|
await esbuild.build({
|
|
...common,
|
|
entryPoints: ['test/integration/suite.ts'],
|
|
outfile: 'out/test/integration/suite.js',
|
|
external: ['vscode'],
|
|
sourcemap: true,
|
|
});
|
|
} else {
|
|
const contexts = await Promise.all([
|
|
esbuild.context({
|
|
...common,
|
|
entryPoints: ['src/extension.ts'],
|
|
outfile: 'dist/extension.js',
|
|
external: ['vscode'],
|
|
}),
|
|
// Archify Sync, loaded only when a model is shared (src/sync/loader.ts).
|
|
// ws's native speed-ups are optional and not shipped.
|
|
esbuild.context({
|
|
...common,
|
|
entryPoints: ['src/sync/index.ts'],
|
|
outfile: 'dist/sync.js',
|
|
external: ['vscode', 'bufferutil', 'utf-8-validate'],
|
|
}),
|
|
// Runs inside the Archify page in the webview; three.js is bundled in.
|
|
esbuild.context({
|
|
...common,
|
|
format: 'iife',
|
|
platform: 'browser',
|
|
target: 'es2022',
|
|
entryPoints: ['src/viewer3d/index.ts'],
|
|
outfile: 'dist/viewer3d.js',
|
|
}),
|
|
// The Graph page of a model; Cytoscape.js is bundled in.
|
|
esbuild.context({
|
|
...common,
|
|
format: 'iife',
|
|
platform: 'browser',
|
|
target: 'es2022',
|
|
entryPoints: ['src/graph/index.ts'],
|
|
outfile: 'dist/graph.js',
|
|
}),
|
|
// The Source view; CodeMirror is bundled in. Loaded the first time Source is chosen.
|
|
esbuild.context({
|
|
...common,
|
|
format: 'iife',
|
|
platform: 'browser',
|
|
target: 'es2022',
|
|
entryPoints: ['src/webview/source/index.ts'],
|
|
outfile: 'dist/source.js',
|
|
plugins: [stubMarkdown],
|
|
}),
|
|
]);
|
|
if (watch) {
|
|
await Promise.all(contexts.map((ctx) => ctx.watch()));
|
|
} else {
|
|
await Promise.all(contexts.map((ctx) => ctx.rebuild()));
|
|
await Promise.all(contexts.map((ctx) => ctx.dispose()));
|
|
}
|
|
}
|