Skip to content

Commit 01c4710

Browse files
authored
build: Bump forge packages and update configs to fix macos15-intel build (#1007)
1 parent 67660e7 commit 01c4710

14 files changed

+2188
-1537
lines changed

forge.config.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ import path from 'path'
1111

1212
import { CUSTOM_APP_PROTOCOL } from './src/main/deepLinks.constants'
1313
import { getPlatform, getArch } from './src/utils/electron'
14-
import { spawnSignFile } from './src/utils/signing'
1514
import { windowsSign } from './windowsSign'
15+
import { spawnSignFile } from './windowsSignHook'
1616

1717
function getPlatformSpecificResources() {
1818
// on mac we are using a single image to build both architectures so we
@@ -122,6 +122,7 @@ const config: ForgeConfig = {
122122
config: 'vite.preload.config.ts',
123123
},
124124
{
125+
entry: 'extension/src/background/index.ts',
125126
config: 'vite.extension.config.mts',
126127
},
127128
{

package-lock.json

Lines changed: 2064 additions & 1434 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -25,21 +25,22 @@
2525
"gen:cdp": "ts-node --transpileOnly scripts/cdp/generateCdpClient.ts > src/utils/cdp/client.ts"
2626
},
2727
"devDependencies": {
28-
"@electron-forge/cli": "^7.4.0",
29-
"@electron-forge/maker-deb": "^7.4.0",
30-
"@electron-forge/maker-dmg": "^7.4.0",
31-
"@electron-forge/maker-rpm": "^7.4.0",
32-
"@electron-forge/maker-squirrel": "^7.4.0",
33-
"@electron-forge/maker-zip": "^7.4.0",
34-
"@electron-forge/plugin-auto-unpack-natives": "^7.4.0",
35-
"@electron-forge/plugin-fuses": "^7.4.0",
36-
"@electron-forge/plugin-vite": "^7.4.0",
37-
"@electron-forge/publisher-github": "^7.4.0",
28+
"@electron-forge/cli": "^7.10.2",
29+
"@electron-forge/maker-deb": "^7.10.2",
30+
"@electron-forge/maker-dmg": "^7.10.2",
31+
"@electron-forge/maker-rpm": "^7.10.2",
32+
"@electron-forge/maker-squirrel": "^7.10.2",
33+
"@electron-forge/maker-zip": "^7.10.2",
34+
"@electron-forge/plugin-auto-unpack-natives": "^7.10.2",
35+
"@electron-forge/plugin-fuses": "^7.10.2",
36+
"@electron-forge/plugin-vite": "^7.10.2",
37+
"@electron-forge/publisher-github": "^7.10.2",
3838
"@electron/fuses": "^1.8.0",
3939
"@tanstack/eslint-plugin-query": "^5.53.0",
4040
"@testing-library/react": "^16.0.1",
4141
"@types/chrome": "^0.0.287",
4242
"@types/diff": "^7.0.2",
43+
"@types/electron-squirrel-startup": "^1.0.2",
4344
"@types/express": "^5.0.3",
4445
"@types/har-format": "^1.2.16",
4546
"@types/k6": "^1.3.1",
@@ -154,7 +155,7 @@
154155
"tree-kill": "^1.2.2",
155156
"typescript": "^5.4.5",
156157
"undici": "^7.10.0",
157-
"update-electron-app": "^3.0.0",
158+
"update-electron-app": "^3.1.2",
158159
"use-konami": "^1.0.1",
159160
"webextension-polyfill": "^0.12.0",
160161
"ws": "^8.18.0",

src/main.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import * as Sentry from '@sentry/electron/main'
22
import { app, BrowserWindow, nativeTheme } from 'electron'
33
import log from 'electron-log/main'
4+
import isSquirrelStartup from 'electron-squirrel-startup'
45
import path from 'path'
56
import { updateElectronApp } from 'update-electron-app'
67

@@ -44,7 +45,7 @@ if (process.env.NODE_ENV !== 'development') {
4445
}
4546

4647
// Handle creating/removing shortcuts on Windows when installing/uninstalling.
47-
if (require('electron-squirrel-startup')) {
48+
if (isSquirrelStartup) {
4849
app.quit()
4950
}
5051

src/main/runner/instrumentation.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,15 @@ export const instrumentScript = ({
2929
throw new Error('Failed to parse entry script')
3030
}
3131

32+
// Use relative import path with ./ prefix for cross-platform compatibility
33+
const scriptBasename = path.basename(scriptPath)
34+
const relativePath = `./${scriptBasename}`
35+
3236
traverse(entryAst, {
3337
[NodeType.ImportDeclaration](node) {
3438
if (node.source.value === '__USER_SCRIPT_PATH__') {
35-
node.source.value = scriptPath
36-
node.source.raw = JSON.stringify(scriptPath)
39+
node.source.value = relativePath
40+
node.source.raw = JSON.stringify(relativePath)
3741
}
3842
},
3943
})

src/main/script.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,9 +129,13 @@ const archiveScript = async (
129129
try {
130130
const client = new K6Client()
131131

132+
// Set cwd to script directory for import resolution on Windows
133+
const scriptDir = path.dirname(scriptPath)
134+
132135
await client.archive({
133136
scriptPath,
134137
outputPath: TEMP_K6_ARCHIVE_PATH,
138+
cwd: scriptDir,
135139
})
136140

137141
return TEMP_K6_ARCHIVE_PATH

src/utils/k6/client.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ function getDefaultExecutablePath() {
2525
interface SpawnArgs {
2626
args: Array<string[] | string | null | undefined | false>
2727
env?: NodeJS.ProcessEnv
28+
cwd?: string
2829
}
2930

3031
interface SpawnResult {
@@ -36,6 +37,7 @@ interface SpawnResult {
3637
interface ArchiveArgs {
3738
scriptPath: string
3839
outputPath?: string
40+
cwd?: string
3941
}
4042

4143
interface InspectArgs {
@@ -69,13 +71,14 @@ export class K6Client {
6971
this.#executablePath = executablePath
7072
}
7173

72-
async archive({ scriptPath, outputPath }: ArchiveArgs): Promise<void> {
74+
async archive({ scriptPath, outputPath, cwd }: ArchiveArgs): Promise<void> {
7375
const process = this.#spawn('archive', {
7476
args: [
7577
outputPath && ['--archive-out', outputPath],
7678
['--log-format', 'json'],
7779
scriptPath,
7880
],
81+
cwd,
7982
})
8083

8184
const { code, stderr } = await this.#wait(process)
@@ -171,13 +174,14 @@ export class K6Client {
171174

172175
#spawn(
173176
command: string,
174-
{ args, env }: SpawnArgs
177+
{ args, env, cwd }: SpawnArgs
175178
): ChildProcessWithoutNullStreams {
176179
const flattenedArgs = args
177180
.filter((arg) => arg !== null && arg !== undefined && arg !== false)
178181
.flat()
179182

180183
return spawn(this.#executablePath, [command, ...flattenedArgs], {
184+
cwd,
181185
env: {
182186
...process.env,
183187
...env,

src/utils/signing.ts

Lines changed: 0 additions & 68 deletions
This file was deleted.

vite.base.config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ export function getBuildDefine(env: ConfigEnv<'build'>) {
5454
const { command, forgeConfig } = env
5555
const names = forgeConfig.renderer
5656
.filter(({ name }) => name != null)
57-
.map(({ name }) => name!)
57+
.map(({ name }) => name)
5858
const defineKeys = getDefineKeys(names)
5959
const define = Object.entries(defineKeys).reduce(
6060
(acc, [name, keys]) => {

vite.browser.config.mts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,21 @@ import tsconfigPaths from 'vite-tsconfig-paths'
77
export default defineConfig((env) => {
88
const forgeEnv = env as ConfigEnv<'renderer'>
99
const { root, mode } = forgeEnv
10+
const nodeEnv = process.env.NODE_ENV || 'production'
1011

1112
return {
1213
root,
1314
mode,
1415
base: './',
1516
define: {
1617
TARGET_PLATFORM: JSON.stringify(process.platform),
17-
'process.env.NODE_ENV': JSON.stringify(process.env.NODE_ENV),
18+
'process.env.NODE_ENV': JSON.stringify(nodeEnv),
19+
// fix for react-is lib in packaged mode
20+
process: JSON.stringify({
21+
env: {
22+
NODE_ENV: nodeEnv
23+
},
24+
}),
1825
},
1926
build: {
2027
target: 'esnext',
@@ -43,6 +50,8 @@ export default defineConfig((env) => {
4350
],
4451
resolve: {
4552
preserveSymlinks: true,
53+
// Force vite to use browser-specific package exports
54+
conditions: ['browser', 'import', 'module', 'default'],
4655
},
4756
clearScreen: false,
4857
} as UserConfig

0 commit comments

Comments
 (0)