@erikey/react 0.2.7 → 0.2.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{chunk-E3EMTIQ5.mjs → chunk-K57QXNQP.mjs} +10 -10
- package/dist/chunk-K57QXNQP.mjs.map +1 -0
- package/dist/index.mjs +8 -1
- package/dist/index.mjs.map +1 -1
- package/dist/ui/index.mjs +8 -1
- package/dist/ui/index.mjs.map +1 -1
- package/package.json +1 -1
- package/dist/chunk-E3EMTIQ5.mjs.map +0 -1
package/package.json
CHANGED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/require-shim.ts"],"sourcesContent":["/**\n * CJS Require Shim for Browser Environments\n *\n * This module MUST be imported at the very top of entry points (index.ts, ui/index.tsx)\n * BEFORE any other imports that might trigger CJS code.\n *\n * ## Why This Exists\n *\n * We bundle `better-auth` and `@daveyplate/better-auth-ui` into @erikey/react.\n * These packages depend on `use-sync-external-store` which ONLY ships CommonJS.\n * The CJS code contains `require(\"react\")` calls.\n *\n * When tsup/esbuild bundles CJS into ESM, it wraps require() calls in a `__require()`\n * helper that throws \"Dynamic require of X is not supported\" in browsers.\n *\n * The __require helper checks `typeof require !== \"undefined\"` first.\n * If require exists, it uses it. If not, it throws.\n *\n * ## How This Shim Works\n *\n * We set `globalThis.require` BEFORE the __require helper is initialized.\n * This makes `typeof require` return \"function\" instead of \"undefined\".\n * The __require helper then uses our shim instead of throwing.\n *\n * ## Environment Handling\n *\n * **Production (Vite build):**\n * - No require function exists\n * - We set globalThis.require to our shim\n * - __require uses our shim → returns React\n *\n * **Sandpack Preview:**\n * - Sandpack provides its own require function\n * - typeof globalThis.require !== \"undefined\" → we DON'T override\n * - __require uses Sandpack's require → Sandpack provides React\n *\n * ## Critical Notes\n *\n * - This file MUST be in package.json sideEffects to prevent tree-shaking\n * - This MUST be the first import in entry points\n * - The module executes immediately on import (side effect)\n */\nimport * as React from 'react';\nimport * as ReactDOM from 'react-dom';\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nconst g = globalThis as any;\n\n// Only set require if it doesn't exist\n// Sandpack and other environments may provide their own\nif (typeof g.require === 'undefined') {\n g.require = function requireShim(moduleName: string): unknown {\n if (moduleName === 'react') return React;\n if (moduleName === 'react-dom') return ReactDOM;\n // For any other module, throw a clear error\n throw new Error(\n `[require-shim] Dynamic require of \"${moduleName}\" is not supported. ` +\n `Only \"react\" and \"react-dom\" are shimmed.`\n );\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA0CA,YAAY,WAAW;AACvB,YAAY,cAAc;AAG1B,IAAM,IAAI;AAIV,IAAI,OAAO,EAAE,YAAY,aAAa;AACpC,IAAE,UAAU,SAAS,YAAY,YAA6B;AAC5D,QAAI,eAAe,QAAS,QAAO;AACnC,QAAI,eAAe,YAAa,QAAO;AAEvC,UAAM,IAAI;AAAA,MACR,sCAAsC,UAAU;AAAA,IAElD;AAAA,EACF;AACF;","names":[]}
|