Closed jsimomaa closed 1 year ago
This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 5 days.
Is not stale
What has worked for me is transpiling the config and then executing the electron-builder command using the output file path for the config flag, probably not the ideal solution but something that just works!
compile.js
const { execSync } = require('child_process')
// Get stage and OS flag from command line arguments
const stage = process.argv[2]
const osFlag = process.argv[3]
// Set environment variables
process.env.STAGE = stage
// Transpile TypeScript to JavaScript
try {
execSync('tsc --esModuleInterop electron-builder.config.ts', { stdio: 'inherit' })
// Build the command based on the stage and OS flag
const command = `cross-env STAGE=${stage} electron-builder ${osFlag} --x64 --config electron-builder.config.js`
// Run the electron-builder command
execSync(command, { stdio: 'inherit' })
} catch (error) {
console.error('Electron Builder transpilation or execution failed')
process.exit(1)
}
package.json
"scripts": {
"compile": "node compile.js"
},
terminal
npm run compile alpha --win
I use JavaScript and ts-check for workaround.
Might be worth opening an issue with config-files-ts
to fix the :
path to work on windows, then we can update electron-builder accordingly once a new release is published?
This issue is stale because it has been open 60 days with no activity. Remove stale label or comment or this will be closed in 30 days.
Not stale
Closing this issue. It's not an electron-builder issue. Please open an issue with upstream npm dependency https://www.npmjs.com/package/config-file-ts
Ref: https://github.com/electron-userland/electron-builder/issues/7572#issuecomment-1648295495
To check this issue status in config-file-ts
, the ticket is: https://github.com/mighdoll/config-file-ts/issues/19
It seems they have a PR ready to fix it soon
This is a fake fix. We should re-open it https://github.com/mighdoll/config-file-ts/pull/22
Feel free to post in that github project. There's not much I can do from this side and the workaround is to just use the other approach in a .js
file with
// Let's get that intellisense working
/**
* @type {import('electron-builder').Configuration}
* @see https://www.electron.build/configuration/configuration
*/
I am saddened by this fact. "The configuration file now supports TS" is hype.😞
Tried to convert my
electron-builder.js
to TypeScript and it seems the TS-config requires compilation. However the compilation (or saving the resulting extended sources after compiling) fails:This is because Windows does not allow
:
in path. The packageconfig-files-ts
functiondefaultOutDir
produces an output path with:
in it:https://github.com/mighdoll/config-file-ts/blob/25600267e7da114c5a12b1e9b30759d7f4b7c16c/src/loadTsConfig.ts#L29-L40
Unfortunately package
read-config-file
does not supply the optional output dir forloadTsConfig
:https://github.com/develar/read-config-file/blob/482fb9fad1a789150064928a80b2a30485ba1f94/src/main.ts#L29-L31