mirror of
https://github.com/zulip/zulip-desktop.git
synced 2025-10-22 19:21:57 +00:00
Switch to "type": "module".
Signed-off-by: Anders Kaseorg <anders@zulip.com>
This commit is contained in:
@@ -32,7 +32,7 @@ import {sentryInit} from "./sentry.ts";
|
||||
import {setAutoLaunch} from "./startup.ts";
|
||||
import {ipcMain, send} from "./typed-ipc-main.ts";
|
||||
|
||||
import "gatemaker/electron-setup"; // eslint-disable-line import/no-unassigned-import
|
||||
import "gatemaker/electron-setup.js"; // eslint-disable-line import/no-unassigned-import
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/naming-convention
|
||||
const {GDK_BACKEND} = process.env;
|
||||
@@ -87,7 +87,7 @@ function createMainWindow(): BrowserWindow {
|
||||
minWidth: 500,
|
||||
minHeight: 400,
|
||||
webPreferences: {
|
||||
preload: path.join(bundlePath, "renderer.js"),
|
||||
preload: path.join(bundlePath, "renderer.cjs"),
|
||||
sandbox: false,
|
||||
webviewTag: true,
|
||||
},
|
||||
|
@@ -412,7 +412,7 @@ export class ServerManagerView {
|
||||
await this.openNetworkTroubleshooting(index);
|
||||
},
|
||||
onTitleChange: this.updateBadge.bind(this),
|
||||
preload: url.pathToFileURL(path.join(bundlePath, "preload.js")).href,
|
||||
preload: url.pathToFileURL(path.join(bundlePath, "preload.cjs")).href,
|
||||
unsupportedMessage: DomainUtil.getUnsupportedMessage(server),
|
||||
}),
|
||||
});
|
||||
|
@@ -1,6 +1,4 @@
|
||||
"use strict";
|
||||
|
||||
module.exports = {
|
||||
const config = {
|
||||
createOldCatalogs: false,
|
||||
defaultValue: (locale, namespace, key, value) =>
|
||||
locale === "en" ? key : value,
|
||||
@@ -15,3 +13,4 @@ module.exports = {
|
||||
output: "public/translations/$LOCALE.json",
|
||||
sort: (a, b) => (a < b ? -1 : a > b ? 1 : 0),
|
||||
};
|
||||
export default config;
|
||||
|
@@ -2,7 +2,7 @@
|
||||
"name": "zulip",
|
||||
"productName": "Zulip",
|
||||
"version": "5.12.0",
|
||||
"main": "./dist-electron",
|
||||
"main": "./dist-electron/index.cjs",
|
||||
"description": "Zulip Desktop App",
|
||||
"license": "Apache-2.0",
|
||||
"copyright": "Kandra Labs, Inc.",
|
||||
@@ -17,6 +17,7 @@
|
||||
"bugs": {
|
||||
"url": "https://github.com/zulip/zulip-desktop/issues"
|
||||
},
|
||||
"type": "module",
|
||||
"engines": {
|
||||
"node": ">=18"
|
||||
},
|
||||
|
@@ -1,12 +1,11 @@
|
||||
"use strict";
|
||||
const {chan, put, take} = require("medium");
|
||||
const test = require("tape");
|
||||
import {chan, put, take} from "medium";
|
||||
import test from "tape";
|
||||
|
||||
const setup = require("./setup.js");
|
||||
import * as setup from "./setup.js";
|
||||
|
||||
test("app runs", async (t) => {
|
||||
t.timeoutAfter(10e3);
|
||||
setup.resetTestDataDir();
|
||||
setup.resetTestDataDirectory();
|
||||
const app = await setup.createApp();
|
||||
try {
|
||||
const windows = chan();
|
||||
|
@@ -1,5 +1,6 @@
|
||||
{
|
||||
"version": "5.9.3",
|
||||
"productName": "ZulipTest",
|
||||
"main": "../dist-electron"
|
||||
"type": "module",
|
||||
"main": "../dist-electron/index.cjs"
|
||||
}
|
||||
|
@@ -1,28 +1,23 @@
|
||||
"use strict";
|
||||
const fs = require("node:fs");
|
||||
const path = require("node:path");
|
||||
const process = require("node:process");
|
||||
import fs from "node:fs";
|
||||
import path from "node:path";
|
||||
import process from "node:process";
|
||||
|
||||
const {_electron} = require("playwright-core");
|
||||
import {_electron} from "playwright-core";
|
||||
|
||||
const testsPkg = require("./package.json");
|
||||
|
||||
module.exports = {
|
||||
createApp,
|
||||
endTest,
|
||||
resetTestDataDir: resetTestDataDirectory,
|
||||
};
|
||||
const testsPackage = JSON.parse(
|
||||
fs.readFileSync(new URL("package.json", import.meta.url), "utf8"),
|
||||
);
|
||||
|
||||
// Runs Zulip Desktop.
|
||||
// Returns a promise that resolves to an Electron Application once the app has loaded.
|
||||
function createApp() {
|
||||
export function createApp() {
|
||||
return _electron.launch({
|
||||
args: [path.join(__dirname)], // Ensure this dir has a package.json file with a 'main' entry point
|
||||
args: [import.meta.dirname], // Ensure this dir has a package.json file with a 'main' entry point
|
||||
});
|
||||
}
|
||||
|
||||
// Quit the app, end the test
|
||||
async function endTest(app) {
|
||||
export async function endTest(app) {
|
||||
await app.close();
|
||||
}
|
||||
|
||||
@@ -52,11 +47,11 @@ function getAppDataDirectory() {
|
||||
}
|
||||
|
||||
console.log("Detected App Data Dir base:", base);
|
||||
return path.join(base, testsPkg.productName);
|
||||
return path.join(base, testsPackage.productName);
|
||||
}
|
||||
|
||||
// Resets the test directory, containing domain.json, window-state.json, etc
|
||||
function resetTestDataDirectory() {
|
||||
export function resetTestDataDirectory() {
|
||||
const appDataDirectory = getAppDataDirectory();
|
||||
fs.rmSync(appDataDirectory, {force: true, recursive: true});
|
||||
}
|
||||
|
@@ -1,12 +1,11 @@
|
||||
"use strict";
|
||||
const {chan, put, take} = require("medium");
|
||||
const test = require("tape");
|
||||
import {chan, put, take} from "medium";
|
||||
import test from "tape";
|
||||
|
||||
const setup = require("./setup.js");
|
||||
import * as setup from "./setup.js";
|
||||
|
||||
test("add-organization", async (t) => {
|
||||
t.timeoutAfter(50e3);
|
||||
setup.resetTestDataDir();
|
||||
setup.resetTestDataDirectory();
|
||||
const app = await setup.createApp();
|
||||
try {
|
||||
const windows = chan();
|
||||
|
@@ -1,14 +1,13 @@
|
||||
"use strict";
|
||||
const {chan, put, take} = require("medium");
|
||||
const test = require("tape");
|
||||
import {chan, put, take} from "medium";
|
||||
import test from "tape";
|
||||
|
||||
const setup = require("./setup.js");
|
||||
import * as setup from "./setup.js";
|
||||
|
||||
// Create new org link should open in the default browser [WIP]
|
||||
|
||||
test("new-org-link", async (t) => {
|
||||
t.timeoutAfter(50e3);
|
||||
setup.resetTestDataDir();
|
||||
setup.resetTestDataDirectory();
|
||||
const app = await setup.createApp();
|
||||
try {
|
||||
const windows = chan();
|
||||
|
@@ -1,7 +1,5 @@
|
||||
/* eslint-disable @typescript-eslint/naming-convention */
|
||||
|
||||
import * as path from "node:path";
|
||||
|
||||
import {defineConfig} from "vite";
|
||||
import electron from "vite-plugin-electron";
|
||||
|
||||
@@ -9,14 +7,20 @@ export default defineConfig({
|
||||
plugins: [
|
||||
electron([
|
||||
{
|
||||
entry: {
|
||||
index: "app/main",
|
||||
},
|
||||
vite: {
|
||||
build: {
|
||||
lib: {
|
||||
entry: {
|
||||
index: "app/main",
|
||||
},
|
||||
formats: ["cjs"],
|
||||
},
|
||||
sourcemap: true,
|
||||
rollupOptions: {
|
||||
external: ["electron", /^electron\//, /^gatemaker\//],
|
||||
output: {
|
||||
entryFileNames: "[name].cjs",
|
||||
},
|
||||
},
|
||||
ssr: true,
|
||||
},
|
||||
@@ -31,27 +35,39 @@ export default defineConfig({
|
||||
},
|
||||
},
|
||||
{
|
||||
entry: {
|
||||
preload: "app/renderer/js/preload.ts",
|
||||
},
|
||||
vite: {
|
||||
build: {
|
||||
lib: {
|
||||
entry: {
|
||||
preload: "app/renderer/js/preload.ts",
|
||||
},
|
||||
formats: ["cjs"],
|
||||
},
|
||||
sourcemap: "inline",
|
||||
rollupOptions: {
|
||||
external: ["electron", /^electron\//],
|
||||
output: {
|
||||
entryFileNames: "[name].cjs",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
entry: {
|
||||
renderer: "app/renderer/js/main.ts",
|
||||
},
|
||||
vite: {
|
||||
build: {
|
||||
lib: {
|
||||
entry: {
|
||||
renderer: "app/renderer/js/main.ts",
|
||||
},
|
||||
formats: ["cjs"],
|
||||
},
|
||||
sourcemap: true,
|
||||
rollupOptions: {
|
||||
external: ["electron", /^electron\//],
|
||||
output: {
|
||||
entryFileNames: "[name].cjs",
|
||||
},
|
||||
},
|
||||
},
|
||||
resolve: {
|
||||
@@ -68,10 +84,10 @@ export default defineConfig({
|
||||
sourcemap: true,
|
||||
rollupOptions: {
|
||||
input: {
|
||||
renderer: path.join(__dirname, "app/renderer/main.html"),
|
||||
network: path.join(__dirname, "app/renderer/network.html"),
|
||||
about: path.join(__dirname, "app/renderer/about.html"),
|
||||
preference: path.join(__dirname, "app/renderer/preference.html"),
|
||||
renderer: "app/renderer/main.html",
|
||||
network: "app/renderer/network.html",
|
||||
about: "app/renderer/about.html",
|
||||
preference: "app/renderer/preference.html",
|
||||
},
|
||||
},
|
||||
},
|
||||
|
@@ -128,12 +128,7 @@ module.exports = {
|
||||
},
|
||||
},
|
||||
{
|
||||
files: [
|
||||
"**.cjs",
|
||||
"i18next-parser.config.js",
|
||||
"scripts/win-sign.js",
|
||||
"tests/**/*.js",
|
||||
],
|
||||
files: ["**.cjs"],
|
||||
parserOptions: {
|
||||
sourceType: "script",
|
||||
},
|
||||
|
Reference in New Issue
Block a user