@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.
@@ -1,3 +1,10 @@
1
+ if (typeof globalThis.require === "undefined") {
2
+ globalThis.require = function(m) {
3
+ if (m === "react") return globalThis.__ERIKEY_REACT__;
4
+ if (m === "react-dom") return globalThis.__ERIKEY_REACT_DOM__;
5
+ throw new Error("[erikey/react] Dynamic require of " + m + " is not supported");
6
+ };
7
+ }
1
8
  var __create = Object.create;
2
9
  var __defProp = Object.defineProperty;
3
10
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
@@ -38,15 +45,8 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
38
45
  import * as React from "react";
39
46
  import * as ReactDOM from "react-dom";
40
47
  var g = globalThis;
41
- if (typeof g.require === "undefined") {
42
- g.require = function requireShim(moduleName) {
43
- if (moduleName === "react") return React;
44
- if (moduleName === "react-dom") return ReactDOM;
45
- throw new Error(
46
- `[require-shim] Dynamic require of "${moduleName}" is not supported. Only "react" and "react-dom" are shimmed.`
47
- );
48
- };
49
- }
48
+ g.__ERIKEY_REACT__ = React;
49
+ g.__ERIKEY_REACT_DOM__ = ReactDOM;
50
50
 
51
51
  export {
52
52
  __require,
@@ -54,4 +54,4 @@ export {
54
54
  __export,
55
55
  __toESM
56
56
  };
57
- //# sourceMappingURL=chunk-E3EMTIQ5.mjs.map
57
+ //# sourceMappingURL=chunk-K57QXNQP.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/require-shim.ts"],"sourcesContent":["/**\n * CJS Require Shim - Part 2: Global Registration\n *\n * This module works together with the banner in tsup.config.ts:\n *\n * ## Execution Order\n *\n * 1. Banner runs FIRST (before esbuild helpers)\n * - Sets globalThis.require that reads from __ERIKEY_REACT__\n *\n * 2. esbuild's __require helper initializes\n * - Sees `typeof require !== \"undefined\"` (our banner set it)\n * - Uses our require function instead of throwing\n *\n * 3. This module runs (after React imports are resolved)\n * - Sets globalThis.__ERIKEY_REACT__ = React\n * - Sets globalThis.__ERIKEY_REACT_DOM__ = ReactDOM\n *\n * 4. When CJS code calls require(\"react\")\n * - __require calls our require function\n * - Our function returns globalThis.__ERIKEY_REACT__ (now available)\n *\n * ## Sandpack Compatibility\n *\n * Sandpack provides its own require function, so:\n * - Banner check skips (require already exists)\n * - Sandpack's require is used instead\n * - We still set the globals (harmless, unused)\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// Register React modules for the banner's require shim to return\n// This runs AFTER React imports are resolved, making them available\ng.__ERIKEY_REACT__ = React;\ng.__ERIKEY_REACT_DOM__ = ReactDOM;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA6BA,YAAY,WAAW;AACvB,YAAY,cAAc;AAG1B,IAAM,IAAI;AAIV,EAAE,mBAAmB;AACrB,EAAE,uBAAuB;","names":[]}
package/dist/index.mjs CHANGED
@@ -1,4 +1,11 @@
1
- import "./chunk-E3EMTIQ5.mjs";
1
+ if (typeof globalThis.require === "undefined") {
2
+ globalThis.require = function(m) {
3
+ if (m === "react") return globalThis.__ERIKEY_REACT__;
4
+ if (m === "react-dom") return globalThis.__ERIKEY_REACT_DOM__;
5
+ throw new Error("[erikey/react] Dynamic require of " + m + " is not supported");
6
+ };
7
+ }
8
+ import "./chunk-K57QXNQP.mjs";
2
9
 
3
10
  // ../../../node_modules/.pnpm/@better-fetch+fetch@1.1.18/node_modules/@better-fetch/fetch/dist/index.js
4
11
  var __defProp = Object.defineProperty;