nukejs 0.0.16 → 0.0.18

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.
@@ -731,6 +731,8 @@ async function bundleClientComponents(globalRegistry, pagesDir, staticDir) {
731
731
  platform: "browser",
732
732
  jsx: "automatic",
733
733
  minify: true,
734
+ conditions: ["module", "browser", "import"],
735
+ banner: { js: `const require=(m)=>{if(m==='react')return window.__nukejs_react__;if(m==='react/jsx-runtime')return window.__nukejs_jsx__;throw new Error('Dynamic require of "'+m+'" is not supported');};` },
734
736
  external: ["react", "react-dom/client", "react/jsx-runtime"],
735
737
  define: { "process.env.NODE_ENV": '"production"' },
736
738
  write: false
@@ -821,6 +823,10 @@ export {
821
823
  hydrateRoot, createRoot, jsx, jsxs
822
824
  };
823
825
  export default React;
826
+ // Expose React on window so CJS packages that call require('react')
827
+ // at runtime can resolve it via the __nukejs_require__ shim.
828
+ window.__nukejs_react__ = React;
829
+ window.__nukejs_jsx__ = { jsx, jsxs };
824
830
  `,
825
831
  loader: "ts",
826
832
  resolveDir: nukeDir
package/dist/bundler.js CHANGED
@@ -13,6 +13,12 @@ async function bundleClientComponent(filePath) {
13
13
  platform: "browser",
14
14
  write: false,
15
15
  jsx: "automatic",
16
+ // Prefer ESM exports from dual-mode packages (e.g. radix-ui) to avoid
17
+ // CJS require() calls that break in an ESM context at runtime.
18
+ conditions: ["module", "browser", "import"],
19
+ // Shim require() for CJS-only packages that call require('react') at
20
+ // runtime. Resolves to the already-loaded React instance on window.
21
+ banner: { js: `const require=(m)=>{if(m==='react')return window.__nukejs_react__;if(m==='react/jsx-runtime')return window.__nukejs_jsx__;throw new Error('Dynamic require of "'+m+'" is not supported');};` },
16
22
  // Keep React external — resolved by the importmap to /__react.js
17
23
  external: ["react", "react-dom/client", "react/jsx-runtime"]
18
24
  });
@@ -58,6 +64,10 @@ async function serveReactBundle(res) {
58
64
  hydrateRoot, createRoot, jsx, jsxs
59
65
  };
60
66
  export default React;
67
+ // Expose React on window so CJS packages that call require('react')
68
+ // at runtime can resolve it via the __nukejs_require__ shim.
69
+ window.__nukejs_react__ = React;
70
+ window.__nukejs_jsx__ = { jsx, jsxs };
61
71
  `,
62
72
  loader: "ts"
63
73
  },
@@ -88,7 +98,7 @@ async function serveNukeBundle(res) {
88
98
  format: "esm",
89
99
  minify: true,
90
100
  bundle: true,
91
- external: ["react", "react-dom/client"]
101
+ external: ["react", "react-dom/client", "react/jsx-runtime"]
92
102
  }).then((r) => r.outputFiles[0].text);
93
103
  }
94
104
  res.setHeader("Content-Type", "application/javascript");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nukejs",
3
- "version": "0.0.16",
3
+ "version": "0.0.18",
4
4
  "description": "A minimal, opinionated full-stack React framework on Node.js that server-renders everything and hydrates only interactive parts.",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",