Skip to content

fix: fix build process #1594

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Aug 14, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 27 additions & 28 deletions tools/build.mjs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import concurrently from "concurrently";
import esbuild from "esbuild";
import fs from "fs";
import path from "path";

console.log("start");
const dev = process.argv[2];
Expand Down Expand Up @@ -57,13 +56,38 @@ const browserBuildOptions = {
},
};

const copyFiles = () => {
const foldersToCopy = [
{
src: "./server/node_modules/jsonc-parser/lib/umd/impl",
dest: "./server/dist/node/impl",
},
{
src: "./server/node_modules/pyright-internal-node/dist/packages/pyright-internal/typeshed-fallback",
dest: "./server/dist/node/typeshed-fallback",
},
{
src: "./server/src/python/sas",
dest: "./server/dist/node/typeshed-fallback/stubs/sas",
},
{
src: "./client/src/components/notebook/exporters/templates",
dest: "./client/dist/notebook/exporters/templates",
},
];
foldersToCopy.forEach((item) =>
fs.cpSync(item.src, item.dest, { recursive: true }),
);
};

if (process.env.npm_config_webviews || process.env.npm_config_client) {
const ctx = await esbuild.context(
process.env.npm_config_webviews ? browserBuildOptions : nodeBuildOptions,
);
await ctx.rebuild();

if (dev) {
copyFiles();
await ctx.watch();
} else {
await ctx.dispose();
Expand All @@ -79,32 +103,7 @@ if (process.env.npm_config_webviews || process.env.npm_config_client) {
name: "node",
},
]);

await result.then(
() => {
const foldersToCopy = [
{
src: "./server/node_modules/jsonc-parser/lib/umd/impl",
dest: "./server/dist/node/impl",
},
{
src: "./server/node_modules/pyright-internal-node/dist/packages/pyright-internal/typeshed-fallback",
dest: "./server/dist/node/typeshed-fallback",
},
{
src: "./server/src/python/sas",
dest: "./server/dist/node/typeshed-fallback/stubs/sas",
},
{
src: "./client/src/components/notebook/exporters/templates",
dest: "./client/dist/notebook/exporters/templates",
},
];
for (const item of foldersToCopy) {
fs.cpSync(item.src, item.dest, { recursive: true });
console.log(`${item.src} was copied to ${item.dest}`);
}
},
() => console.error("Assets failed to build successfully"),
await result.then(copyFiles, () =>
console.error("Assets failed to build successfully"),
);
}
Loading