@cedarjs/vite 7.0.1-next.467 → 7.1.0-rc.34

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.
Files changed (35) hide show
  1. package/dist/buildApp.d.ts.map +1 -1
  2. package/dist/buildApp.js +11 -32
  3. package/dist/buildRouteHooks.d.ts +13 -7
  4. package/dist/buildRouteHooks.d.ts.map +1 -1
  5. package/dist/buildRouteHooks.js +10 -5
  6. package/dist/bundled/react-server-dom-webpack.server.js +29125 -2264
  7. package/dist/devFeServer.js +3 -3
  8. package/dist/index.d.ts +0 -1
  9. package/dist/index.d.ts.map +1 -1
  10. package/dist/index.js +0 -4
  11. package/dist/jobsDevMiddleware.d.ts.map +1 -1
  12. package/dist/jobsDevMiddleware.js +2 -29
  13. package/dist/plugins/vite-plugin-cedar-cell.d.ts +1 -2
  14. package/dist/plugins/vite-plugin-cedar-cell.d.ts.map +1 -1
  15. package/dist/plugins/vite-plugin-cedar-cell.js +11 -30
  16. package/dist/plugins/vite-plugin-handler-als-wrapping.d.ts +6 -2
  17. package/dist/plugins/vite-plugin-handler-als-wrapping.d.ts.map +1 -1
  18. package/dist/plugins/vite-plugin-handler-als-wrapping.js +7 -4
  19. package/dist/rsc/rscBuildClient.d.ts +1 -1
  20. package/dist/rsc/rscBuildForServer.d.ts +1 -1
  21. package/dist/rsc/rscBuildForSsr.d.ts +1 -1
  22. package/dist/runFeServer.js +3 -3
  23. package/dist/streaming/streamHelpers.d.ts +1 -6
  24. package/dist/streaming/streamHelpers.d.ts.map +1 -1
  25. package/dist/streaming/streamHelpers.js +1 -1
  26. package/package.json +44 -46
  27. package/dist/lib/sandboxChildren.d.ts +0 -58
  28. package/dist/lib/sandboxChildren.d.ts.map +0 -1
  29. package/dist/lib/sandboxChildren.js +0 -157
  30. package/dist/plugins/vite-plugin-cedar-parsed-scalars.d.ts +0 -20
  31. package/dist/plugins/vite-plugin-cedar-parsed-scalars.d.ts.map +0 -1
  32. package/dist/plugins/vite-plugin-cedar-parsed-scalars.js +0 -60
  33. package/dist/plugins/vite-plugin-cedar-sandbox-children.d.ts +0 -20
  34. package/dist/plugins/vite-plugin-cedar-sandbox-children.d.ts.map +0 -1
  35. package/dist/plugins/vite-plugin-cedar-sandbox-children.js +0 -58
@@ -1 +1 @@
1
- {"version":3,"file":"buildApp.d.ts","sourceRoot":"","sources":["../src/buildApp.ts"],"names":[],"mappings":"AAuEA,MAAM,WAAW,oBAAoB;IACnC,OAAO,CAAC,EAAE,OAAO,CAAA;IACjB,SAAS,CAAC,EAAE,MAAM,EAAE,CAAA;IACpB,EAAE,CAAC,EAAE,OAAO,CAAA;CACb;AAED;;;;;;;;GAQG;AACH,wBAAsB,aAAa,CAAC,EAClC,OAAe,EACf,SAA0B,EAC1B,EAAU,GACX,GAAE,oBAAyB,iBAyd3B"}
1
+ {"version":3,"file":"buildApp.d.ts","sourceRoot":"","sources":["../src/buildApp.ts"],"names":[],"mappings":"AAkEA,MAAM,WAAW,oBAAoB;IACnC,OAAO,CAAC,EAAE,OAAO,CAAA;IACjB,SAAS,CAAC,EAAE,MAAM,EAAE,CAAA;IACpB,EAAE,CAAC,EAAE,OAAO,CAAA;CACb;AAED;;;;;;;;GAQG;AACH,wBAAsB,aAAa,CAAC,EAClC,OAAe,EACf,SAA0B,EAC1B,EAAU,GACX,GAAE,oBAAyB,iBAgc3B"}
package/dist/buildApp.js CHANGED
@@ -23,14 +23,10 @@ import { findApiFiles } from "@cedarjs/internal/dist/files.js";
23
23
  import {
24
24
  createPrismaClientFileMatcher,
25
25
  getConfig,
26
- getPaths
26
+ getPaths,
27
+ projectSideIsEsm
27
28
  } from "@cedarjs/project-config";
28
29
  import { generateDiffSourceMap } from "./lib/generateDiffSourceMap.js";
29
- import {
30
- copySandboxChildrenIntoVercelFunctions,
31
- findSandboxChildScripts,
32
- SANDBOX_CHILDREN_DIR
33
- } from "./lib/sandboxChildren.js";
34
30
  import { getWorkspacePackageAliases } from "./lib/workspacePackageAliases.js";
35
31
  import { cedarAutoImportsPlugin } from "./plugins/vite-plugin-cedar-auto-import.js";
36
32
  import { cedarDirectoryNamedImportPlugin } from "./plugins/vite-plugin-cedar-directory-named-import.js";
@@ -39,7 +35,6 @@ import { cedarGraphqlOptionsExtractPlugin } from "./plugins/vite-plugin-cedar-gr
39
35
  import { cedarImportDirPlugin } from "./plugins/vite-plugin-cedar-import-dir.js";
40
36
  import { cedarMockCellDataPlugin } from "./plugins/vite-plugin-cedar-mock-cell-data.js";
41
37
  import { cedarOtelWrappingPlugin } from "./plugins/vite-plugin-cedar-otel-wrapping.js";
42
- import { cedarSandboxChildrenPlugin } from "./plugins/vite-plugin-cedar-sandbox-children.js";
43
38
  import { cedarjsJobPathInjectorPlugin } from "./plugins/vite-plugin-cedarjs-job-path-injector.js";
44
39
  import { handlerAlsWrappingPlugin } from "./plugins/vite-plugin-handler-als-wrapping.js";
45
40
  function resolveWithExtensions(id) {
@@ -62,7 +57,6 @@ async function buildCedarApp({
62
57
  const cedarPaths = getPaths();
63
58
  const cedarConfig = getConfig();
64
59
  const environments = {};
65
- let sandboxChildren = {};
66
60
  if (workspace.includes("web")) {
67
61
  environments.client = {
68
62
  build: {
@@ -71,6 +65,8 @@ async function buildCedarApp({
71
65
  };
72
66
  }
73
67
  if (workspace.includes("api")) {
68
+ const isEsm = projectSideIsEsm("api");
69
+ const format = isEsm ? "es" : "cjs";
74
70
  const apiFiles = findApiFiles();
75
71
  const input = {};
76
72
  for (const f of apiFiles) {
@@ -86,7 +82,7 @@ async function buildCedarApp({
86
82
  rollupOptions: {
87
83
  input,
88
84
  output: {
89
- format: "es",
85
+ format,
90
86
  preserveModules: true,
91
87
  preserveModulesRoot: cedarPaths.api.src,
92
88
  entryFileNames: "[name].js",
@@ -104,16 +100,15 @@ async function buildCedarApp({
104
100
  }
105
101
  };
106
102
  if (ud) {
107
- sandboxChildren = findSandboxChildScripts(cedarPaths.api.src);
108
103
  environments["ssr"] = {
109
104
  build: {
110
105
  ssr: true,
111
106
  outDir: path.join(cedarPaths.api.dist, "ud"),
112
107
  emptyOutDir: true,
113
108
  rollupOptions: {
114
- input: { index: catchAllEntry, ...sandboxChildren },
109
+ input: catchAllEntry,
115
110
  output: {
116
- entryFileNames: "[name].js"
111
+ entryFileNames: "index.js"
117
112
  },
118
113
  external: (id) => {
119
114
  if (id.startsWith("virtual:")) {
@@ -209,12 +204,6 @@ async function buildCedarApp({
209
204
  ];
210
205
  if (ud) {
211
206
  plugins.push(catchAll());
212
- plugins.push(
213
- cedarSandboxChildrenPlugin({
214
- environment: "ssr",
215
- children: sandboxChildren
216
- })
217
- );
218
207
  plugins.push({
219
208
  name: "cedar-ud-verify-routes",
220
209
  configResolved() {
@@ -272,7 +261,9 @@ async function buildCedarApp({
272
261
  plugins.push(cedarDirectoryNamedImportPlugin());
273
262
  plugins.push(cedarOtelWrappingPlugin());
274
263
  plugins.push(cedarjsJobPathInjectorPlugin());
275
- plugins.push(handlerAlsWrappingPlugin());
264
+ plugins.push(
265
+ handlerAlsWrappingPlugin({ projectIsEsm: projectSideIsEsm("api") })
266
+ );
276
267
  }
277
268
  plugins.push(cedarMockCellDataPlugin());
278
269
  if (workspace.includes("api")) {
@@ -355,19 +346,7 @@ async function buildCedarApp({
355
346
  },
356
347
  plugins
357
348
  });
358
- await builder.buildApp();
359
- const vercelNode = builder.environments["vercel_node"];
360
- if (ud && vercelNode && Object.keys(sandboxChildren).length > 0) {
361
- const outDir = path.resolve(
362
- vercelNode.config.root,
363
- vercelNode.config.build.outDir
364
- );
365
- copySandboxChildrenIntoVercelFunctions({
366
- appRoot: cedarPaths.base,
367
- childrenDir: path.join(cedarPaths.api.dist, "ud", SANDBOX_CHILDREN_DIR),
368
- functionsDir: path.join(outDir, "functions")
369
- });
370
- }
349
+ return builder.buildApp();
371
350
  }
372
351
  export {
373
352
  buildCedarApp
@@ -1,16 +1,22 @@
1
1
  import type { Paths } from '@cedarjs/project-config';
2
2
  /**
3
- * Returns the path, relative to `web/dist/ssr/routeHooks` and with a `.js`
4
- * extension, that the built version of the given route hook source file is
5
- * written to. The layout mirrors `web/src`, so
6
- * `web/src/pages/HomePage/HomePage.routeHooks.ts` ends up at
7
- * `pages/HomePage/HomePage.routeHooks.js` and `web/src/App.routeHooks.ts` at
8
- * `App.routeHooks.js`.
3
+ * Route hooks are built as ES modules. Node reads a `.js` file as CommonJS
4
+ * when the nearest package.json has no `"type": "module"`, so in a CommonJS
5
+ * web side the output gets the `.mjs` extension instead.
6
+ */
7
+ export declare function getRouteHookDistExtension(): ".js" | ".mjs";
8
+ /**
9
+ * Returns the path, relative to `web/dist/ssr/routeHooks`, that the built
10
+ * version of the given route hook source file is written to. The layout
11
+ * mirrors `web/src`, so `web/src/pages/HomePage/HomePage.routeHooks.ts` ends
12
+ * up at `pages/HomePage/HomePage.routeHooks.js` and `web/src/App.routeHooks.ts`
13
+ * at `App.routeHooks.js` (`.mjs` in a CommonJS web side, see
14
+ * getRouteHookDistExtension()).
9
15
  *
10
16
  * Used both by the build (to name the Rollup entries) and by the route
11
17
  * manifest (so the streaming handler can find the file at request time).
12
18
  */
13
- export declare function getRouteHookDistPath(routeHookSrcPath: string, webSrc?: string): string;
19
+ export declare function getRouteHookDistPath(routeHookSrcPath: string, webSrc?: string, extension?: string): string;
14
20
  /**
15
21
  * Bundles every `web/src/** /*.routeHooks.{js,ts,tsx,jsx}` file into
16
22
  * `web/dist/ssr/routeHooks` as a node ESM module, one output file per route
@@ -1 +1 @@
1
- {"version":3,"file":"buildRouteHooks.d.ts","sourceRoot":"","sources":["../src/buildRouteHooks.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,yBAAyB,CAAA;AAiBpD;;;;;;;;;;GAUG;AACH,wBAAgB,oBAAoB,CAClC,gBAAgB,EAAE,MAAM,EACxB,MAAM,SAAqB,UAG5B;AA6BD;;;;GAIG;AACH,wBAAsB,eAAe,CACnC,OAAO,EAAE,OAAO,GAAG,SAAS,EAC5B,OAAO,EAAE,KAAK,iBAuEf"}
1
+ {"version":3,"file":"buildRouteHooks.d.ts","sourceRoot":"","sources":["../src/buildRouteHooks.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,yBAAyB,CAAA;AAiBpD;;;;GAIG;AACH,wBAAgB,yBAAyB,mBAExC;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,oBAAoB,CAClC,gBAAgB,EAAE,MAAM,EACxB,MAAM,SAAqB,EAC3B,SAAS,SAA8B,UAGxC;AA6BD;;;;GAIG;AACH,wBAAsB,eAAe,CACnC,OAAO,EAAE,OAAO,GAAG,SAAS,EAC5B,OAAO,EAAE,KAAK,iBAyEf"}
@@ -3,7 +3,7 @@ import { build as viteBuild } from "vite";
3
3
  import { gqlPlugin as gqlTagPlugin } from "vite-plugin-graphql-tag";
4
4
  import tsPathsMod from "vite-tsconfig-paths";
5
5
  import { findRouteHooksSrc } from "@cedarjs/internal/dist/files.js";
6
- import { getPaths } from "@cedarjs/project-config";
6
+ import { getPaths, projectSideIsEsm } from "@cedarjs/project-config";
7
7
  import { cedarApiImportGuardPlugin } from "./plugins/vite-plugin-cedar-api-import-guard.js";
8
8
  import { cedarAutoImportsPlugin } from "./plugins/vite-plugin-cedar-auto-import.js";
9
9
  import { cedarDirectoryNamedImportPlugin } from "./plugins/vite-plugin-cedar-directory-named-import.js";
@@ -13,8 +13,11 @@ const tsconfigPaths = (
13
13
  // interop
14
14
  tsPathsMod.default?.default || tsPathsMod.default || tsPathsMod
15
15
  );
16
- function getRouteHookDistPath(routeHookSrcPath, webSrc = getPaths().web.src) {
17
- return getRouteHookEntryName(routeHookSrcPath, webSrc) + ".js";
16
+ function getRouteHookDistExtension() {
17
+ return projectSideIsEsm("web") ? ".js" : ".mjs";
18
+ }
19
+ function getRouteHookDistPath(routeHookSrcPath, webSrc = getPaths().web.src, extension = getRouteHookDistExtension()) {
20
+ return getRouteHookEntryName(routeHookSrcPath, webSrc) + extension;
18
21
  }
19
22
  function getRouteHookEntryName(routeHookSrcPath, webSrc) {
20
23
  return path.relative(webSrc, routeHookSrcPath).replace(/\.(js|ts|tsx|jsx)$/, "").split(path.sep).join("/");
@@ -35,6 +38,7 @@ async function buildRouteHooks(verbose, rwPaths) {
35
38
  for (const routeHook of allRouteHooks) {
36
39
  input[getRouteHookEntryName(routeHook, rwPaths.web.src)] = routeHook;
37
40
  }
41
+ const extension = getRouteHookDistExtension();
38
42
  await viteBuild({
39
43
  // Route hooks run in node, so the project's web/vite.config, which is set
40
44
  // up for browser and SSR builds of React code, doesn't apply. Only the
@@ -77,9 +81,9 @@ async function buildRouteHooks(verbose, rwPaths) {
77
81
  input,
78
82
  output: {
79
83
  format: "es",
80
- entryFileNames: "[name].js",
84
+ entryFileNames: "[name]" + extension,
81
85
  // Modules shared between route hooks, like the api side's db.js
82
- chunkFileNames: "chunks/[name]-[hash].js",
86
+ chunkFileNames: "chunks/[name]-[hash]" + extension,
83
87
  exports: "named"
84
88
  }
85
89
  }
@@ -96,5 +100,6 @@ async function buildRouteHooks(verbose, rwPaths) {
96
100
  }
97
101
  export {
98
102
  buildRouteHooks,
103
+ getRouteHookDistExtension,
99
104
  getRouteHookDistPath
100
105
  };