diff --git a/scripts/build/build.mjs b/scripts/build/build.mjs index 6d0a43cce..65326d3d5 100755 --- a/scripts/build/build.mjs +++ b/scripts/build/build.mjs @@ -20,7 +20,7 @@ // @ts-check import { readdir } from "fs/promises"; -import { join } from "path"; +import { join, resolve } from "path"; import { BUILD_TIMESTAMP, commonOpts, exists, globPlugins, IS_DEV, IS_REPORTER, IS_ANTI_CRASH_TEST, IS_STANDALONE, IS_UPDATER_DISABLED, resolvePluginName, VERSION, commonRendererPlugins, watch, buildOrWatchAll, stringifyValues } from "./common.mjs"; @@ -78,6 +78,10 @@ const globNativesPlugin = { let code = ""; let natives = "\n"; let i = 0; + /** + * @type {string[]} + */ + const watchFiles = []; for (const dir of pluginDirs) { const dirPath = join("src", dir); if (!await exists(dirPath)) continue; @@ -87,6 +91,8 @@ const globNativesPlugin = { const nativePath = join(dirPath, fileName, "native.ts"); const indexNativePath = join(dirPath, fileName, "native/index.ts"); + watchFiles.push(resolve(nativePath), resolve(indexNativePath)); + if (!(await exists(nativePath)) && !(await exists(indexNativePath))) continue; @@ -101,7 +107,9 @@ const globNativesPlugin = { code += `export default {${natives}};`; return { contents: code, - resolveDir: "./src" + resolveDir: "./src", + watchDirs: pluginDirs.map(d => resolve("src", d)), + watchFiles, }; }); } diff --git a/scripts/build/common.mjs b/scripts/build/common.mjs index 6e69ac088..7f2f5da53 100644 --- a/scripts/build/common.mjs +++ b/scripts/build/common.mjs @@ -26,7 +26,7 @@ import esbuild, { build, context } from "esbuild"; import { constants as FsConstants, readFileSync } from "fs"; import { access, readdir, readFile } from "fs/promises"; import { minify as minifyHtml } from "html-minifier-terser"; -import { join, relative } from "path"; +import { join, relative, resolve } from "path"; import { promisify } from "util"; import { getPluginTarget } from "../utils.mjs"; @@ -190,7 +190,8 @@ export const globPlugins = kind => ({ code += `export default {${pluginsCode}};export const PluginMeta={${metaCode}};export const ExcludedPlugins={${excludedCode}};`; return { contents: code, - resolveDir: "./src" + resolveDir: "./src", + watchDirs: pluginDirs.map(d => resolve("src", d)), }; }); }