@cedarjs/prerender 5.0.0-canary.13889 → 5.0.0-canary.13893
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.
|
@@ -22,9 +22,6 @@ __export(node_runner_exports, {
|
|
|
22
22
|
});
|
|
23
23
|
module.exports = __toCommonJS(node_runner_exports);
|
|
24
24
|
var import_vite = require("vite");
|
|
25
|
-
var import_client = require("vite-node/client");
|
|
26
|
-
var import_server = require("vite-node/server");
|
|
27
|
-
var import_source_map = require("vite-node/source-map");
|
|
28
25
|
var import_project_config = require("@cedarjs/project-config");
|
|
29
26
|
var import_vite2 = require("@cedarjs/vite");
|
|
30
27
|
var import_vite_plugin_cedar_auto_import = require("./vite-plugin-cedar-auto-import.js");
|
|
@@ -33,10 +30,16 @@ async function createViteServer(customConfig = {}) {
|
|
|
33
30
|
const defaultConfig = {
|
|
34
31
|
mode: "production",
|
|
35
32
|
optimizeDeps: {
|
|
36
|
-
// This is recommended in the vite-node readme
|
|
37
33
|
noDiscovery: true,
|
|
38
34
|
include: void 0
|
|
39
35
|
},
|
|
36
|
+
server: {
|
|
37
|
+
hmr: false,
|
|
38
|
+
watch: null
|
|
39
|
+
},
|
|
40
|
+
environments: {
|
|
41
|
+
nodeRunnerEnv: {}
|
|
42
|
+
},
|
|
40
43
|
resolve: {
|
|
41
44
|
alias: [
|
|
42
45
|
{
|
|
@@ -46,6 +49,7 @@ async function createViteServer(customConfig = {}) {
|
|
|
46
49
|
]
|
|
47
50
|
},
|
|
48
51
|
plugins: [
|
|
52
|
+
(0, import_vite2.cedarCjsCompatPlugin)(),
|
|
49
53
|
(0, import_vite_plugin_cedar_import_dir.cedarImportDirPlugin)(),
|
|
50
54
|
(0, import_vite_plugin_cedar_auto_import.cedarAutoImportsPlugin)(),
|
|
51
55
|
(0, import_vite2.cedarjsResolveCedarStyleImportsPlugin)(),
|
|
@@ -56,48 +60,33 @@ async function createViteServer(customConfig = {}) {
|
|
|
56
60
|
};
|
|
57
61
|
const mergedConfig = (0, import_vite.mergeConfig)(defaultConfig, customConfig);
|
|
58
62
|
const server = await (0, import_vite.createServer)(mergedConfig);
|
|
59
|
-
if (Number(import_vite.version.split(".")[0]) < 6) {
|
|
60
|
-
await server.pluginContainer.buildStart({});
|
|
61
|
-
}
|
|
62
63
|
return server;
|
|
63
64
|
}
|
|
64
65
|
class NodeRunner {
|
|
65
66
|
viteServer = void 0;
|
|
66
|
-
|
|
67
|
+
env = void 0;
|
|
67
68
|
customViteConfig;
|
|
68
69
|
constructor(customViteConfig = {}) {
|
|
69
70
|
this.customViteConfig = customViteConfig;
|
|
70
71
|
}
|
|
71
72
|
async init() {
|
|
72
73
|
this.viteServer = await createViteServer(this.customViteConfig);
|
|
73
|
-
const
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
fallbackCJS: true
|
|
80
|
-
}
|
|
81
|
-
});
|
|
82
|
-
(0, import_source_map.installSourcemapsSupport)({
|
|
83
|
-
getSourceMap: (source) => nodeServer?.getSourceMap(source)
|
|
84
|
-
});
|
|
85
|
-
this.runner = new import_client.ViteNodeRunner({
|
|
86
|
-
root: this.viteServer.config.root,
|
|
87
|
-
base: this.viteServer.config.base,
|
|
88
|
-
fetchModule(id) {
|
|
89
|
-
return nodeServer.fetchModule(id);
|
|
90
|
-
},
|
|
91
|
-
resolveId(id, importer) {
|
|
92
|
-
return nodeServer.resolveId(id, importer);
|
|
93
|
-
}
|
|
94
|
-
});
|
|
74
|
+
const env = this.viteServer.environments.nodeRunnerEnv;
|
|
75
|
+
if (!env || !(0, import_vite.isRunnableDevEnvironment)(env)) {
|
|
76
|
+
await this.viteServer.close();
|
|
77
|
+
throw new Error("Vite environment is not runnable.");
|
|
78
|
+
}
|
|
79
|
+
this.env = env;
|
|
95
80
|
}
|
|
96
81
|
async importFile(filePath) {
|
|
97
|
-
if (!this.
|
|
82
|
+
if (!this.env) {
|
|
98
83
|
await this.init();
|
|
99
84
|
}
|
|
100
|
-
|
|
85
|
+
const env = this.env;
|
|
86
|
+
if (!env) {
|
|
87
|
+
throw new Error("NodeRunner failed to initialize");
|
|
88
|
+
}
|
|
89
|
+
return env.runner.import(filePath);
|
|
101
90
|
}
|
|
102
91
|
async close() {
|
|
103
92
|
await this.viteServer?.close();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"node-runner.d.ts","sourceRoot":"","sources":["../../src/graphql/node-runner.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"node-runner.d.ts","sourceRoot":"","sources":["../../src/graphql/node-runner.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAyC,UAAU,EAAE,MAAM,MAAM,CAAA;AAsD7E,qBAAa,UAAU;IACrB,OAAO,CAAC,UAAU,CAAC,CAA2B;IAC9C,OAAO,CAAC,GAAG,CAAC,CAAoC;IAChD,OAAO,CAAC,QAAQ,CAAC,gBAAgB,CAAY;gBAEjC,gBAAgB,GAAE,UAAe;IAIvC,IAAI;IAYJ,UAAU,CAAC,QAAQ,EAAE,MAAM;IAa3B,KAAK;CAGZ"}
|
|
@@ -1,13 +1,11 @@
|
|
|
1
|
-
import { createServer,
|
|
2
|
-
import { ViteNodeRunner } from "vite-node/client";
|
|
3
|
-
import { ViteNodeServer } from "vite-node/server";
|
|
4
|
-
import { installSourcemapsSupport } from "vite-node/source-map";
|
|
1
|
+
import { createServer, isRunnableDevEnvironment, mergeConfig } from "vite";
|
|
5
2
|
import { getPaths } from "@cedarjs/project-config";
|
|
6
3
|
import {
|
|
7
4
|
cedarCellTransform,
|
|
8
5
|
cedarjsResolveCedarStyleImportsPlugin,
|
|
9
6
|
cedarjsJobPathInjectorPlugin,
|
|
10
|
-
cedarSwapApolloProvider
|
|
7
|
+
cedarSwapApolloProvider,
|
|
8
|
+
cedarCjsCompatPlugin
|
|
11
9
|
} from "@cedarjs/vite";
|
|
12
10
|
import { cedarAutoImportsPlugin } from "./vite-plugin-cedar-auto-import.js";
|
|
13
11
|
import { cedarImportDirPlugin } from "./vite-plugin-cedar-import-dir.js";
|
|
@@ -15,10 +13,16 @@ async function createViteServer(customConfig = {}) {
|
|
|
15
13
|
const defaultConfig = {
|
|
16
14
|
mode: "production",
|
|
17
15
|
optimizeDeps: {
|
|
18
|
-
// This is recommended in the vite-node readme
|
|
19
16
|
noDiscovery: true,
|
|
20
17
|
include: void 0
|
|
21
18
|
},
|
|
19
|
+
server: {
|
|
20
|
+
hmr: false,
|
|
21
|
+
watch: null
|
|
22
|
+
},
|
|
23
|
+
environments: {
|
|
24
|
+
nodeRunnerEnv: {}
|
|
25
|
+
},
|
|
22
26
|
resolve: {
|
|
23
27
|
alias: [
|
|
24
28
|
{
|
|
@@ -28,6 +32,7 @@ async function createViteServer(customConfig = {}) {
|
|
|
28
32
|
]
|
|
29
33
|
},
|
|
30
34
|
plugins: [
|
|
35
|
+
cedarCjsCompatPlugin(),
|
|
31
36
|
cedarImportDirPlugin(),
|
|
32
37
|
cedarAutoImportsPlugin(),
|
|
33
38
|
cedarjsResolveCedarStyleImportsPlugin(),
|
|
@@ -38,48 +43,33 @@ async function createViteServer(customConfig = {}) {
|
|
|
38
43
|
};
|
|
39
44
|
const mergedConfig = mergeConfig(defaultConfig, customConfig);
|
|
40
45
|
const server = await createServer(mergedConfig);
|
|
41
|
-
if (Number(viteVersion.split(".")[0]) < 6) {
|
|
42
|
-
await server.pluginContainer.buildStart({});
|
|
43
|
-
}
|
|
44
46
|
return server;
|
|
45
47
|
}
|
|
46
48
|
class NodeRunner {
|
|
47
49
|
viteServer = void 0;
|
|
48
|
-
|
|
50
|
+
env = void 0;
|
|
49
51
|
customViteConfig;
|
|
50
52
|
constructor(customViteConfig = {}) {
|
|
51
53
|
this.customViteConfig = customViteConfig;
|
|
52
54
|
}
|
|
53
55
|
async init() {
|
|
54
56
|
this.viteServer = await createViteServer(this.customViteConfig);
|
|
55
|
-
const
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
fallbackCJS: true
|
|
62
|
-
}
|
|
63
|
-
});
|
|
64
|
-
installSourcemapsSupport({
|
|
65
|
-
getSourceMap: (source) => nodeServer?.getSourceMap(source)
|
|
66
|
-
});
|
|
67
|
-
this.runner = new ViteNodeRunner({
|
|
68
|
-
root: this.viteServer.config.root,
|
|
69
|
-
base: this.viteServer.config.base,
|
|
70
|
-
fetchModule(id) {
|
|
71
|
-
return nodeServer.fetchModule(id);
|
|
72
|
-
},
|
|
73
|
-
resolveId(id, importer) {
|
|
74
|
-
return nodeServer.resolveId(id, importer);
|
|
75
|
-
}
|
|
76
|
-
});
|
|
57
|
+
const env = this.viteServer.environments.nodeRunnerEnv;
|
|
58
|
+
if (!env || !isRunnableDevEnvironment(env)) {
|
|
59
|
+
await this.viteServer.close();
|
|
60
|
+
throw new Error("Vite environment is not runnable.");
|
|
61
|
+
}
|
|
62
|
+
this.env = env;
|
|
77
63
|
}
|
|
78
64
|
async importFile(filePath) {
|
|
79
|
-
if (!this.
|
|
65
|
+
if (!this.env) {
|
|
80
66
|
await this.init();
|
|
81
67
|
}
|
|
82
|
-
|
|
68
|
+
const env = this.env;
|
|
69
|
+
if (!env) {
|
|
70
|
+
throw new Error("NodeRunner failed to initialize");
|
|
71
|
+
}
|
|
72
|
+
return env.runner.import(filePath);
|
|
83
73
|
}
|
|
84
74
|
async close() {
|
|
85
75
|
await this.viteServer?.close();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cedarjs/prerender",
|
|
3
|
-
"version": "5.0.0-canary.
|
|
3
|
+
"version": "5.0.0-canary.13893+8801f7260c",
|
|
4
4
|
"description": "CedarJS prerender",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -71,12 +71,12 @@
|
|
|
71
71
|
"@babel/generator": "7.29.1",
|
|
72
72
|
"@babel/parser": "7.29.2",
|
|
73
73
|
"@babel/traverse": "7.29.0",
|
|
74
|
-
"@cedarjs/babel-config": "5.0.0-canary.
|
|
75
|
-
"@cedarjs/project-config": "5.0.0-canary.
|
|
76
|
-
"@cedarjs/router": "5.0.0-canary.
|
|
77
|
-
"@cedarjs/structure": "5.0.0-canary.
|
|
78
|
-
"@cedarjs/vite": "5.0.0-canary.
|
|
79
|
-
"@cedarjs/web": "5.0.0-canary.
|
|
74
|
+
"@cedarjs/babel-config": "5.0.0-canary.13893",
|
|
75
|
+
"@cedarjs/project-config": "5.0.0-canary.13893",
|
|
76
|
+
"@cedarjs/router": "5.0.0-canary.13893",
|
|
77
|
+
"@cedarjs/structure": "5.0.0-canary.13893",
|
|
78
|
+
"@cedarjs/vite": "5.0.0-canary.13893",
|
|
79
|
+
"@cedarjs/web": "5.0.0-canary.13893",
|
|
80
80
|
"@rollup/plugin-alias": "5.1.1",
|
|
81
81
|
"@rollup/plugin-commonjs": "28.0.9",
|
|
82
82
|
"@rollup/plugin-node-resolve": "16.0.3",
|
|
@@ -91,11 +91,10 @@
|
|
|
91
91
|
"rollup-plugin-swc3": "0.12.1",
|
|
92
92
|
"unimport": "5.7.0",
|
|
93
93
|
"unplugin-auto-import": "19.3.0",
|
|
94
|
-
"vite": "7.3.2"
|
|
95
|
-
"vite-node": "3.2.4"
|
|
94
|
+
"vite": "7.3.2"
|
|
96
95
|
},
|
|
97
96
|
"devDependencies": {
|
|
98
|
-
"@cedarjs/framework-tools": "5.0.0-canary.
|
|
97
|
+
"@cedarjs/framework-tools": "5.0.0-canary.13893",
|
|
99
98
|
"@types/mime-types": "2.1.4",
|
|
100
99
|
"@types/react": "^18.2.55",
|
|
101
100
|
"babel-plugin-tester": "11.0.4",
|
|
@@ -119,5 +118,5 @@
|
|
|
119
118
|
"react": "react",
|
|
120
119
|
"react-dom": "react-dom"
|
|
121
120
|
},
|
|
122
|
-
"gitHead": "
|
|
121
|
+
"gitHead": "8801f7260cc1702114b09ff8a2aa35334b109b2f"
|
|
123
122
|
}
|