houdini-adapter-static 2.0.0-next.27 → 2.0.0-next.29
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 +10 -10
- package/build/index.d.ts +0 -3
- package/build/index.js +0 -60
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "houdini-adapter-static",
|
|
3
|
-
"version": "2.0.0-next.
|
|
3
|
+
"version": "2.0.0-next.29",
|
|
4
4
|
"description": "The adapter for deploying your Houdini application as a single-page application without a server component",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"houdini",
|
|
@@ -19,18 +19,18 @@
|
|
|
19
19
|
"access": "public"
|
|
20
20
|
},
|
|
21
21
|
"devDependencies": {
|
|
22
|
-
"@types/node": "^
|
|
23
|
-
"@types/react-dom": "^19.
|
|
24
|
-
"csstype": "^3.
|
|
25
|
-
"tsup": "^
|
|
26
|
-
"typescript": "^
|
|
27
|
-
"undici-types": "^
|
|
22
|
+
"@types/node": "^25.9.1",
|
|
23
|
+
"@types/react-dom": "^19.2.3",
|
|
24
|
+
"csstype": "^3.2.3",
|
|
25
|
+
"tsup": "^8.5.1",
|
|
26
|
+
"typescript": "^6.0.3",
|
|
27
|
+
"undici-types": "^8.3.0",
|
|
28
28
|
"scripts": "^2.0.0-next.2"
|
|
29
29
|
},
|
|
30
30
|
"dependencies": {
|
|
31
|
-
"react": "^19.
|
|
32
|
-
"react-dom": "^19.
|
|
33
|
-
"houdini": "^2.0.0-next.
|
|
31
|
+
"react": "^19.2.7",
|
|
32
|
+
"react-dom": "^19.2.7",
|
|
33
|
+
"houdini": "^2.0.0-next.29"
|
|
34
34
|
},
|
|
35
35
|
"peerDependencies": {
|
|
36
36
|
"vite": "^8.0.0"
|
package/build/index.d.ts
DELETED
package/build/index.js
DELETED
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
// @ts-nocheck
|
|
2
|
-
import { fs } from 'houdini';
|
|
3
|
-
import path from 'node:path';
|
|
4
|
-
import React from 'react';
|
|
5
|
-
import ReactDOM from 'react-dom/server';
|
|
6
|
-
// in order to prepare the app as a single-page app, we have 2 create 2 additional files:
|
|
7
|
-
// - an index.js that imports the application and calls React.render. This file needs to be built by vite so it's passed with the includePaths option for an adapter
|
|
8
|
-
// - an index.html containing the static shell that wraps the application.
|
|
9
|
-
const adapter = async ({ outDir, config: { runtimeDir } }) => {
|
|
10
|
-
// the first thing we need to do is pull out the rendered html file into the root of the outDir
|
|
11
|
-
await fs.copyFile(path.join(outDir, 'assets', runtimeDir, 'temp', 'spa-shell', 'index.html'), path.join(outDir, 'index.html'));
|
|
12
|
-
try {
|
|
13
|
-
await fs.rmdir(path.join(outDir, 'assets', runtimeDir));
|
|
14
|
-
}
|
|
15
|
-
catch { }
|
|
16
|
-
};
|
|
17
|
-
// make sure we include the app entry point in the bundle
|
|
18
|
-
adapter.includePaths = ({ config: { runtimeDir } }) => ({
|
|
19
|
-
shell: path.join(runtimeDir, 'temp', 'spa-shell', 'index.html'),
|
|
20
|
-
});
|
|
21
|
-
// we dont want any server artifacts to be generated
|
|
22
|
-
adapter.disableServer = true;
|
|
23
|
-
adapter.pre = async ({ config, outDir: _outDir, conventions: _conventions }) => {
|
|
24
|
-
// before we do anything, we need to ensure the user isn't using a local API
|
|
25
|
-
if (config.localSchema) {
|
|
26
|
-
throw new Error("Houdini's SPA adapter cannot be used if your project relies on a local schema");
|
|
27
|
-
}
|
|
28
|
-
process.env.HOUDINI_SECONDARY_BUILD = 'true';
|
|
29
|
-
const { build } = await import('vite');
|
|
30
|
-
const shellDir = conventions.temp_dir(config, 'spa-shell');
|
|
31
|
-
// before we can import and render the user's index file, we need to compile it with vite
|
|
32
|
-
await build({
|
|
33
|
-
build: {
|
|
34
|
-
emptyOutDir: false,
|
|
35
|
-
ssr: true,
|
|
36
|
-
rollupOptions: {
|
|
37
|
-
output: {
|
|
38
|
-
dir: shellDir,
|
|
39
|
-
entryFileNames: '[name].js',
|
|
40
|
-
},
|
|
41
|
-
},
|
|
42
|
-
lib: {
|
|
43
|
-
entry: {
|
|
44
|
-
// the shell could be defined as tsx or jsx so just strip the extension
|
|
45
|
-
shell: conventions.router_index_path(config).replace('.jsx', ''),
|
|
46
|
-
},
|
|
47
|
-
formats: ['es'],
|
|
48
|
-
},
|
|
49
|
-
},
|
|
50
|
-
});
|
|
51
|
-
process.env.HOUDINI_SECONDARY_BUILD = 'false';
|
|
52
|
-
// now we can import the bundled shell
|
|
53
|
-
const { default: App } = await import(path.join(shellDir, 'shell.js'));
|
|
54
|
-
// render the index.jsx file to generate the static html that
|
|
55
|
-
// we can use to wrap the ajvascript application
|
|
56
|
-
const shellContents = ReactDOM.renderToStaticMarkup(React.createElement(App, null, React.createElement('div', { id: 'app' }))).replace('</head>', "<script type='module' src='virtual:houdini/static-entry'></script></head>");
|
|
57
|
-
// write the shell to the outDir
|
|
58
|
-
await fs.writeFile(path.join(shellDir, 'index.html'), shellContents);
|
|
59
|
-
};
|
|
60
|
-
export default adapter;
|