Skip to content

typeof process==='undefined' as a browser check can fail #41

@glib-0

Description

@glib-0

For reasons, I have polyfills such that process in my browser environment is not undefined, so scribe attempts to follow the Node codepath and does not work at all.

It would be helpful if the browser check were amended to something like typeof process==='undefined' || process?.title === 'browser' or typeof process==='undefined' || typeof window==='object' (might fail if using a mock window in Node?)

For reference, I am using Preact with Tauri, and Vite config is

import { nodePolyfills } from "vite-plugin-node-polyfills";
import preact from "@preact/preset-vite";
import { defineConfig } from "vite";
export default defineConfig(async () => ({
	plugins: [preact(), nodePolyfills()],
	build: { commonjsOptions: { transformMixedEsModules: true } },
	// Vite options tailored for Tauri development and only applied in `tauri dev` or `tauri build`
	//
	// 1. prevent vite from obscuring rust errors
	clearScreen: false,
	// 2. tauri expects a fixed port, fail if that port is not available
	server: {
		port: 1420,
		strictPort: true,
		watch: {
			// 3. tell vite to ignore watching `src-tauri`
			ignored: ["**/src-tauri/**"]
		}
	}
}));

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions