glashjs 0.13.4 → 0.13.5
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/package.json +1 -1
- package/src/server/jsx.mjs +11 -2
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "glashjs",
|
|
3
|
-
"version": "0.13.
|
|
3
|
+
"version": "0.13.5",
|
|
4
4
|
"description": "glashjs — The Postgres-native full-stack framework for builders who want to ship without DevOps. Framework, hosting, database, auth, and deploy in one GlashDB-native runtime.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
package/src/server/jsx.mjs
CHANGED
|
@@ -54,6 +54,15 @@ const REACT_ALIAS = {
|
|
|
54
54
|
'next/headers': path.join(pkgRoot, 'next/headers.mjs'),
|
|
55
55
|
};
|
|
56
56
|
|
|
57
|
+
// CJS deps bundled into an ESM server module (e.g. lucide-react -> require('react')
|
|
58
|
+
// -> aliased preact/compat, which is external) emit a dynamic require that ESM
|
|
59
|
+
// can't run ("Dynamic require of X is not supported"). Defining `require` via
|
|
60
|
+
// createRequire makes esbuild's __require shim use the real Node require, so those
|
|
61
|
+
// runtime requires resolve from the app's node_modules.
|
|
62
|
+
const NODE_ESM_REQUIRE_BANNER = {
|
|
63
|
+
js: "import { createRequire as __glashCreateRequire } from 'node:module';\nconst require = __glashCreateRequire(import.meta.url);",
|
|
64
|
+
};
|
|
65
|
+
|
|
57
66
|
export function isComponentRoute(file) {
|
|
58
67
|
return /\.(jsx|tsx)$/.test(file);
|
|
59
68
|
}
|
|
@@ -76,7 +85,7 @@ export async function compileModule(file, root, dev) {
|
|
|
76
85
|
entryPoints: [file], bundle: true, platform: 'node', format: 'esm',
|
|
77
86
|
jsx: 'automatic', jsxImportSource: 'preact',
|
|
78
87
|
external: ['preact', 'preact/*', 'preact-render-to-string'],
|
|
79
|
-
alias: REACT_ALIAS, outfile: out, logLevel: 'silent',
|
|
88
|
+
alias: REACT_ALIAS, banner: NODE_ESM_REQUIRE_BANNER, outfile: out, logLevel: 'silent',
|
|
80
89
|
});
|
|
81
90
|
return import(pathToFileURL(out).href + (dev ? `?t=${Date.now()}` : ''));
|
|
82
91
|
}
|
|
@@ -158,7 +167,7 @@ export async function loadComponentRoute(pageFile, layouts, root, dev, force = f
|
|
|
158
167
|
stdin: { contents: serverEntry(pageFile, layouts), resolveDir: path.dirname(pageFile), loader: 'js', sourcefile: 'glash-server-entry.js' },
|
|
159
168
|
bundle: true, platform: 'node', format: 'esm', jsx: 'automatic', jsxImportSource: 'preact',
|
|
160
169
|
external: ['preact', 'preact/*', 'preact-render-to-string'],
|
|
161
|
-
alias: REACT_ALIAS,
|
|
170
|
+
alias: REACT_ALIAS, banner: NODE_ESM_REQUIRE_BANNER,
|
|
162
171
|
outfile: out, logLevel: 'silent',
|
|
163
172
|
});
|
|
164
173
|
const mod = await import(pathToFileURL(out).href + (dev ? `?t=${Date.now()}` : ''));
|