Skip to content

Build your personal knowledge base with Trilium Notes

chore(edit-docs): switch to esbuild

Elian Doranbe8749d84e40
diff --git a/apps/edit-docs/package.json b/apps/edit-docs/package.json
index d38029b5f0..ea13095e52 100644
--- a/apps/edit-docs/package.json
+++ b/apps/edit-docs/package.json
@@ -17,6 +17,51 @@
"server"
],
"targets": {
+ "build": {
+ "executor": "@nx/esbuild:esbuild",
+ "outputs": [
+ "{options.outputPath}"
+ ],
+ "options": {
+ "main": "apps/edit-docs/src/electron-edit-demo.ts",
+ "outputPath": "apps/edit-docs/dist",
+ "outputFileName": "main.js",
+ "tsConfig": "apps/edit-docs/tsconfig.app.json",
+ "platform": "node",
+ "external": [
+ "electron",
+ "@electron/remote",
+ "better-sqlite3",
+ "./xhr-sync-worker.js"
+ ],
+ "format": [
+ "cjs"
+ ],
+ "assets": [
+ {
+ "glob": "**/*",
+ "input": "apps/server/dist/node_modules",
+ "output": "node_modules"
+ },
+ {
+ "glob": "**/*",
+ "input": "apps/server/dist/assets",
+ "output": "assets"
+ },
+ {
+ "glob": "**/*",
+ "input": "apps/server/dist/public",
+ "output": "public"
+ },
+ {
+ "glob": "xhr-sync-worker.js",
+ "input": "apps/server/node_modules/jsdom/lib/jsdom/living/xhr",
+ "output": ""
+ }
+ ],
+ "declarationRootDir": "apps/edit-docs/src"
+ }
+ },
"rebuild-deps": {
"executor": "nx:run-commands",
"dependsOn": [
@@ -41,13 +86,31 @@
"defaultConfiguration": "default",
"configurations": {
"default": {
- "command": "electron .",
- "cwd": "./apps/edit-docs/dist"
+ "command": "electron main.cjs",
+ "cwd": "{projectRoot}/dist"
+ },
+ "nixos": {
+ "command": "nix-shell -p electron_35 --run \"electron {projectRoot}/dist/main.cjs\"",
+ "cwd": ".",
+ "forwardAllArgs": false
+ }
+ }
+ },
+ "serve-nodir": {
+ "executor": "nx:run-commands",
+ "dependsOn": [
+ "rebuild-deps"
+ ],
+ "defaultConfiguration": "default",
+ "configurations": {
+ "default": {
+ "command": "electron main.cjs",
+ "cwd": "{projectRoot}/dist"
},
"nixos": {
- "command": "nix-shell -p electron_35 --run \"electron .\"",
- "forwardAllArgs": false,
- "cwd": "./apps/edit-docs/dist"
+ "command": "nix-shell -p electron_35 --run \"electron {projectRoot}/dist/main.cjs\"",
+ "cwd": ".",
+ "forwardAllArgs": false
}
}
}
@@ -56,4 +119,4 @@
"dependencies": {
"archiver": "7.0.1"
}
-}
+}
\ No newline at end of file
diff --git a/apps/edit-docs/src/electron-docs-main.ts b/apps/edit-docs/src/electron-docs-main.ts
index 52121df3a0..ac1baa107b 100644
--- a/apps/edit-docs/src/electron-docs-main.ts
+++ b/apps/edit-docs/src/electron-docs-main.ts
@@ -15,6 +15,7 @@ import { parseNoteMetaFile } from "@triliumnext/server/src/services/in_app_help.
import { resolve } from "path";
import electron from "electron";
import { onReady } from "@triliumnext/desktop/src/electron-main.js";
+import type NoteMeta from "@triliumnext/server/src/services/meta/note_meta.js";
interface NoteMapping {
rootNoteId: string;
diff --git a/apps/edit-docs/src/electron-edit-demo.ts b/apps/edit-docs/src/electron-edit-demo.ts
index 17fb59e572..204e9220aa 100644
--- a/apps/edit-docs/src/electron-edit-demo.ts
+++ b/apps/edit-docs/src/electron-edit-demo.ts
@@ -40,4 +40,4 @@ async function exportData() {
await exportToZipFile("root", "html", DEMO_ZIP_PATH);
}
-await main();
+main();
diff --git a/apps/edit-docs/tsconfig.app.json b/apps/edit-docs/tsconfig.app.json
index 2479661aa7..b9e17115a0 100644
--- a/apps/edit-docs/tsconfig.app.json
+++ b/apps/edit-docs/tsconfig.app.json
@@ -1,16 +1,21 @@
{
"extends": "../../tsconfig.base.json",
"compilerOptions": {
+ "module": "ESNext",
+ "moduleResolution": "bundler",
+ "target": "ES2020",
"outDir": "dist",
+ "strict": false,
"types": [
- "node"
+ "node",
+ "express"
],
"rootDir": "src",
- "tsBuildInfoFile": "dist/tsconfig.app.tsbuildinfo",
- "verbatimModuleSyntax": false
+ "tsBuildInfoFile": "dist/tsconfig.app.tsbuildinfo"
},
"include": [
- "src/**/*.ts"
+ "src/**/*.ts",
+ "../server/src/*.d.ts"
],
"exclude": [
"eslint.config.js",
diff --git a/apps/edit-docs/webpack.config.cjs b/apps/edit-docs/webpack.config.cjs
deleted file mode 100644
index 1ae774de74..0000000000
--- a/apps/edit-docs/webpack.config.cjs
+++ /dev/null
@@ -1,53 +0,0 @@
-const { NxAppWebpackPlugin } = require('@nx/webpack/app-plugin');
-const CopyPlugin = require('copy-webpack-plugin');
-const { join } = require('path');
-
-const outputDir = join(__dirname, 'dist');
-
-module.exports = {
- output: {
- path: join(__dirname, 'dist'),
- },
- module: {
- rules: [
- {
- test: /\.css$/i,
- type: "asset/source"
- }
- ]
- },
- plugins: [
- new NxAppWebpackPlugin({
- target: 'node',
- compiler: 'tsc',
- main: './src/electron-docs-main.ts',
- tsConfig: './tsconfig.app.json',
- optimization: false,
- outputHashing: 'none',
- generatePackageJson: true,
- externalDependencies: [
- "electron/main",
- "@electron/remote/main",
- "electron",
- "@electron/remote",
- "better-sqlite3"
- ]
- }),
- new CopyPlugin({
- patterns: [
- {
- from: "../desktop/dist/node_modules",
- to: join(outputDir, "node_modules")
- },
- {
- from: "../desktop/dist/assets",
- to: join(outputDir, "assets")
- },
- {
- from: "../desktop/dist/public",
- to: join(outputDir, "public")
- },
- ]
- })
- ],
-};