@emberbox/ui 0.6.0 → 0.6.1

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.
@@ -11,6 +11,22 @@ function sitemap(url, paths) {
11
11
  const entries = paths.map(path => ` <url><loc>${url}${path}</loc></url>`).join('\n');
12
12
  return `<?xml version="1.0" encoding="UTF-8"?>\n<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">\n${entries}\n</urlset>\n`;
13
13
  }
14
+ /**
15
+ * Vue's compile-time feature flags with their production values. Dependencies that Node loads in
16
+ * their bundler build, such as vue-i18n, read them as globals: a bundler replaces them, Node does not.
17
+ * The values are the defaults of `@vitejs/plugin-vue`.
18
+ */
19
+ const VUE_FLAGS = {
20
+ __VUE_OPTIONS_API__: true,
21
+ __VUE_PROD_DEVTOOLS__: false,
22
+ __VUE_PROD_HYDRATION_MISMATCH_DETAILS__: false,
23
+ };
24
+ /** Defines Vue's feature flags as globals where nothing has defined them yet, as Vue's own bundler build does. */
25
+ function defineVueFlags() {
26
+ const scope = globalThis;
27
+ for (const [flag, value] of Object.entries(VUE_FLAGS))
28
+ scope[flag] ??= value;
29
+ }
14
30
  /**
15
31
  * Prerenders the public pages once the client build is written. It builds the entry as an SSR
16
32
  * bundle, calls `render` for every path with the built `index.html` as template and writes the
@@ -41,6 +57,7 @@ export function prerenderPlugin(options, url) {
41
57
  const bundle = readdirSync(ssrOutDir).find(candidate => /^(.+)\.m?js$/.exec(candidate)?.[1] === name);
42
58
  if (!bundle)
43
59
  throw new Error(`The SSR bundle of ${options.entry} is missing in ${ssrOutDir}.`);
60
+ defineVueFlags();
44
61
  const entry = await import(pathToFileURL(join(ssrOutDir, bundle)).href);
45
62
  const template = readFileSync(join(outDir, 'index.html'), 'utf8');
46
63
  for (const path of options.paths) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@emberbox/ui",
3
- "version": "0.6.0",
3
+ "version": "0.6.1",
4
4
  "description": "Shared look and building blocks of the Emberbox tools, built on Nuxt UI.",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -28,6 +28,23 @@ function sitemap(url: string, paths: string[]): string {
28
28
  return `<?xml version="1.0" encoding="UTF-8"?>\n<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">\n${entries}\n</urlset>\n`
29
29
  }
30
30
 
31
+ /**
32
+ * Vue's compile-time feature flags with their production values. Dependencies that Node loads in
33
+ * their bundler build, such as vue-i18n, read them as globals: a bundler replaces them, Node does not.
34
+ * The values are the defaults of `@vitejs/plugin-vue`.
35
+ */
36
+ const VUE_FLAGS = {
37
+ __VUE_OPTIONS_API__: true,
38
+ __VUE_PROD_DEVTOOLS__: false,
39
+ __VUE_PROD_HYDRATION_MISMATCH_DETAILS__: false,
40
+ }
41
+
42
+ /** Defines Vue's feature flags as globals where nothing has defined them yet, as Vue's own bundler build does. */
43
+ function defineVueFlags(): void {
44
+ const scope = globalThis as Record<string, unknown>
45
+ for (const [flag, value] of Object.entries(VUE_FLAGS)) scope[flag] ??= value
46
+ }
47
+
31
48
  /**
32
49
  * Prerenders the public pages once the client build is written. It builds the entry as an SSR
33
50
  * bundle, calls `render` for every path with the built `index.html` as template and writes the
@@ -56,6 +73,7 @@ export function prerenderPlugin(options: PrerenderOptions, url: string): Plugin
56
73
  const name = basename(options.entry, extname(options.entry))
57
74
  const bundle = readdirSync(ssrOutDir).find(candidate => /^(.+)\.m?js$/.exec(candidate)?.[1] === name)
58
75
  if (!bundle) throw new Error(`The SSR bundle of ${options.entry} is missing in ${ssrOutDir}.`)
76
+ defineVueFlags()
59
77
  const entry = await import(pathToFileURL(join(ssrOutDir, bundle)).href) as PrerenderEntry
60
78
  const template = readFileSync(join(outDir, 'index.html'), 'utf8')
61
79
  for (const path of options.paths) {