A fully open source & end-to-end encrypted note taking alternative to Evernote.
TypeScript asp-net-coredotnet-coreelectronfosshacktoberfestnote-managmentnote-takingnote-taking-appnotebooknotesnotes-appopen-sourceopensourceprivacyproductivityreactreact-nativereactjsself-hosted
core: don't use require in desktop app
Abdullah Atta0cd1ce3431b1
diff --git a/packages/core/utils/templates/html/builder.js b/packages/core/utils/templates/html/builder.jsindex 2b17892f7..54c289753 100644--- a/packages/core/utils/templates/html/builder.js+++ b/packages/core/utils/templates/html/builder.js@@ -95,5 +95,5 @@ async function preprocessHTML(templateData) {export default { buildHTML };function hasRequire() {- return typeof require === "function";+ return typeof require === "function" && !("IS_DESKTOP_APP" in globalThis);}diff --git a/packages/editor/scripts/build.mjs b/packages/editor/scripts/build.mjsindex a2dcf6bb7..99a03eced 100755--- a/packages/editor/scripts/build.mjs+++ b/packages/editor/scripts/build.mjs@@ -42,14 +42,18 @@ for (const name in pathsToCopy) {}const languagesList = await langen(ROOT_DIR, path.join(ROOT_DIR, "languages"));-const languageIndex = `export async function loadLanguage(language) {+const languageIndex = `function hasRequire() {+ return typeof require === "function" && !("IS_DESKTOP_APP" in globalThis);+}++export async function loadLanguage(language) {switch (language) {${languagesList.map(({ filename, alias }) => {return [...(alias || []).map((a) => `case "${a}":`),`case "${filename}":`,- `return typeof require === "function" ? require("./${filename}.js") : await import("./${filename}.js");`+ `return hasRequire() ? require("./${filename}.js") : await import("./${filename}.js");`].join("\n");}).join("\n\n")}