mirror of
https://github.com/binaricat/Netcatty.git
synced 2026-11-26 02:31:40 +00:00
build(packaging): prune unused node_modules/dev payloads from app.asar and move @remote-dom/core to devDependencies (#4388)
* build(packaging): prune unused node_modules/dev payloads from app.asar and move @remote-dom/core to devDependencies * fix(build): keep explicit !electron/plugins/fixtures/**/* exclusion for packaging boundary test
This commit is contained in:
4 files changed
+184
-5
No files matched your search
@@ -60,10 +60,19 @@ module.exports = {
|
||||
// The Windows Hello helper is shipped once through win.extraResources.
|
||||
// Exclude local per-arch build output from app.asar on every platform.
|
||||
'!electron/bridges/windowsHelloHelper/build/**/*',
|
||||
// Runtime smoke fixtures are built test packages, not host resources.
|
||||
// Keep them out of production ASARs so no example plugin can be
|
||||
// mistaken for an installed or host-trusted package.
|
||||
// Test fixtures, test-only helpers, and dev/CI schema snapshots are not
|
||||
// runtime resources. Keep them out of production ASARs (including plugin
|
||||
// smoke fixtures so no example plugin can be mistaken for an installed package).
|
||||
'!electron/plugins/fixtures/**/*',
|
||||
'!electron/**/fixtures/**/*',
|
||||
'!electron/bridges/testSupport/**/*',
|
||||
'!electron/bridges/cliDiscoveryTestIsolation.cjs',
|
||||
'!electron/bridges/sshBridge/serverStatsTestHelpers.cjs',
|
||||
'!electron/bridges/terminalBridge.moshConpty.integration.cjs',
|
||||
'!electron/bridges/aiBridge/codexAppServer/protocol.schema.json',
|
||||
// Build-time vector sources copied from public/ into dist/.
|
||||
'!dist/icon.svg',
|
||||
'!dist/tray-iconTemplate.svg',
|
||||
// Main-process terminal flow control reads shared thresholds from here
|
||||
// (terminalFlowAck.cjs). Must ship beside electron/ in app.asar.
|
||||
'infrastructure/config/terminalFlowConstants.cjs',
|
||||
@@ -141,6 +150,39 @@ module.exports = {
|
||||
'!node_modules/katex/**/*',
|
||||
'!node_modules/shiki/**/*',
|
||||
'!node_modules/@shiki/**/*',
|
||||
// @remote-dom/core is bundled into dist/ by Vite for renderer and into
|
||||
// plugin packages at plugin build time; main process never requires it.
|
||||
// Must still be explicitly excluded because workspace @netcatty/plugin-sdk
|
||||
// declares it in dependencies.
|
||||
'!node_modules/@remote-dom/**/*',
|
||||
// web-streams-polyfill is only a Node < 16.5 fallback inside fetch-blob;
|
||||
// Netcatty requires Node >= 22 / Electron 42 with native Web Streams.
|
||||
'!node_modules/web-streams-polyfill/**/*',
|
||||
// Main process only CJS-requires css-tree (cjs/index.cjs) and mdn-data's
|
||||
// css/{at-rules,properties,syntaxes}.json; skip browser/ESM/l10n/schema copies.
|
||||
'!node_modules/css-tree/dist/**/*',
|
||||
'!node_modules/css-tree/lib/**/*',
|
||||
'!node_modules/mdn-data/l10n/**/*',
|
||||
'!node_modules/mdn-data/api/**/*',
|
||||
'!node_modules/mdn-data/css/*.schema.json',
|
||||
// Browser/CDN/schema/unused builds inside Node runtime packages.
|
||||
'!node_modules/@statsig/js-client/build/**/*',
|
||||
'!node_modules/@agentclientprotocol/sdk/schema/**/*',
|
||||
'!node_modules/yaml/browser/**/*',
|
||||
'!node_modules/webdav/dist/web/**/*',
|
||||
'!node_modules/webdav/dist/react-native/**/*',
|
||||
'!node_modules/@withfig/autocomplete/icons/**/*',
|
||||
'!node_modules/js-yaml/dist/js-yaml.js',
|
||||
'!node_modules/js-yaml/dist/js-yaml.min.js',
|
||||
// Build caches and non-license markdown/README docs inside node_modules.
|
||||
// Preserve all LICENSE*/LICENCE*/NOTICE*/COPYING*/PATENTS* files and
|
||||
// @anthropic-ai/claude-agent-sdk/README.md (whose package.json declares
|
||||
// "license": "SEE LICENSE IN README.md").
|
||||
'!node_modules/**/tsconfig*.tsbuildinfo',
|
||||
'!node_modules/**/!(LICENSE*|license*|LICENCE*|licence*|NOTICE*|notice*|COPYING*|copying*|PATENTS*|patents*|README*|readme*).{md,MD}',
|
||||
'!node_modules/!(@anthropic-ai)/**/{README,readme}*',
|
||||
'!node_modules/@anthropic-ai/!(claude-agent-sdk)/**/{README,readme}*',
|
||||
'!node_modules/**/HISTORY.md',
|
||||
// Heavy cloud completion specs are intentionally not bundled. The main
|
||||
// process filters the same prefixes so dev and packaged builds behave
|
||||
// consistently.
|
||||
@@ -232,6 +274,9 @@ module.exports = {
|
||||
// iconutil-generated bundle instead so Finder and app switchers do not
|
||||
// render those representations as colored noise.
|
||||
icon: 'build/icon.icns',
|
||||
files: [
|
||||
'!node_modules/@vscode/windows-process-tree/**/*'
|
||||
],
|
||||
target: [
|
||||
{
|
||||
target: 'dmg',
|
||||
@@ -277,6 +322,9 @@ module.exports = {
|
||||
},
|
||||
win: {
|
||||
icon: 'public/icon-win.png',
|
||||
files: [
|
||||
'!dist/icons/variants/macos/**/*'
|
||||
],
|
||||
// Do not hard-code arch here. pack:win-x64 / pack:win pass --x64/--arm64,
|
||||
// and electron-builder unions config arch with the CLI set. Hard-coding
|
||||
// ['x64', 'arm64'] made the official x64 CI job also emit win-arm64 and
|
||||
@@ -316,6 +364,10 @@ module.exports = {
|
||||
// installs only hicolor/1024x1024 and launchers miss the icon (#274,
|
||||
// #1340). Do NOT set linux.icon to a single 1024px PNG either.
|
||||
icon: 'icons',
|
||||
files: [
|
||||
'!dist/icons/variants/macos/**/*',
|
||||
'!node_modules/@vscode/windows-process-tree/**/*'
|
||||
],
|
||||
target: ['AppImage', 'deb', 'rpm', 'pacman'],
|
||||
category: 'Development',
|
||||
extraResources: [...moshExtraResources('linux'), ...etExtraResources('linux')]
|
||||
|
||||
Generated
+1
-1
@@ -22,7 +22,6 @@
|
||||
"@netcatty/plugin-sdk": "0.1.0-internal.1",
|
||||
"@noble/ciphers": "2.4.0",
|
||||
"@openai/codex-sdk": "0.144.3",
|
||||
"@remote-dom/core": "^1.12.0",
|
||||
"@smithy/node-http-handler": "^4.4.9",
|
||||
"@withfig/autocomplete": "^2.692.3",
|
||||
"ajv": "8.18.0",
|
||||
@@ -70,6 +69,7 @@
|
||||
"@radix-ui/react-select": "2.2.6",
|
||||
"@radix-ui/react-tabs": "1.1.13",
|
||||
"@radix-ui/react-tooltip": "^1.2.8",
|
||||
"@remote-dom/core": "^1.12.0",
|
||||
"@streamdown/cjk": "^1.0.2",
|
||||
"@streamdown/code": "^1.1.0",
|
||||
"@tailwindcss/vite": "^4.1.17",
|
||||
|
||||
+1
-1
@@ -93,7 +93,6 @@
|
||||
"@netcatty/plugin-sdk": "0.1.0-internal.1",
|
||||
"@noble/ciphers": "2.4.0",
|
||||
"@openai/codex-sdk": "0.144.3",
|
||||
"@remote-dom/core": "^1.12.0",
|
||||
"@smithy/node-http-handler": "^4.4.9",
|
||||
"@withfig/autocomplete": "^2.692.3",
|
||||
"ajv": "8.18.0",
|
||||
@@ -137,6 +136,7 @@
|
||||
"@radix-ui/react-select": "2.2.6",
|
||||
"@radix-ui/react-tabs": "1.1.13",
|
||||
"@radix-ui/react-tooltip": "^1.2.8",
|
||||
"@remote-dom/core": "^1.12.0",
|
||||
"@streamdown/cjk": "^1.0.2",
|
||||
"@streamdown/code": "^1.1.0",
|
||||
"@tailwindcss/vite": "^4.1.17",
|
||||
|
||||
@@ -447,3 +447,130 @@ test("linux FPM packages use the custom post-install template", () => {
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
test("@remote-dom/core is a root devDependency while remaining in plugin-sdk and excluded from app.asar", () => {
|
||||
const rootPkg = require("../package.json");
|
||||
const sdkPkg = require("../packages/plugin-sdk/package.json");
|
||||
assert.equal(rootPkg.dependencies["@remote-dom/core"], undefined);
|
||||
assert.ok(rootPkg.devDependencies["@remote-dom/core"]);
|
||||
assert.ok(sdkPkg.dependencies["@remote-dom/core"]);
|
||||
assert.ok(config.files.includes("!node_modules/@remote-dom/**/*"));
|
||||
});
|
||||
|
||||
test("node_modules packaging exclusions prune unused payloads while preserving license notices and css-tree CJS", () => {
|
||||
const { getNodeModuleFileMatcher } = require("app-builder-lib/out/fileMatcher");
|
||||
const root = path.resolve(__dirname, "..");
|
||||
const outDir = path.join(root, "release");
|
||||
const stat = { isDirectory: () => false };
|
||||
|
||||
const nmMac = getNodeModuleFileMatcher(root, outDir, (v) => v, config.mac, {
|
||||
config,
|
||||
debugLogger: { isEnabled: false },
|
||||
}).createFilter();
|
||||
const nmWin = getNodeModuleFileMatcher(root, outDir, (v) => v, config.win, {
|
||||
config,
|
||||
debugLogger: { isEnabled: false },
|
||||
}).createFilter();
|
||||
const nmLinux = getNodeModuleFileMatcher(root, outDir, (v) => v, config.linux, {
|
||||
config,
|
||||
debugLogger: { isEnabled: false },
|
||||
}).createFilter();
|
||||
|
||||
for (const dropped of [
|
||||
"node_modules/@remote-dom/core/build/esm/index.mjs",
|
||||
"node_modules/web-streams-polyfill/dist/ponyfill.es2018.js",
|
||||
"node_modules/css-tree/dist/csstree.js",
|
||||
"node_modules/css-tree/lib/index.js",
|
||||
"node_modules/mdn-data/l10n/css.json",
|
||||
"node_modules/mdn-data/api/inheritance.json",
|
||||
"node_modules/mdn-data/css/properties.schema.json",
|
||||
"node_modules/@statsig/js-client/build/statsig-js-client.min.js",
|
||||
"node_modules/@agentclientprotocol/sdk/schema/schema.json",
|
||||
"node_modules/yaml/browser/index.js",
|
||||
"node_modules/webdav/dist/web/index.js",
|
||||
"node_modules/webdav/dist/react-native/index.js",
|
||||
"node_modules/@withfig/autocomplete/icons/git.png",
|
||||
"node_modules/js-yaml/dist/js-yaml.js",
|
||||
"node_modules/js-yaml/dist/js-yaml.min.js",
|
||||
"node_modules/foo/tsconfig.tsbuildinfo",
|
||||
"node_modules/foo/README.md",
|
||||
"node_modules/foo/readme.txt",
|
||||
"node_modules/foo/CHANGELOG.md",
|
||||
"node_modules/foo/HISTORY.md",
|
||||
"node_modules/@anthropic-ai/sdk/README.md",
|
||||
]) {
|
||||
assert.equal(nmMac(path.join(root, dropped), stat), false, `expected excluded: ${dropped}`);
|
||||
}
|
||||
|
||||
for (const kept of [
|
||||
"node_modules/css-tree/cjs/index.cjs",
|
||||
"node_modules/mdn-data/css/properties.json",
|
||||
"node_modules/mdn-data/css/at-rules.json",
|
||||
"node_modules/mdn-data/css/syntaxes.json",
|
||||
"node_modules/yaml/dist/index.js",
|
||||
"node_modules/webdav/dist/node/index.js",
|
||||
"node_modules/js-yaml/index.js",
|
||||
"node_modules/js-yaml/dist/js-yaml.mjs",
|
||||
"node_modules/foo/LICENSE",
|
||||
"node_modules/foo/LICENSE.md",
|
||||
"node_modules/foo/LICENSE-MIT.md",
|
||||
"node_modules/foo/NOTICE.md",
|
||||
// @anthropic-ai/claude-agent-sdk declares "license": "SEE LICENSE IN README.md"
|
||||
"node_modules/@anthropic-ai/claude-agent-sdk/README.md",
|
||||
"node_modules/@anthropic-ai/claude-agent-sdk/sdk.mjs",
|
||||
]) {
|
||||
assert.equal(nmMac(path.join(root, kept), stat), true, `expected preserved: ${kept}`);
|
||||
}
|
||||
|
||||
// Platform-scoped @vscode/windows-process-tree exclusion
|
||||
const winProcTree = path.join(root, "node_modules/@vscode/windows-process-tree/lib/index.js");
|
||||
assert.equal(nmMac(winProcTree, stat), false);
|
||||
assert.equal(nmLinux(winProcTree, stat), false);
|
||||
assert.equal(nmWin(winProcTree, stat), true);
|
||||
|
||||
// Verify css-tree + mdn-data runtime loader still works cleanly
|
||||
const policy = require("../domain/pluginViewStylePolicy.cjs");
|
||||
assert.equal(typeof policy.validatePluginStylesheet, "function");
|
||||
});
|
||||
|
||||
test("app file exclusions prune dev schemas, test helpers/fixtures, svg sources, and non-target macOS icons", () => {
|
||||
const { getFileMatchers } = require("app-builder-lib/out/fileMatcher");
|
||||
const root = path.resolve(__dirname, "..");
|
||||
const outDir = path.join(root, "release");
|
||||
const stat = { isDirectory: () => false };
|
||||
|
||||
const makeFilter = (platformOpts) =>
|
||||
getFileMatchers(config, "files", outDir, {
|
||||
macroExpander: (v) => v,
|
||||
customBuildOptions: platformOpts,
|
||||
globalOutDir: outDir,
|
||||
defaultSrc: root,
|
||||
})[0].createFilter();
|
||||
|
||||
const macFilter = makeFilter(config.mac);
|
||||
const winFilter = makeFilter(config.win);
|
||||
const linuxFilter = makeFilter(config.linux);
|
||||
|
||||
for (const dropped of [
|
||||
"electron/bridges/aiBridge/codexAppServer/protocol.schema.json",
|
||||
"electron/plugins/fixtures/inProcessBrowserRuntime.cjs",
|
||||
"electron/bridges/fixtures/sample.cs",
|
||||
"electron/hostBrowser/fixtures/renderer.html",
|
||||
"electron/bridges/testSupport/bridgeHarness.cjs",
|
||||
"electron/bridges/cliDiscoveryTestIsolation.cjs",
|
||||
"electron/bridges/sshBridge/serverStatsTestHelpers.cjs",
|
||||
"electron/bridges/terminalBridge.moshConpty.integration.cjs",
|
||||
"dist/icon.svg",
|
||||
"dist/tray-iconTemplate.svg",
|
||||
]) {
|
||||
assert.equal(macFilter(path.join(root, dropped), stat), false, `expected excluded: ${dropped}`);
|
||||
}
|
||||
|
||||
assert.equal(macFilter(path.join(root, "dist/index.html"), stat), true);
|
||||
assert.equal(macFilter(path.join(root, "electron/main.cjs"), stat), true);
|
||||
|
||||
const macosVariantIcon = path.join(root, "dist/icons/variants/macos/icon.png");
|
||||
assert.equal(macFilter(macosVariantIcon, stat), true);
|
||||
assert.equal(winFilter(macosVariantIcon, stat), false);
|
||||
assert.equal(linuxFilter(macosVariantIcon, stat), false);
|
||||
});
|
||||
Reference in new issue
Block a user