mirror of
https://github.com/streetwriters/notesnook.git
synced 2026-02-24 04:00:59 +01:00
web: support top-level-await transform in desktop builds
This commit is contained in:
1087
apps/web/package-lock.json
generated
1087
apps/web/package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@@ -101,6 +101,7 @@
|
||||
"vite-plugin-env-compatible": "^1.1.1",
|
||||
"vite-plugin-pwa": "^0.16.3",
|
||||
"vite-plugin-svgr": "^3.2.0",
|
||||
"vite-plugin-top-level-await": "^1.3.1",
|
||||
"vitest": "^0.32.0",
|
||||
"workbox-core": "^7.0.0",
|
||||
"workbox-expiration": "^7.0.0",
|
||||
|
||||
@@ -21,9 +21,7 @@ import { type desktop as bridge } from "./bridge";
|
||||
|
||||
export const desktop: typeof bridge | undefined =
|
||||
import.meta.env.REACT_APP_PLATFORM === "desktop"
|
||||
? process.env.NODE_ENV === "development"
|
||||
? // eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
||||
// @ts-ignore
|
||||
(await import("./bridge")).desktop
|
||||
: require("./bridge.ts").desktop
|
||||
? // eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
||||
// @ts-ignore
|
||||
(await import("./bridge")).desktop
|
||||
: undefined;
|
||||
|
||||
@@ -23,6 +23,7 @@ import svgrPlugin from "vite-plugin-svgr";
|
||||
import envCompatible from "vite-plugin-env-compatible";
|
||||
import { VitePWA, ManifestOptions } from "vite-plugin-pwa";
|
||||
import path from "path";
|
||||
import topLevelAwait from "vite-plugin-top-level-await";
|
||||
|
||||
const WEB_MANIFEST: Partial<ManifestOptions> = {
|
||||
name: "Notesnook",
|
||||
@@ -142,6 +143,8 @@ const WEB_MANIFEST: Partial<ManifestOptions> = {
|
||||
const isTesting =
|
||||
process.env.REACT_APP_TEST === "true" ||
|
||||
process.env.NODE_ENV === "development";
|
||||
const isDesktop = process.env.REACT_APP_PLATFORM === "desktop";
|
||||
|
||||
export default defineConfig({
|
||||
envPrefix: "REACT_APP_",
|
||||
build: {
|
||||
@@ -171,6 +174,16 @@ export default defineConfig({
|
||||
format: "es"
|
||||
},
|
||||
plugins: [
|
||||
...(isDesktop
|
||||
? [
|
||||
topLevelAwait({
|
||||
// The export name of top-level await promise for each chunk module
|
||||
promiseExportName: "__tla",
|
||||
// The function to generate import names of top-level await promise in each chunk module
|
||||
promiseImportName: (i) => `__tla_${i}`
|
||||
})
|
||||
]
|
||||
: []),
|
||||
VitePWA({
|
||||
strategies: "injectManifest",
|
||||
minify: true,
|
||||
|
||||
Reference in New Issue
Block a user