eddev 2.0.0-beta.164 → 2.0.0-beta.166

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.
@@ -1 +1 @@
1
- {"version":3,"file":"ssr-root-client.d.ts","sourceRoot":"","sources":["../../../src/app/entry/ssr-root-client.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAiC,MAAM,OAAO,CAAA;AAIhE,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAA;AAItD,wBAAgB,aAAa,CAAC,KAAK,EAAE;IAAE,MAAM,EAAE,SAAS,CAAC;IAAC,QAAQ,EAAE,YAAY,EAAE,CAAA;CAAE,2CAYnF"}
1
+ {"version":3,"file":"ssr-root-client.d.ts","sourceRoot":"","sources":["../../../src/app/entry/ssr-root-client.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAiC,MAAM,OAAO,CAAA;AAIhE,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAA;AAItD,wBAAgB,aAAa,CAAC,KAAK,EAAE;IAAE,MAAM,EAAE,SAAS,CAAC;IAAC,QAAQ,EAAE,YAAY,EAAE,CAAA;CAAE,2CAgBnF"}
@@ -1,12 +1,12 @@
1
1
  import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { useEffect } from "react";
2
+ import { Suspense, useEffect } from "react";
3
3
  import { useSnapshot } from "valtio";
4
4
  import { BrowserRouter } from "../lib/routing/components/BrowserRouter.js";
5
5
  import { clientMetaTags } from "../lib/routing/context.js";
6
6
  import { APIProvider } from "../utils/APIProvider.js";
7
7
  import { DevUILoader } from "../lib/devtools/loader.js";
8
8
  export function SSRClientRoot(props) {
9
- return (_jsxs(APIProvider, { children: [_jsx(BrowserRouter, {}), _jsxs(_Fragment, { children: [_jsx(DynamicMetaTags, {}), _jsx(DevUILoader, {})] })] }));
9
+ return (_jsxs(APIProvider, { children: [_jsx(BrowserRouter, {}), _jsx(_Fragment, { children: _jsx(DynamicMetaTags, {}) }), _jsx(Suspense, { fallback: null, children: _jsx(_Fragment, { children: _jsx(DevUILoader, {}) }) })] }));
10
10
  }
11
11
  function DynamicMetaTags() {
12
12
  const dynamicTags = useSnapshot(clientMetaTags).tags;
@@ -1 +1 @@
1
- {"version":3,"file":"ssr-root.d.ts","sourceRoot":"","sources":["../../../src/app/entry/ssr-root.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAA;AAC3D,OAAO,KAAK,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAA;AAItE,wBAAgB,OAAO,CAAC,KAAK,EAAE;IAC7B,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,QAAQ,EAAE,MAAM,CAAA;IAChB,WAAW,EAAE,SAAS,CAAA;IACtB,MAAM,EAAE,WAAW,CAAA;IACnB,QAAQ,EAAE,YAAY,EAAE,CAAA;CACzB,2CA0BA"}
1
+ {"version":3,"file":"ssr-root.d.ts","sourceRoot":"","sources":["../../../src/app/entry/ssr-root.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAA;AAC3D,OAAO,KAAK,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAA;AAItE,wBAAgB,OAAO,CAAC,KAAK,EAAE;IAC7B,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,QAAQ,EAAE,MAAM,CAAA;IAChB,WAAW,EAAE,SAAS,CAAA;IACtB,MAAM,EAAE,WAAW,CAAA;IACnB,QAAQ,EAAE,YAAY,EAAE,CAAA;CACzB,2CA+BA"}
@@ -1,4 +1,5 @@
1
1
  import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { Suspense } from "react";
2
3
  import { SSRRouter } from "../lib/routing/components/SSRRouter.js";
3
4
  import { getRouteMeta, normalizeRoute } from "../lib/routing/utils.js";
4
5
  import { APIProvider } from "../utils/APIProvider.js";
@@ -17,5 +18,5 @@ export function SSRRoot(props) {
17
18
  query: {},
18
19
  hash: "",
19
20
  meta: getRouteMeta(props.initialData),
20
- }) }), _jsx(_Fragment, {})] }));
21
+ }) }), _jsx(_Fragment, {}), _jsx(Suspense, { fallback: null, children: _jsx(_Fragment, {}) })] }));
21
22
  }
@@ -72,8 +72,8 @@ export function useLinkState(href) {
72
72
  }
73
73
  const hrefUrl = parseURL(resolveURL(href));
74
74
  const active = route ? compareUri(route, hrefUrl) : undefined;
75
- const childActive = !active && route ? isSubpath(hrefUrl.pathname, route.pathname) : undefined;
76
- const pending = pendingRoute ? compareUri(pendingRoute, hrefUrl) : undefined;
75
+ const childActive = !active && route ? isSubpath(hrefUrl.pathname, route.pathname) || undefined : undefined;
76
+ const pending = pendingRoute ? compareUri(pendingRoute, hrefUrl) || undefined : undefined;
77
77
  return {
78
78
  active,
79
79
  childActive,
@@ -101,6 +101,9 @@ function compareUri(route, href) {
101
101
  }
102
102
  }
103
103
  function isSubpath(parentPath, childPath) {
104
+ if (parentPath === "/" || childPath === "/") {
105
+ return false;
106
+ }
104
107
  if (withoutTrailingSlash(parentPath) === withoutTrailingSlash(childPath)) {
105
108
  return false;
106
109
  }
@@ -1 +1 @@
1
- {"version":3,"file":"server-context.d.ts","sourceRoot":"","sources":["../../../src/app/server/server-context.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,iCAAiC,CAAA;AAC1D,OAAO,EAAE,cAAc,EAAE,MAAM,YAAY,CAAA;AAC3C,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,8BAA8B,CAAA;AAE5D,OAAO,EAAiC,WAAW,EAAE,MAAM,yBAAyB,CAAA;AAEpF,OAAO,EAAqB,eAAe,EAAE,MAAM,yBAAyB,CAAA;AAE5E,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAA;AAKxD,MAAM,MAAM,iBAAiB,GAAG;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EAAE,cAAc;IAYpC,eAAe,CAAC,GAAG,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,cAAc,CAAA;KAAE;IA4D9E,aAAa,CAAC,GAAG,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,cAAc,CAAA;KAAE;IAehF,IAAI,kBAAkB,aAcrB;IAED,aAAa,CAAC,YAAY,EAAE,MAAM;IAUlC,cAAc,CAAC,MAAM,EAAE,MAAM;;;;;;;;;;;;;CAiD9B"}
@@ -71,9 +71,21 @@ export class ServerContext {
71
71
  }
72
72
  });
73
73
  let text = await response.text();
74
+ try {
75
+ console.log("PARSE 1", JSON.parse(text));
76
+ }
77
+ catch (e) {
78
+ console.log("PARSE 1 ERROR", e);
79
+ }
74
80
  if (opts?.replaceUrls) {
75
81
  text = this.replaceUrls(text, opts.newOrigin);
76
82
  }
83
+ try {
84
+ console.log("PARSE 2", JSON.parse(text));
85
+ }
86
+ catch (e) {
87
+ console.log("PARSE 2 ERROR", e);
88
+ }
77
89
  return new Response(text, {
78
90
  status: response.status,
79
91
  statusText: response.statusText,
@@ -17,7 +17,12 @@ import { bootCLIUI } from "./display/boot-cli-app.js";
17
17
  import { VERSION } from "./version.js";
18
18
  import { buildVinxi } from "../compiler/build-vinxi.js";
19
19
  import { createConsole } from "../utils/stateful-log.js";
20
- import { join } from "path";
20
+ import { join, relative } from "path";
21
+ import { ensureSelfSignedCert } from "../utils/self-signed-cert.js";
22
+ import { parseURL } from "ufo";
23
+ import { corePlugins } from "../compiler/get-vite-config.js";
24
+ import { build } from "vite";
25
+ import rollupVisualizer from "rollup-plugin-visualizer";
21
26
  importDotEnv();
22
27
  const program = new Command()
23
28
  .version(VERSION)
@@ -218,16 +223,90 @@ program
218
223
  console.log("Done building SPA WordPress");
219
224
  }
220
225
  });
226
+ program
227
+ .command("analyze")
228
+ .description("Generate a bundle size analysis")
229
+ .action(async (options) => {
230
+ process.env["NODE_ENV"] = "production";
231
+ /** Ignore self-signed certificate errors in dev mode */
232
+ // process.env["NODE_TLS_REJECT_UNAUTHORIZED"] = "0"
233
+ init(options.verbose);
234
+ configureCliMode({
235
+ interactive: false,
236
+ readonly: false,
237
+ exitOnValidationError: true,
238
+ detailed: true,
239
+ verbose: false,
240
+ watch: false,
241
+ rootDir: process.cwd(),
242
+ });
243
+ const console = createConsole("build");
244
+ // Load the project info
245
+ const project = await Project.create({
246
+ rootDir: process.cwd(),
247
+ });
248
+ // Generate bootstrap files
249
+ const codegen = createVinxiCodegen({
250
+ mode: "production",
251
+ project: project,
252
+ serverless: false,
253
+ });
254
+ await codegen.run();
255
+ const outDir = relative(project.rootDir, "./dist/frontend-analysis/");
256
+ // @ts-ignore
257
+ const visualizer = rollupVisualizer.default;
258
+ await build({
259
+ plugins: [
260
+ ...corePlugins({
261
+ rootDir: project.rootDir,
262
+ console: console,
263
+ mode: "production",
264
+ publicUrl: project.publicUrl,
265
+ serverless: true,
266
+ target: "frontend",
267
+ client: true,
268
+ }),
269
+ visualizer({
270
+ emitFile: true,
271
+ filename: "stats.html",
272
+ template: "sunburst",
273
+ }),
274
+ ],
275
+ build: {
276
+ manifest: true,
277
+ sourcemap: true,
278
+ minify: true,
279
+ modulePreload: false,
280
+ outDir: outDir,
281
+ lib: undefined,
282
+ rollupOptions: {
283
+ input: "./.eddev/prod/entry.client.tsx",
284
+ },
285
+ },
286
+ });
287
+ console.log("Done building SPA WordPress");
288
+ });
221
289
  program
222
290
  .command("preview")
223
291
  .description("Run a local production build, which was previously built with `eddev build --serverless`")
224
- .option("--host", "Hostname to serve the application", "127.0.0.1")
225
- .option("--port", "Port to serve the application", "3000")
292
+ .option("--host", "Hostname to serve the application", "")
293
+ .option("--port", "Port to serve the application", "8080")
226
294
  .action(async (options) => {
295
+ const project = await Project.create({
296
+ rootDir: process.cwd(),
297
+ });
298
+ const parsedSiteURL = parseURL(project.origin);
299
+ const defaultHostname = parsedSiteURL.host?.endsWith(".local") ? parsedSiteURL.host : "127.0.0.1";
227
300
  process.env["NODE_TLS_REJECT_UNAUTHORIZED"] = "0";
228
301
  process.env["NODE_ENV"] = "production";
229
302
  process.env["HOST"] = options.host;
230
303
  process.env["PORT"] = options.port;
304
+ if (!options.host) {
305
+ process.env["HOST"] = defaultHostname;
306
+ const keys = await ensureSelfSignedCert(defaultHostname, process.cwd());
307
+ process.env["NITRO_SSL_CERT"] = keys.cert;
308
+ process.env["NITRO_SSL_KEY"] = keys.key;
309
+ }
231
310
  init(options.verbose);
232
311
  configureCliMode({
233
312
  interactive: true,
@@ -1,2 +1,2 @@
1
- export declare const VERSION = "2.0.0-beta.164";
1
+ export declare const VERSION = "2.0.0-beta.165";
2
2
  //# sourceMappingURL=version.d.ts.map
@@ -1 +1 @@
1
- export const VERSION = "2.0.0-beta.164";
1
+ export const VERSION = "2.0.0-beta.165";
@@ -3,6 +3,7 @@ export declare const frontendLog: import("../utils/stateful-log.js").StatefulLog
3
3
  type Options = {
4
4
  mode: "development" | "production";
5
5
  watch?: boolean;
6
+ bundleAnalysis?: boolean;
6
7
  };
7
8
  export declare class FrontendBundler {
8
9
  project: Project;
@@ -1 +1 @@
1
- {"version":3,"file":"bundler.frontend.d.ts","sourceRoot":"","sources":["../../../src/node/compiler/bundler.frontend.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,OAAO,EAAE,MAAM,uBAAuB,CAAA;AAO/C,eAAO,MAAM,WAAW,yDAAU,CAAA;AAElC,KAAK,OAAO,GAAG;IACb,IAAI,EAAE,aAAa,GAAG,YAAY,CAAA;IAClC,KAAK,CAAC,EAAE,OAAO,CAAA;CAChB,CAAA;AAED,qBAAa,eAAe;IAEjB,OAAO,EAAE,OAAO;IAChB,IAAI,EAAE,OAAO;gBADb,OAAO,EAAE,OAAO,EAChB,IAAI,EAAE,OAAO;IAGhB,KAAK;CA+BZ"}
1
+ {"version":3,"file":"bundler.frontend.d.ts","sourceRoot":"","sources":["../../../src/node/compiler/bundler.frontend.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,OAAO,EAAE,MAAM,uBAAuB,CAAA;AAQ/C,eAAO,MAAM,WAAW,yDAAU,CAAA;AAElC,KAAK,OAAO,GAAG;IACb,IAAI,EAAE,aAAa,GAAG,YAAY,CAAA;IAClC,KAAK,CAAC,EAAE,OAAO,CAAA;IACf,cAAc,CAAC,EAAE,OAAO,CAAA;CACzB,CAAA;AAED,qBAAa,eAAe;IAEjB,OAAO,EAAE,OAAO;IAChB,IAAI,EAAE,OAAO;gBADb,OAAO,EAAE,OAAO,EAChB,IAAI,EAAE,OAAO;IAGhB,KAAK;CAwCZ"}
@@ -2,6 +2,7 @@ import { relative } from "path";
2
2
  import { build, defineConfig, mergeConfig } from "vite";
3
3
  import { createConsole } from "../utils/stateful-log.js";
4
4
  import { getViteConfig } from "./get-vite-config.js";
5
+ import rollupVisualizer from "rollup-plugin-visualizer";
5
6
  const console = createConsole("Frontend Bundler", "spa");
6
7
  export const frontendLog = console;
7
8
  export class FrontendBundler {
@@ -13,25 +14,38 @@ export class FrontendBundler {
13
14
  }
14
15
  async start() {
15
16
  console.info(`Creating ${this.opts.mode} SPA build...`);
17
+ const config = {
18
+ build: {
19
+ watch: this.opts.watch
20
+ ? {
21
+ buildDelay: 200,
22
+ }
23
+ : undefined,
24
+ },
25
+ };
26
+ let outDir = relative(this.project.rootDir, "./dist/frontend/");
27
+ if (this.opts.bundleAnalysis) {
28
+ outDir = relative(this.project.rootDir, "./dist/frontend-analysis/");
29
+ // @ts-ignore
30
+ const visualizer = rollupVisualizer.default;
31
+ config.plugins = [
32
+ visualizer({
33
+ emitFile: true,
34
+ filename: "stats.html",
35
+ template: "sunburst",
36
+ }),
37
+ ];
38
+ }
16
39
  const baseConfig = getViteConfig({
17
40
  console,
18
41
  mode: this.opts.mode,
19
42
  publicUrl: this.project.publicUrl,
20
43
  rootDir: this.project.rootDir,
21
- outDir: relative(this.project.rootDir, "./dist/frontend/"),
44
+ outDir: outDir,
22
45
  serverless: false,
23
46
  target: "frontend",
24
47
  client: true,
25
48
  });
26
- console.verbose("Vite config:", baseConfig);
27
- await build(mergeConfig(baseConfig, defineConfig({
28
- build: {
29
- watch: this.opts.watch
30
- ? {
31
- buildDelay: 200,
32
- }
33
- : undefined,
34
- },
35
- })));
49
+ await build(mergeConfig(baseConfig, defineConfig(config)));
36
50
  }
37
51
  }
@@ -1 +1 @@
1
- {"version":3,"file":"vinxi-codegen.d.ts","sourceRoot":"","sources":["../../../src/node/compiler/vinxi-codegen.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,MAAM,uBAAuB,CAAA;AAC/C,OAAO,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAA;AAIlD,KAAK,OAAO,GAAG;IACb,IAAI,EAAE,aAAa,GAAG,YAAY,CAAA;IAClC,UAAU,EAAE,OAAO,CAAA;IACnB,OAAO,EAAE,OAAO,CAAA;IAChB,QAAQ,CAAC,EAAE,MAAM,CAAA;CAClB,CAAA;AAED,wBAAgB,cAAc,CAAC,IAAI,EAAE,IAAI,CAAC,OAAO,EAAE,MAAM,GAAG,YAAY,CAAC,UAExE;AAED,wBAAsB,eAAe,CAAC,IAAI,EAAE,OAAO,iBAIlD;AAED,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,OAAO,aAmqB/C"}
1
+ {"version":3,"file":"vinxi-codegen.d.ts","sourceRoot":"","sources":["../../../src/node/compiler/vinxi-codegen.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,MAAM,uBAAuB,CAAA;AAC/C,OAAO,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAA;AAIlD,KAAK,OAAO,GAAG;IACb,IAAI,EAAE,aAAa,GAAG,YAAY,CAAA;IAClC,UAAU,EAAE,OAAO,CAAA;IACnB,OAAO,EAAE,OAAO,CAAA;IAChB,QAAQ,CAAC,EAAE,MAAM,CAAA;CAClB,CAAA;AAED,wBAAgB,cAAc,CAAC,IAAI,EAAE,IAAI,CAAC,OAAO,EAAE,MAAM,GAAG,YAAY,CAAC,UAExE;AAED,wBAAsB,eAAe,CAAC,IAAI,EAAE,OAAO,iBAIlD;AAED,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,OAAO,aA8qB/C"}
@@ -1,6 +1,6 @@
1
1
  import { code, imp } from "ts-poet";
2
2
  import { FSCodegen } from "../utils/fs-codegen.js";
3
- import { camelCase } from "change-case-all";
3
+ import { camelCase, pascalCase } from "change-case-all";
4
4
  import { ProjectEnvUtils } from "../project/env.js";
5
5
  export function getVinxiFolder(opts) {
6
6
  return (opts.mode === "development" ? "dev" : "prod") + (opts.serverless ? "" : "-spa");
@@ -434,19 +434,30 @@ export function createVinxiCodegen(opts) {
434
434
  name: "manifest/blocks.ts",
435
435
  generate: async () => {
436
436
  const blockManifest = await project.blocks.get();
437
+ let blockImports = [];
438
+ let blockEntries = [];
439
+ for (const [name, block] of Object.entries(blockManifest.blocks)) {
440
+ if (name.match(/^_[a-z]+$/i))
441
+ continue;
442
+ const importSource = JSON.stringify("../../../" + block.fileName);
443
+ const jsName = pascalCase(name);
444
+ if (block.dynamic) {
445
+ const importStatement = `dynamic(() => import(${importSource}), ${JSON.stringify(block.fileName)})`;
446
+ blockEntries.push(JSON.stringify(block.acfName) + ": " + importStatement);
447
+ }
448
+ else {
449
+ blockImports.push(`import ${jsName} from ${importSource}`);
450
+ blockEntries.push(JSON.stringify(block.acfName) + ": " + jsName);
451
+ }
452
+ }
437
453
  return code /* ts */ `
438
454
  import { blockManifestReader } from 'eddev/_internal'
439
455
  import { dynamic } from 'eddev/dynamic'
440
456
  import core from '../../../blocks/_core'
457
+ ${blockImports.join("\n")}
441
458
 
442
459
  const manifest = {
443
- ${Object.entries(blockManifest.blocks)
444
- .filter(([name]) => !name.match(/^_[a-z]+$/i))
445
- .map(([name, block]) => {
446
- const importStatement = `dynamic(() => import(${JSON.stringify("../../../" + block.fileName)}), ${JSON.stringify(block.fileName)})`;
447
- return JSON.stringify(block.acfName) + ": " + importStatement;
448
- })
449
- .join(",\n")},
460
+ ${blockEntries.join(",\n")},
450
461
  ...core
451
462
  }
452
463
 
@@ -563,7 +563,7 @@ export class GraphQLGenerator {
563
563
  output = await codegen(config);
564
564
  }
565
565
  catch (err) {
566
- errors.push(String(err));
566
+ errors.push(err);
567
567
  }
568
568
  if (args.banner) {
569
569
  output = args.banner + "\n\n" + output + "\n" + (args.footer ?? "");
@@ -1 +1 @@
1
- {"version":3,"file":"gql-plugin-files.d.ts","sourceRoot":"","sources":["../../../../src/node/graphql/plugins/gql-plugin-files.ts"],"names":[],"mappings":"AAKA,KAAK,YAAY,GAAG;IAClB,UAAU,EAAE,MAAM,CAAA;IAClB,OAAO,EAAE,MAAM,CAAA;IACf,YAAY,EAAE,MAAM,CAAA;IACpB,UAAU,EAAE,MAAM,CAAA;IAClB,OAAO,CAAC,EAAE,CAAC,YAAY,EAAE,MAAM,EAAE,UAAU,EAAE,GAAG,EAAE,IAAI,EAAE,MAAM,KAAK,MAAM,CAAA;IACzE,eAAe,EAAE;QACf,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAA;KACtB,CAAA;IACD,MAAM,EAAE,MAAM,CAAA;CACf,CAAA;;qBAGkB,GAAG,aAAa,GAAG,UAAU,YAAY,QAAQ,GAAG;;AADvE,wBAkEC"}
1
+ {"version":3,"file":"gql-plugin-files.d.ts","sourceRoot":"","sources":["../../../../src/node/graphql/plugins/gql-plugin-files.ts"],"names":[],"mappings":"AAIA,KAAK,YAAY,GAAG;IAClB,UAAU,EAAE,MAAM,CAAA;IAClB,OAAO,EAAE,MAAM,CAAA;IACf,YAAY,EAAE,MAAM,CAAA;IACpB,UAAU,EAAE,MAAM,CAAA;IAClB,OAAO,CAAC,EAAE,CAAC,YAAY,EAAE,MAAM,EAAE,UAAU,EAAE,GAAG,EAAE,IAAI,EAAE,MAAM,KAAK,MAAM,CAAA;IACzE,eAAe,EAAE;QACf,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAA;KACtB,CAAA;IACD,MAAM,EAAE,MAAM,CAAA;CACf,CAAA;;qBAGkB,GAAG,aAAa,GAAG,UAAU,YAAY,QAAQ,GAAG;;AADvE,wBAkEC"}
@@ -1 +1 @@
1
- {"version":3,"file":"gql-plugin-queries.d.ts","sourceRoot":"","sources":["../../../../src/node/graphql/plugins/gql-plugin-queries.ts"],"names":[],"mappings":"AAYA,KAAK,YAAY,GAAG;IAClB,UAAU,EAAE,MAAM,CAAA;IAClB,OAAO,EAAE,MAAM,CAAA;CAChB,CAAA;;qBAKkB,GAAG,aAAa,GAAG,UAAU,YAAY,QAAQ,GAAG;;AADvE,wBA2TC"}
1
+ {"version":3,"file":"gql-plugin-queries.d.ts","sourceRoot":"","sources":["../../../../src/node/graphql/plugins/gql-plugin-queries.ts"],"names":[],"mappings":"AAWA,KAAK,YAAY,GAAG;IAClB,UAAU,EAAE,MAAM,CAAA;IAClB,OAAO,EAAE,MAAM,CAAA;CAChB,CAAA;;qBAKkB,GAAG,aAAa,GAAG,UAAU,YAAY,QAAQ,GAAG;;AADvE,wBA2TC"}
@@ -1,6 +1,6 @@
1
1
  import { printSourceLocation, visit, } from "graphql";
2
- import { code, imp } from "ts-poet";
3
2
  import { basename } from "path";
3
+ import { code, imp } from "ts-poet";
4
4
  export default {
5
5
  plugin: (schema, documents, config, info) => {
6
6
  const hooks = {};
@@ -134,6 +134,7 @@ function readBlockDataAsJSONExport(file, contents) {
134
134
  result.inserter = userData.inserter;
135
135
  result.frontendMode = userData.frontendMode;
136
136
  result.blockStyles = userData.blockStyles;
137
+ result.dynamic = userData.lazyLoad ?? true;
137
138
  if (userData.postMetaBlock) {
138
139
  result.postMetaBlock = {
139
140
  postTypes: userData.postMetaBlock.postTypes,
@@ -195,7 +196,7 @@ function readBlockDataAsComment(file) {
195
196
  meta.childTags = value.split(/,\s*/);
196
197
  return;
197
198
  case "dynamic":
198
- meta.dynamic = value === "true";
199
+ meta.dynamic = value !== "false";
199
200
  return;
200
201
  case "cache":
201
202
  meta.cache = value === "true";
@@ -47,6 +47,7 @@ export declare const BlockMetaSchema: z.ZodObject<{
47
47
  name: string;
48
48
  isDefault?: boolean | undefined;
49
49
  }>, "many">>;
50
+ lazyLoad: z.ZodOptional<z.ZodBoolean>;
50
51
  }, "strip", z.ZodTypeAny, {
51
52
  title: string;
52
53
  mode: "both" | "edit" | "preview";
@@ -80,6 +81,7 @@ export declare const BlockMetaSchema: z.ZodObject<{
80
81
  name: string;
81
82
  isDefault?: boolean | undefined;
82
83
  }[] | undefined;
84
+ lazyLoad?: boolean | undefined;
83
85
  }, {
84
86
  title: string;
85
87
  slug: string;
@@ -113,6 +115,7 @@ export declare const BlockMetaSchema: z.ZodObject<{
113
115
  name: string;
114
116
  isDefault?: boolean | undefined;
115
117
  }[] | undefined;
118
+ lazyLoad?: boolean | undefined;
116
119
  }>;
117
120
  export type BlockMetadata = z.infer<typeof BlockMetaSchema>;
118
121
  export type BlockMetadataConstructor = z.input<typeof BlockMetaSchema>;
@@ -1 +1 @@
1
- {"version":3,"file":"block-type.d.ts","sourceRoot":"","sources":["../../../src/node/types/block-type.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAEvB,OAAO,EAAE,aAAa,EAAE,MAAM,uCAAuC,CAAA;AAMrE,eAAO,MAAM,eAAe;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA+B1B,CAAA;AAEF,MAAM,MAAM,aAAa,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,eAAe,CAAC,CAAA;AAE3D,MAAM,MAAM,wBAAwB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,eAAe,CAAC,CAAA;AAEtE,wBAAgB,aAAa,CAAC,KAAK,EAAE,aAAa,UAkBjD;AAED,wBAAgB,qBAAqB,CAAC,QAAQ,EAAE,aAAa,UA6B5D"}
1
+ {"version":3,"file":"block-type.d.ts","sourceRoot":"","sources":["../../../src/node/types/block-type.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAEvB,OAAO,EAAE,aAAa,EAAE,MAAM,uCAAuC,CAAA;AAMrE,eAAO,MAAM,eAAe;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAgC1B,CAAA;AAEF,MAAM,MAAM,aAAa,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,eAAe,CAAC,CAAA;AAE3D,MAAM,MAAM,wBAAwB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,eAAe,CAAC,CAAA;AAEtE,wBAAgB,aAAa,CAAC,KAAK,EAAE,aAAa,UAkBjD;AAED,wBAAgB,qBAAqB,CAAC,QAAQ,EAAE,aAAa,UA6B5D"}
@@ -34,6 +34,7 @@ export const BlockMetaSchema = z.object({
34
34
  frontendMode: z.enum(["hidden", "childrenOnly", "default"]).default("default"),
35
35
  inserter: z.boolean().default(true),
36
36
  blockStyles: z.array(z.object({ name: z.string(), label: z.string(), isDefault: z.boolean().optional() })).optional(),
37
+ lazyLoad: z.boolean().optional(),
37
38
  });
38
39
  export function describeBlock(block) {
39
40
  let output = "";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "eddev",
3
- "version": "2.0.0-beta.164",
3
+ "version": "2.0.0-beta.166",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "type": "module",
@@ -119,6 +119,7 @@
119
119
  "obj-console": "^1.0.2",
120
120
  "object-code": "^1.3.3",
121
121
  "qs": "^6.13.0",
122
+ "rollup-plugin-visualizer": "^5.14.0",
122
123
  "superjson": "^2.2.1",
123
124
  "ts-poet": "^6.6.0",
124
125
  "ufo": "^1.3.1",
package/types.meta.d.ts CHANGED
@@ -179,6 +179,13 @@ declare global {
179
179
  * Block styles work like 'variants' for a block, allowing you to quickly switch between different styles of the same block.
180
180
  */
181
181
  blockStyles?: { name: string; label: string; isDefault?: boolean }[]
182
+
183
+ /**
184
+ * Whether to lazy-load this block using Suspense.
185
+ * You can disable this for blocks with a smaller size footprint, or blocks which are almost always rendered on first visit.
186
+ * @default true
187
+ */
188
+ lazyLoad?: boolean
182
189
  }
183
190
  }
184
191
  type BlockIcon =