Skip to content
Merged
Show file tree
Hide file tree
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
6 changes: 3 additions & 3 deletions packages/suite-desktop-core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
"homepage": "https://trezor.io/",
"main": "src/app.ts",
"scripts": {
"build:scripts": "yarn g:rimraf ./lib && yarn g:tsc --build tsconfig.scripts.json && find ./lib -name '*.js' -exec bash -c 'mv \"$0\" \"${0%.js}.mjs\"' {} \\;",
"build:scripts": "yarn g:rimraf ./lib && yarn g:tsc --build scripts/tsconfig.json && node scripts/rename-js-to-mjs.cjs",
Copy link
Copy Markdown
Contributor Author

@Lemonexe Lemonexe Aug 13, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have many simple bash scripts in-lined in package.json, that's why "git bash for windows" is the only supported shell for native windows dev env.
But find binary is not available in git bash for windows, so this was not working (files were not renamed, and then not found, and build crashed)

"build:core": "yarn g:rimraf dist && TS_NODE_PROJECT=\"tsconfig.json\" yarn webpack --config ./webpack/core.webpack.config.ts",
"type-check": "yarn g:tsc --build tsconfig.json",
"type-check": "yarn g:tsc --build tsconfig.json && yarn g:tsc --build scripts/tsconfig.json",
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Before this PR, the scripts folder was targeted by both tsconfig.scripts.json (for building) and tsconfig.json (for type-checking).
This is not possible now because of the different "module" and "moduleResolution", so everything related to scripts must be handled by their own tsconfig.

"test:unit": "yarn g:jest",
"test:e2e:desktop": "yarn xvfb-maybe -- playwright test --config=./e2e/playwright.config.ts --project=desktop",
"test:e2e:web": "yarn xvfb-maybe -- playwright test --config=./e2e/playwright.config.ts --project=web",
Expand Down Expand Up @@ -54,7 +54,7 @@
},
"devDependencies": {
"@currents/playwright": "^1.13.4",
"@electron/fuses": "^1.8.0",
"@electron/fuses": "^2.0.0",
"@electron/notarize": "3.0.2",
"@octokit/rest": "^21.1.1",
"@playwright/browser-chromium": "^1.52.0",
Expand Down
21 changes: 21 additions & 0 deletions packages/suite-desktop-core/scripts/rename-js-to-mjs.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
/**
* Electron-builder hooks in /scripts/*.ts are compiled to /lib/*.js
* They are built as ESM, as required by some of the libs, but the whole module is still CJS.
* Electron-builder needs to know that the hooks are ESM, so we rename the extension.
* This is an interim solution while electron-main is still built as CJS.
* TODO #14482 Delete this, update the filenames in electron-builder-config.js
*/

const fs = require('fs');
const path = require('path');

const libDir = path.join(__dirname, '../lib');

fs.readdirSync(libDir).forEach(file => {
if (file.endsWith('.js')) {
const oldPath = path.join(libDir, file);
const newPath = path.join(libDir, file.replace(/\.js$/, '.mjs'));
fs.renameSync(oldPath, newPath);
}
});
console.log(`Renamed electron-builder hooks .js files to .mjs`);
12 changes: 12 additions & 0 deletions packages/suite-desktop-core/scripts/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"extends": "../../../tsconfig.lib.json",
"compilerOptions": {
"module": "ESNext",
"moduleResolution": "bundler",
"declaration": false,
"sourceMap": false,
"declarationMap": false,
"outDir": "../lib"
},
"include": ["."]
}
7 changes: 1 addition & 6 deletions packages/suite-desktop-core/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,7 @@
"moduleResolution": "node",
"outDir": "libDev"
},
"include": [
"src",
"e2e",
"scripts",
"**/*.json"
],
"include": ["src", "e2e", "**/*.json"],
"references": [
{
"path": "../../suite-common/message-system"
Expand Down
16 changes: 0 additions & 16 deletions packages/suite-desktop-core/tsconfig.scripts.json

This file was deleted.

11 changes: 10 additions & 1 deletion yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2189,6 +2189,15 @@ __metadata:
languageName: node
linkType: hard

"@electron/fuses@npm:^2.0.0":
version: 2.0.0
resolution: "@electron/fuses@npm:2.0.0"
bin:
electron-fuses: dist/bin.js
checksum: 10/12af9e5164a9870f353368cebd8b451b82ca0abd82bc62b2a3745c51dd3692a761e8e107c2f35cf85aa0781bbbda3afafac8b77c4f8692b6dc820d9a455297a7
languageName: node
linkType: hard

"@electron/get@npm:^2.0.0":
version: 2.0.2
resolution: "@electron/get@npm:2.0.2"
Expand Down Expand Up @@ -12701,7 +12710,7 @@ __metadata:
resolution: "@trezor/suite-desktop-core@workspace:packages/suite-desktop-core"
dependencies:
"@currents/playwright": "npm:^1.13.4"
"@electron/fuses": "npm:^1.8.0"
"@electron/fuses": "npm:^2.0.0"
"@electron/notarize": "npm:3.0.2"
"@octokit/rest": "npm:^21.1.1"
"@playwright/browser-chromium": "npm:^1.52.0"
Expand Down
Loading