Migrate project to pnpm monorepo
Restructure the repository into a pnpm workspace under packages/ (core, webui, runtime). Move source files for core and webui into packages/*, add package manifests for @snowluma/core and @snowluma/runtime, and remove the old launcher package.json. Update root package.json to be a monorepo controller (scripts delegate to pnpm filters, set packageManager and Node engine). Configure build outputs to emit into the repo-root dist/ (vite config changes) so the existing release pipeline continues to work. Add .npmrc with mirrors, expand .gitignore for monorepo layout, add tsconfig base and package-level tsconfigs, and add vitest config for the core package. Adjust injector native search paths and update tests import paths to the new package layout. Small CI/workflow comment added to clarify build behavior and README updated with monorepo structure and common commands.
This commit is contained in:
1 parent
6bba36bba6
commit
39f1672b29
122 files changed
+279
-85
No files matched your search
@@ -0,0 +1,84 @@
|
||||
import { defineConfig, PluginOption, UserConfig } from 'vite';
|
||||
import { fileURLToPath } from 'url';
|
||||
import path from 'path';
|
||||
import { builtinModules } from 'module';
|
||||
import cp from 'vite-plugin-cp';
|
||||
|
||||
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
||||
const repoRoot = path.resolve(__dirname, '..', '..');
|
||||
const distDir = path.resolve(repoRoot, 'dist');
|
||||
const runtimeDir = path.resolve(repoRoot, 'packages', 'runtime');
|
||||
const nativeDir = path.resolve(runtimeDir, 'native');
|
||||
|
||||
// vite-plugin-cp consumes globs through globby; on Windows we must use POSIX-style separators.
|
||||
const toPosix = (p: string) => p.replace(/\\/g, '/');
|
||||
|
||||
const external = [
|
||||
'ws'
|
||||
];
|
||||
|
||||
const nodeModules = [...builtinModules, ...builtinModules.map((m) => `node:${m}`), 'node:sqlite'].flat();
|
||||
|
||||
const runtimeSrc = toPosix(runtimeDir);
|
||||
const nativeSrc = toPosix(nativeDir);
|
||||
|
||||
// Only the runtime distribution assets land in dist/.
|
||||
// (.gitignore and other dev artifacts must NOT be shipped.)
|
||||
const runtimeDistFiles = ['launcher.bat', 'package.json'];
|
||||
|
||||
const BaseConfigPlugin: PluginOption[] = [
|
||||
cp({
|
||||
targets: [
|
||||
...runtimeDistFiles.map((file) => ({
|
||||
src: `${runtimeSrc}/${file}`,
|
||||
dest: distDir,
|
||||
flatten: true,
|
||||
})),
|
||||
{ src: `${nativeSrc}/*`, dest: path.join(distDir, 'native'), flatten: true },
|
||||
]
|
||||
})
|
||||
];
|
||||
|
||||
const BaseConfig = (source_map: boolean = false) => defineConfig({
|
||||
resolve: {
|
||||
conditions: ['node', 'default'],
|
||||
alias: {
|
||||
'@': path.resolve(__dirname, 'src')
|
||||
}
|
||||
},
|
||||
build: {
|
||||
sourcemap: source_map,
|
||||
target: 'esnext',
|
||||
minify: false,
|
||||
lib: {
|
||||
entry: {
|
||||
index: path.resolve(__dirname, 'src/index.ts')
|
||||
},
|
||||
formats: ['es'],
|
||||
fileName: (_, entryName) => `${entryName}.mjs`
|
||||
},
|
||||
rollupOptions: {
|
||||
external: [...nodeModules, ...external]
|
||||
},
|
||||
// Emit to monorepo root dist/ so the existing release pipeline keeps working.
|
||||
outDir: distDir,
|
||||
// Required since outDir is outside the vite project root.
|
||||
emptyOutDir: true
|
||||
},
|
||||
define: {
|
||||
__BUILD_WEBUI__: process.env.BUILD_WEBUI === 'true'
|
||||
}
|
||||
});
|
||||
|
||||
export default defineConfig(({ mode }): UserConfig => {
|
||||
if (mode === 'development') {
|
||||
return {
|
||||
...BaseConfig(true),
|
||||
plugins: [...BaseConfigPlugin]
|
||||
};
|
||||
}
|
||||
return {
|
||||
...BaseConfig(),
|
||||
plugins: [...BaseConfigPlugin]
|
||||
};
|
||||
});
|
||||
Reference in new issue
Block a user