summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorTobias Järvelöv <tobias.jarvelov@mullvad.net>2025-09-23 14:29:11 +0200
committerTobias Järvelöv <tobias.jarvelov@mullvad.net>2026-01-05 12:39:32 +0100
commit049afaada9040219d2b6b493da89199225f33032 (patch)
treefa6a768ed9a08e24bbcd622d43d46611fabd5f7d
parentd8077ca050c48801c9311504d3c9364533efbd5a (diff)
downloadmullvadvpn-esm-migration-test.tar.xz
mullvadvpn-esm-migration-test.zip
-rw-r--r--desktop/packages/mullvad-vpn/index.html2
-rw-r--r--desktop/packages/mullvad-vpn/package.json17
-rw-r--r--desktop/packages/mullvad-vpn/src/main/changelog.ts2
-rw-r--r--desktop/packages/mullvad-vpn/src/main/index.ts4
-rw-r--r--desktop/packages/mullvad-vpn/src/main/load-translations.ts2
-rw-r--r--desktop/packages/mullvad-vpn/src/main/notification-controller.ts2
-rw-r--r--desktop/packages/mullvad-vpn/src/main/proc.ts3
-rw-r--r--desktop/packages/mullvad-vpn/src/main/tray-icon-controller.ts2
-rw-r--r--desktop/packages/mullvad-vpn/src/main/user-interface.ts4
-rw-r--r--desktop/packages/mullvad-vpn/src/renderer/index.tsx (renamed from desktop/packages/mullvad-vpn/src/renderer/index.ts)2
-rw-r--r--desktop/packages/mullvad-vpn/src/renderer/test-app.tsx51
-rw-r--r--desktop/packages/mullvad-vpn/tasks/build-production.cjs (renamed from desktop/packages/mullvad-vpn/tasks/build-production.js)4
-rw-r--r--desktop/packages/mullvad-vpn/tasks/build-standalone.cjs (renamed from desktop/packages/mullvad-vpn/tasks/build-standalone.js)0
-rw-r--r--desktop/packages/mullvad-vpn/tasks/build-test.cjs (renamed from desktop/packages/mullvad-vpn/tasks/build-test.js)0
-rw-r--r--desktop/packages/mullvad-vpn/tasks/build.cjs (renamed from desktop/packages/mullvad-vpn/tasks/build.js)0
-rw-r--r--desktop/packages/mullvad-vpn/tasks/distribution.cjs (renamed from desktop/packages/mullvad-vpn/tasks/distribution.js)0
-rw-r--r--desktop/packages/mullvad-vpn/tasks/pack-linux.cjs (renamed from desktop/packages/mullvad-vpn/tasks/pack-linux.js)0
-rw-r--r--desktop/packages/mullvad-vpn/tasks/pack-mac.cjs (renamed from desktop/packages/mullvad-vpn/tasks/pack-mac.js)0
-rw-r--r--desktop/packages/mullvad-vpn/tasks/pack-windows.cjs (renamed from desktop/packages/mullvad-vpn/tasks/pack-windows.js)0
-rw-r--r--desktop/packages/mullvad-vpn/tasks/utils.cjs (renamed from desktop/packages/mullvad-vpn/tasks/utils.js)0
-rw-r--r--desktop/packages/mullvad-vpn/test/e2e/setup/main.ts4
-rw-r--r--desktop/packages/mullvad-vpn/tsconfig.json4
-rw-r--r--desktop/packages/mullvad-vpn/vite.config.ts7
23 files changed, 86 insertions, 24 deletions
diff --git a/desktop/packages/mullvad-vpn/index.html b/desktop/packages/mullvad-vpn/index.html
index 5b1f2e7cdb..12fa1b856b 100644
--- a/desktop/packages/mullvad-vpn/index.html
+++ b/desktop/packages/mullvad-vpn/index.html
@@ -15,6 +15,6 @@
</head>
<body>
<div id="app"></div>
- <script type="module" src="/src/renderer/index.ts"></script>
+ <script type="module" src="/src/renderer/index.tsx"></script>
</body>
</html>
diff --git a/desktop/packages/mullvad-vpn/package.json b/desktop/packages/mullvad-vpn/package.json
index 0004dd9c68..71e1d55139 100644
--- a/desktop/packages/mullvad-vpn/package.json
+++ b/desktop/packages/mullvad-vpn/package.json
@@ -9,6 +9,7 @@
"name": "Mullvad VPN",
"email": "support@mullvadvpn.net"
},
+ "type": "module",
"repository": "https://github.com/mullvad/mullvadvpn-app",
"license": "GPL-3.0",
"dependencies": {
@@ -25,7 +26,7 @@
"react-dom": "^19.1.1",
"react-redux": "^9.2.0",
"react-router": "^5.3.4",
- "redux": "^4.2.0",
+ "redux": "^5.0.1",
"simple-plist": "^1.3.1",
"sprintf-js": "^1.1.2",
"styled-components": "^6.1.19",
@@ -47,7 +48,7 @@
"@types/sinon": "^10.0.13",
"@types/sprintf-js": "^1.1.2",
"@types/topojson-specification": "^1.0.2",
- "@vitejs/plugin-react": "^5.0.2",
+ "@vitejs/plugin-react": "^4.7.0",
"chai": "^4.3.6",
"chai-as-promised": "^7.1.1",
"chai-spies": "^1.0.0",
@@ -78,10 +79,10 @@
},
"scripts": {
"preinstall": "test -d node_modules || mkdir node_modules",
- "build": "node tasks/build-production.js",
+ "build": "node tasks/build-production.cjs",
"build:vite": "vite build",
- "build:test": "node tasks/build-test.js",
- "build:standalone": "node tasks/build-standalone.js",
+ "build:test": "node tasks/build-test.cjs",
+ "build:standalone": "node tasks/build-standalone.cjs",
"pack-test-executable": "./scripts/build-test-executable.sh",
"build-test-executable": "npm run pack-test-executable",
"lint": "eslint . --max-warnings 0",
@@ -97,9 +98,9 @@
"test": "cross-env NODE_ENV=test mocha --reporter spec --require ts-node/register --require \"test/unit/setup.ts\" \"test/unit/*.spec.ts\"",
"type-check": "tsc --noEmit",
"update-translations": "node scripts/extract-translations",
- "pack:mac": "node tasks/pack-mac.js",
- "pack:win": "node tasks/pack-windows.js",
- "pack:linux": "node tasks/pack-linux.js"
+ "pack:mac": "node tasks/pack-mac.cjs",
+ "pack:win": "node tasks/pack-windows.cjs",
+ "pack:linux": "node tasks/pack-linux.cjs"
},
"volta": {
"extends": "../../package.json"
diff --git a/desktop/packages/mullvad-vpn/src/main/changelog.ts b/desktop/packages/mullvad-vpn/src/main/changelog.ts
index 3b72fc17e3..2ff756ddbe 100644
--- a/desktop/packages/mullvad-vpn/src/main/changelog.ts
+++ b/desktop/packages/mullvad-vpn/src/main/changelog.ts
@@ -7,7 +7,7 @@ import log from '../shared/logging';
// Reads and parses the changelog file.
export function readChangelog(): IChangelog {
try {
- const changelogPath = path.join(__dirname, '..', 'changes.txt');
+ const changelogPath = path.join(import.meta.dirname, '..', 'changes.txt');
const contents = fs.readFileSync(changelogPath).toString();
return parseChangelog(contents);
} catch (e) {
diff --git a/desktop/packages/mullvad-vpn/src/main/index.ts b/desktop/packages/mullvad-vpn/src/main/index.ts
index ee74f85486..7968908a31 100644
--- a/desktop/packages/mullvad-vpn/src/main/index.ts
+++ b/desktop/packages/mullvad-vpn/src/main/index.ts
@@ -79,7 +79,7 @@ const ALLOWED_PERMISSIONS = ['clipboard-sanitized-write'];
const SANDBOX_DISABLED = app.commandLine.hasSwitch('no-sandbox');
const UPDATE_NOTIFICATION_DISABLED = process.env.MULLVAD_DISABLE_UPDATE_NOTIFICATION === '1';
-const GEO_DIR = path.resolve(__dirname, 'assets/geo');
+const GEO_DIR = path.resolve(import.meta.dirname, 'assets/geo');
class ApplicationMain
implements
@@ -1012,7 +1012,7 @@ class ApplicationMain
}
private allowFileAccess(url: string): boolean {
- const buildDir = path.normalize(path.join(path.resolve(__dirname), '..', '..'));
+ const buildDir = path.normalize(path.join(path.resolve(import.meta.dirname), '..', '..'));
if (url.startsWith('file:')) {
// Extract the path from the URL
diff --git a/desktop/packages/mullvad-vpn/src/main/load-translations.ts b/desktop/packages/mullvad-vpn/src/main/load-translations.ts
index 670e9a2a5b..5736d23dfa 100644
--- a/desktop/packages/mullvad-vpn/src/main/load-translations.ts
+++ b/desktop/packages/mullvad-vpn/src/main/load-translations.ts
@@ -6,7 +6,7 @@ import path from 'path';
import log from '../shared/logging';
const SOURCE_LANGUAGE = 'en';
-const LOCALES_DIR = path.resolve(__dirname, 'locales');
+const LOCALES_DIR = path.resolve(import.meta.dirname, 'locales');
export function loadTranslations(
currentLocale: string,
diff --git a/desktop/packages/mullvad-vpn/src/main/notification-controller.ts b/desktop/packages/mullvad-vpn/src/main/notification-controller.ts
index e8e5871359..a65fe2b197 100644
--- a/desktop/packages/mullvad-vpn/src/main/notification-controller.ts
+++ b/desktop/packages/mullvad-vpn/src/main/notification-controller.ts
@@ -76,7 +76,7 @@ export default class NotificationController {
}
if (usePngIcon) {
- const imagePath = path.join(__dirname, 'assets/images/icon-notification.png');
+ const imagePath = path.join(import.meta.dirname, 'assets/images/icon-notification.png');
// `nativeImage` is undefined when running tests
this.notificationIcon = nativeImage?.createFromPath(imagePath);
}
diff --git a/desktop/packages/mullvad-vpn/src/main/proc.ts b/desktop/packages/mullvad-vpn/src/main/proc.ts
index 1e8118268d..328735edbc 100644
--- a/desktop/packages/mullvad-vpn/src/main/proc.ts
+++ b/desktop/packages/mullvad-vpn/src/main/proc.ts
@@ -7,7 +7,8 @@ export function resolveBin(binaryName: string) {
function getBasePath(): string {
if (process.env.NODE_ENV === 'development') {
return (
- process.env.MULLVAD_PATH || path.resolve(path.join(__dirname, '../../../../target/debug'))
+ process.env.MULLVAD_PATH ||
+ path.resolve(path.join(import.meta.dirname, '../../../../target/debug'))
);
} else {
return process.resourcesPath;
diff --git a/desktop/packages/mullvad-vpn/src/main/tray-icon-controller.ts b/desktop/packages/mullvad-vpn/src/main/tray-icon-controller.ts
index 92b862c3fc..e5b20ebef5 100644
--- a/desktop/packages/mullvad-vpn/src/main/tray-icon-controller.ts
+++ b/desktop/packages/mullvad-vpn/src/main/tray-icon-controller.ts
@@ -153,7 +153,7 @@ export default class TrayIconController {
}
private getImagePath(frame: number, suffix?: string) {
- const basePath = path.resolve(__dirname, 'assets/images/menubar-icons');
+ const basePath = path.resolve(import.meta.dirname, 'assets/images/menubar-icons');
const extension = process.platform === 'win32' ? 'ico' : 'png';
return path.join(basePath, process.platform, `lock-${frame}${suffix}.${extension}`);
}
diff --git a/desktop/packages/mullvad-vpn/src/main/user-interface.ts b/desktop/packages/mullvad-vpn/src/main/user-interface.ts
index 96af5ca7e4..420042d0e5 100644
--- a/desktop/packages/mullvad-vpn/src/main/user-interface.ts
+++ b/desktop/packages/mullvad-vpn/src/main/user-interface.ts
@@ -198,7 +198,7 @@ export default class UserInterface implements WindowControllerDelegate {
if (process.env.NODE_ENV === 'development' && process.env.VITE_DEV_SERVER_URL) {
await window.loadURL(process.env.VITE_DEV_SERVER_URL);
} else {
- await window.loadFile(path.join(__dirname, 'index.html'));
+ await window.loadFile(path.join(import.meta.dirname, 'index.html'));
}
} catch (e) {
const error = e as Error;
@@ -294,7 +294,7 @@ export default class UserInterface implements WindowControllerDelegate {
show: false,
frame: unpinnedWindow,
webPreferences: {
- preload: path.join(__dirname, 'preload.js'),
+ preload: path.join(import.meta.dirname, 'preload.js'),
nodeIntegration: false,
nodeIntegrationInWorker: false,
nodeIntegrationInSubFrames: false,
diff --git a/desktop/packages/mullvad-vpn/src/renderer/index.ts b/desktop/packages/mullvad-vpn/src/renderer/index.tsx
index fbf8ebcdba..cbb58d4088 100644
--- a/desktop/packages/mullvad-vpn/src/renderer/index.ts
+++ b/desktop/packages/mullvad-vpn/src/renderer/index.tsx
@@ -1,8 +1,10 @@
import { createRoot } from 'react-dom/client';
import App from './app';
+// import { TestApp } from './test-app';
const app = new App();
const container = document.getElementById('app');
const root = createRoot(container!);
root.render(app.renderView());
+// root.render(<TestApp />);
diff --git a/desktop/packages/mullvad-vpn/src/renderer/test-app.tsx b/desktop/packages/mullvad-vpn/src/renderer/test-app.tsx
new file mode 100644
index 0000000000..a50cdafd8f
--- /dev/null
+++ b/desktop/packages/mullvad-vpn/src/renderer/test-app.tsx
@@ -0,0 +1,51 @@
+import React from 'react';
+import { Provider } from 'react-redux';
+import { Router } from 'react-router';
+import { StyleSheetManager } from 'styled-components';
+
+import ErrorBoundary from './components/ErrorBoundary';
+import KeyboardNavigation from './components/KeyboardNavigation';
+import { ModalContainer } from './components/Modal';
+import { AppContext, useAppContext } from './context';
+import { Theme } from './lib/components';
+import History from './lib/history';
+
+function Child() {
+ const { value } = useAppContext();
+ return <div>react renders: {value}</div>;
+}
+
+const history = new History({
+ pathname: '/',
+});
+
+export function TestApp() {
+ const value = React.useMemo(() => {
+ return {
+ app: {
+ value: 'testaa',
+ },
+ };
+ }, []);
+
+ return (
+ <div>
+ <AppContext value={value}>
+ <Child />
+ <StyleSheetManager enableVendorPrefixes>
+ <Router history={history.asHistory}>
+ <Theme>
+ <ErrorBoundary>
+ <ModalContainer>
+ <KeyboardNavigation>
+ <div>children rendered</div>
+ </KeyboardNavigation>
+ </ModalContainer>
+ </ErrorBoundary>
+ </Theme>
+ </Router>
+ </StyleSheetManager>
+ </AppContext>
+ </div>
+ );
+}
diff --git a/desktop/packages/mullvad-vpn/tasks/build-production.js b/desktop/packages/mullvad-vpn/tasks/build-production.cjs
index 09b141d2c5..6f61abcf6e 100644
--- a/desktop/packages/mullvad-vpn/tasks/build-production.js
+++ b/desktop/packages/mullvad-vpn/tasks/build-production.cjs
@@ -1,5 +1,5 @@
-const { build } = require('./build');
-const { setNodeEnvironment } = require('./utils');
+const { build } = require('./build.cjs');
+const { setNodeEnvironment } = require('./utils.cjs');
async function buildProduction() {
setNodeEnvironment('production');
diff --git a/desktop/packages/mullvad-vpn/tasks/build-standalone.js b/desktop/packages/mullvad-vpn/tasks/build-standalone.cjs
index 37c6c3cd81..37c6c3cd81 100644
--- a/desktop/packages/mullvad-vpn/tasks/build-standalone.js
+++ b/desktop/packages/mullvad-vpn/tasks/build-standalone.cjs
diff --git a/desktop/packages/mullvad-vpn/tasks/build-test.js b/desktop/packages/mullvad-vpn/tasks/build-test.cjs
index c09ff10f92..c09ff10f92 100644
--- a/desktop/packages/mullvad-vpn/tasks/build-test.js
+++ b/desktop/packages/mullvad-vpn/tasks/build-test.cjs
diff --git a/desktop/packages/mullvad-vpn/tasks/build.js b/desktop/packages/mullvad-vpn/tasks/build.cjs
index 5ce22e9664..5ce22e9664 100644
--- a/desktop/packages/mullvad-vpn/tasks/build.js
+++ b/desktop/packages/mullvad-vpn/tasks/build.cjs
diff --git a/desktop/packages/mullvad-vpn/tasks/distribution.js b/desktop/packages/mullvad-vpn/tasks/distribution.cjs
index 1ab4588a39..1ab4588a39 100644
--- a/desktop/packages/mullvad-vpn/tasks/distribution.js
+++ b/desktop/packages/mullvad-vpn/tasks/distribution.cjs
diff --git a/desktop/packages/mullvad-vpn/tasks/pack-linux.js b/desktop/packages/mullvad-vpn/tasks/pack-linux.cjs
index 80ef9ad206..80ef9ad206 100644
--- a/desktop/packages/mullvad-vpn/tasks/pack-linux.js
+++ b/desktop/packages/mullvad-vpn/tasks/pack-linux.cjs
diff --git a/desktop/packages/mullvad-vpn/tasks/pack-mac.js b/desktop/packages/mullvad-vpn/tasks/pack-mac.cjs
index 49fa03dd50..49fa03dd50 100644
--- a/desktop/packages/mullvad-vpn/tasks/pack-mac.js
+++ b/desktop/packages/mullvad-vpn/tasks/pack-mac.cjs
diff --git a/desktop/packages/mullvad-vpn/tasks/pack-windows.js b/desktop/packages/mullvad-vpn/tasks/pack-windows.cjs
index cc830cb712..cc830cb712 100644
--- a/desktop/packages/mullvad-vpn/tasks/pack-windows.js
+++ b/desktop/packages/mullvad-vpn/tasks/pack-windows.cjs
diff --git a/desktop/packages/mullvad-vpn/tasks/utils.js b/desktop/packages/mullvad-vpn/tasks/utils.cjs
index ac18bc9980..ac18bc9980 100644
--- a/desktop/packages/mullvad-vpn/tasks/utils.js
+++ b/desktop/packages/mullvad-vpn/tasks/utils.cjs
diff --git a/desktop/packages/mullvad-vpn/test/e2e/setup/main.ts b/desktop/packages/mullvad-vpn/test/e2e/setup/main.ts
index 3b99f2043e..eae0bce4bd 100644
--- a/desktop/packages/mullvad-vpn/test/e2e/setup/main.ts
+++ b/desktop/packages/mullvad-vpn/test/e2e/setup/main.ts
@@ -100,7 +100,7 @@ class ApplicationMain {
frame: true,
webPreferences: {
offscreen: CI_E2E && !TEST_SHOW_WINDOW,
- preload: path.join(__dirname, 'preload.js'),
+ preload: path.join(import.meta.dirname, 'preload.js'),
nodeIntegration: false,
nodeIntegrationInWorker: false,
nodeIntegrationInSubFrames: false,
@@ -115,7 +115,7 @@ class ApplicationMain {
this.registerIpcListeners();
- await window.loadFile(path.join(__dirname, 'index.html'));
+ await window.loadFile(path.join(import.meta.dirname, 'index.html'));
if (process.argv.includes('--show-window')) {
window.show();
diff --git a/desktop/packages/mullvad-vpn/tsconfig.json b/desktop/packages/mullvad-vpn/tsconfig.json
index 5c48d0dabe..63ac9d39fa 100644
--- a/desktop/packages/mullvad-vpn/tsconfig.json
+++ b/desktop/packages/mullvad-vpn/tsconfig.json
@@ -11,9 +11,9 @@
"assets"
],
"skipLibCheck": true,
- "target": "es2021",
+ "target": "es2022",
"lib": [
- "es2021",
+ "es2022",
"dom"
],
"typeRoots": [
diff --git a/desktop/packages/mullvad-vpn/vite.config.ts b/desktop/packages/mullvad-vpn/vite.config.ts
index 8085e82cbb..6cf57ae111 100644
--- a/desktop/packages/mullvad-vpn/vite.config.ts
+++ b/desktop/packages/mullvad-vpn/vite.config.ts
@@ -112,6 +112,13 @@ const viteConfig = defineConfig({
vite: {
build: {
outDir: OUT_DIR,
+ rollupOptions: {
+ output: {
+ // We have to specify preload.js here as otherwise it would
+ // use the '.mjs' file extension.
+ entryFileNames: 'preload.js',
+ },
+ },
},
},
},