@blinkk/root 1.0.0-alpha.1 → 1.0.0-alpha.2

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/bin/root.js CHANGED
@@ -1,10 +1,17 @@
1
1
  #!/usr/bin/env node
2
2
 
3
+ import {createRequire} from 'node:module';
4
+ import path from 'node:path';
5
+ import {fileURLToPath} from 'node:url';
3
6
  import {Command} from 'commander';
4
7
  import {build, dev, start} from '../dist/cli.js';
5
8
 
9
+ const __dirname = path.dirname(fileURLToPath(import.meta.url));
10
+ const require = createRequire(import.meta.url);
11
+ const packageJson = require(path.join(__dirname, '../package.json'));
12
+
6
13
  const program = new Command('root');
7
- program.version(process.env.npm_package_version || 'dev');
14
+ program.version(packageJson.version);
8
15
 
9
16
  program
10
17
  .command('build [path]')
package/dist/cli.js CHANGED
@@ -1,5 +1,5 @@
1
1
  // src/cli/commands/dev.ts
2
- import path3 from "node:path";
2
+ import path4 from "node:path";
3
3
  import { fileURLToPath } from "node:url";
4
4
  import { default as express } from "express";
5
5
  import { createServer as createViteServer } from "vite";
@@ -201,16 +201,59 @@ async function htmlMinify(html) {
201
201
  return min.trimStart();
202
202
  }
203
203
 
204
+ // src/core/fsutils.ts
205
+ import { promises as fs } from "node:fs";
206
+ import path3 from "node:path";
207
+ import fsExtra from "fs-extra";
208
+ function isJsFile2(file) {
209
+ return !!file.match(/\.(j|t)sx?$/);
210
+ }
211
+ async function writeFile(filePath, content) {
212
+ const dirPath = path3.dirname(filePath);
213
+ await makeDir(dirPath);
214
+ await fs.writeFile(filePath, content);
215
+ }
216
+ async function makeDir(dirPath) {
217
+ try {
218
+ await fs.access(dirPath);
219
+ } catch (e) {
220
+ await fs.mkdir(dirPath, { recursive: true });
221
+ }
222
+ }
223
+ async function copyDir(srcDir, dstDir) {
224
+ if (!fsExtra.existsSync(srcDir)) {
225
+ return;
226
+ }
227
+ fsExtra.copySync(srcDir, dstDir, { recursive: true, overwrite: true });
228
+ }
229
+ async function rmDir(dirPath) {
230
+ await fs.rm(dirPath, { recursive: true, force: true });
231
+ }
232
+ async function loadJson(filePath) {
233
+ const content = await fs.readFile(filePath, "utf-8");
234
+ return JSON.parse(content);
235
+ }
236
+ async function isDirectory(dirPath) {
237
+ return fs.stat(dirPath).then((fsStat) => {
238
+ return fsStat.isDirectory();
239
+ }).catch((err) => {
240
+ if (err.code === "ENOENT") {
241
+ return false;
242
+ }
243
+ throw err;
244
+ });
245
+ }
246
+
204
247
  // src/cli/commands/dev.ts
205
- var __dirname2 = path3.dirname(fileURLToPath(import.meta.url));
248
+ import glob2 from "tiny-glob";
249
+ var __dirname2 = path4.dirname(fileURLToPath(import.meta.url));
206
250
  async function createServer(options) {
207
251
  const app = express();
208
252
  app.use(express.static("public"));
209
253
  const middlewares = await getMiddlewares({ rootDir: options == null ? void 0 : options.rootDir });
210
254
  middlewares.forEach((middleware) => app.use(middleware));
211
255
  const port = parseInt(process.env.PORT || "4007");
212
- const version = process.env.npm_package_version || "dev";
213
- console.log(`\u{1F333} Root.js v${version}`);
256
+ console.log("\u{1F333} Root.js");
214
257
  console.log();
215
258
  console.log(`Started server: http://localhost:${port}`);
216
259
  app.listen(port);
@@ -219,13 +262,46 @@ async function getMiddlewares(options) {
219
262
  const rootDir = (options == null ? void 0 : options.rootDir) || process.cwd();
220
263
  const rootConfig = await loadRootConfig(rootDir);
221
264
  const viteConfig = rootConfig.vite || {};
222
- const renderModulePath = path3.resolve(__dirname2, "./render.js");
265
+ const renderModulePath = path4.resolve(__dirname2, "./render.js");
266
+ const pages = [];
267
+ if (await isDirectory(path4.join(rootDir, "routes"))) {
268
+ const pageFiles = await glob2(path4.join(rootDir, "routes/**/*"));
269
+ pageFiles.forEach((file) => {
270
+ const parts = path4.parse(file);
271
+ if (!parts.name.startsWith("_") && isJsFile2(parts.base)) {
272
+ pages.push(file);
273
+ }
274
+ });
275
+ }
276
+ const elements = [];
277
+ if (await isDirectory(path4.join(rootDir, "elements"))) {
278
+ const elementFiles = await glob2(path4.join(rootDir, "elements/**/*"));
279
+ elementFiles.forEach((file) => {
280
+ const parts = path4.parse(file);
281
+ if (isJsFile2(parts.base)) {
282
+ elements.push(file);
283
+ }
284
+ });
285
+ }
286
+ const bundleScripts = [];
287
+ if (await isDirectory(path4.join(rootDir, "bundles"))) {
288
+ const bundleFiles = await glob2(path4.join(rootDir, "bundles/*"));
289
+ bundleFiles.forEach((file) => {
290
+ const parts = path4.parse(file);
291
+ if (isJsFile2(parts.base)) {
292
+ bundleScripts.push(file);
293
+ }
294
+ });
295
+ }
223
296
  const viteServer = await createViteServer({
224
297
  ...viteConfig,
225
298
  server: { middlewareMode: true },
226
299
  appType: "custom",
227
300
  optimizeDeps: {
228
- include: [renderModulePath]
301
+ include: [...pages, ...elements, ...bundleScripts]
302
+ },
303
+ ssr: {
304
+ noExternal: ["@blinkk/root"]
229
305
  },
230
306
  esbuild: {
231
307
  jsx: "automatic",
@@ -266,11 +342,11 @@ function dev(rootDir) {
266
342
  import path6 from "node:path";
267
343
  import { fileURLToPath as fileURLToPath2 } from "node:url";
268
344
  import fsExtra2 from "fs-extra";
269
- import glob2 from "tiny-glob";
345
+ import glob3 from "tiny-glob";
270
346
  import { build as viteBuild } from "vite";
271
347
 
272
348
  // src/render/asset-map/build-asset-map.ts
273
- import path4 from "path";
349
+ import path5 from "path";
274
350
  var BuildAssetMap = class {
275
351
  constructor(manifest) {
276
352
  this.manifest = manifest;
@@ -323,7 +399,7 @@ var BuildAsset = class {
323
399
  return;
324
400
  }
325
401
  visited.add(asset.moduleId);
326
- const parts = path4.parse(asset.assetUrl);
402
+ const parts = path5.parse(asset.assetUrl);
327
403
  if ([".ts", ".tsx"].includes(parts.ext) && asset.moduleId.includes("/elements/")) {
328
404
  urls.add(asset.assetUrl);
329
405
  }
@@ -361,54 +437,10 @@ var BuildAsset = class {
361
437
  }
362
438
  };
363
439
 
364
- // src/core/fsutils.ts
365
- import { promises as fs } from "node:fs";
366
- import path5 from "node:path";
367
- import fsExtra from "fs-extra";
368
- function isJsFile2(file) {
369
- return !!file.match(/\.(j|t)sx?$/);
370
- }
371
- async function writeFile(filePath, content) {
372
- const dirPath = path5.dirname(filePath);
373
- await makeDir(dirPath);
374
- await fs.writeFile(filePath, content);
375
- }
376
- async function makeDir(dirPath) {
377
- try {
378
- await fs.access(dirPath);
379
- } catch (e) {
380
- await fs.mkdir(dirPath, { recursive: true });
381
- }
382
- }
383
- async function copyDir(srcDir, dstDir) {
384
- if (!fsExtra.existsSync(srcDir)) {
385
- return;
386
- }
387
- fsExtra.copySync(srcDir, dstDir, { recursive: true, overwrite: true });
388
- }
389
- async function rmDir(dirPath) {
390
- await fs.rm(dirPath, { recursive: true, force: true });
391
- }
392
- async function loadJson(filePath) {
393
- const content = await fs.readFile(filePath, "utf-8");
394
- return JSON.parse(content);
395
- }
396
- async function isDirectory(dirPath) {
397
- return fs.stat(dirPath).then((fsStat) => {
398
- return fsStat.isDirectory();
399
- }).catch((err) => {
400
- if (err.code === "ENOENT") {
401
- return false;
402
- }
403
- throw err;
404
- });
405
- }
406
-
407
440
  // src/cli/commands/build.ts
408
441
  var __dirname3 = path6.dirname(fileURLToPath2(import.meta.url));
409
442
  async function build(rootDir) {
410
- const version = process.env.npm_package_version || "dev";
411
- console.log(`\u{1F333} Root.js v${version}`);
443
+ console.log("\u{1F333} Root.js");
412
444
  if (!rootDir) {
413
445
  rootDir = process.cwd();
414
446
  }
@@ -418,7 +450,7 @@ async function build(rootDir) {
418
450
  await makeDir(distDir);
419
451
  const pages = [];
420
452
  if (await isDirectory(path6.join(rootDir, "routes"))) {
421
- const pageFiles = await glob2(path6.join(rootDir, "routes/**/*"));
453
+ const pageFiles = await glob3(path6.join(rootDir, "routes/**/*"));
422
454
  pageFiles.forEach((file) => {
423
455
  const parts = path6.parse(file);
424
456
  if (!parts.name.startsWith("_") && isJsFile2(parts.base)) {
@@ -428,7 +460,7 @@ async function build(rootDir) {
428
460
  }
429
461
  const elements = [];
430
462
  if (await isDirectory(path6.join(rootDir, "elements"))) {
431
- const elementFiles = await glob2(path6.join(rootDir, "elements/**/*"));
463
+ const elementFiles = await glob3(path6.join(rootDir, "elements/**/*"));
432
464
  elementFiles.forEach((file) => {
433
465
  const parts = path6.parse(file);
434
466
  if (isJsFile2(parts.base)) {
@@ -438,7 +470,7 @@ async function build(rootDir) {
438
470
  }
439
471
  const bundleScripts = [];
440
472
  if (await isDirectory(path6.join(rootDir, "bundles"))) {
441
- const bundleFiles = await glob2(path6.join(rootDir, "bundles/*"));
473
+ const bundleFiles = await glob3(path6.join(rootDir, "bundles/*"));
442
474
  bundleFiles.forEach((file) => {
443
475
  const parts = path6.parse(file);
444
476
  if (isJsFile2(parts.base)) {
@@ -478,6 +510,9 @@ async function build(rootDir) {
478
510
  minify: false,
479
511
  polyfillModulePreload: false,
480
512
  reportCompressedSize: false
513
+ },
514
+ ssr: {
515
+ noExternal: ["@blinkk/root"]
481
516
  }
482
517
  });
483
518
  await viteBuild({
package/dist/cli.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/cli/commands/dev.ts","../src/render/vite-plugin-root.ts","../src/render/asset-map/dev-asset-map.ts","../src/cli/load-config.ts","../src/render/html-minify.ts","../src/cli/commands/build.ts","../src/render/asset-map/build-asset-map.ts","../src/core/fsutils.ts","../src/cli/commands/start.ts"],"sourcesContent":["import path from 'node:path';\nimport {fileURLToPath} from 'node:url';\nimport {default as express, Request, Response, NextFunction} from 'express';\nimport {createServer as createViteServer} from 'vite';\nimport pluginRoot from '../../render/vite-plugin-root.js';\nimport {DevServerAssetMap} from '../../render/asset-map/dev-asset-map.js';\nimport {loadRootConfig} from '../load-config.js';\nimport {htmlMinify} from '../../render/html-minify.js';\nimport {Renderer} from '../../render/render.js';\n\nconst __dirname = path.dirname(fileURLToPath(import.meta.url));\n\nexport async function createServer(options?: {rootDir?: string}) {\n const app = express();\n\n app.use(express.static('public'));\n const middlewares = await getMiddlewares({rootDir: options?.rootDir});\n middlewares.forEach((middleware) => app.use(middleware));\n\n const port = parseInt(process.env.PORT || '4007');\n const version = process.env.npm_package_version || 'dev';\n console.log(`🌳 Root.js v${version}`);\n console.log();\n console.log(`Started server: http://localhost:${port}`);\n app.listen(port);\n}\n\nexport async function getMiddlewares(options?: {rootDir?: string}) {\n const rootDir = options?.rootDir || process.cwd();\n const rootConfig = await loadRootConfig(rootDir);\n const viteConfig = rootConfig.vite || {};\n const renderModulePath = path.resolve(__dirname, './render.js');\n\n const viteServer = await createViteServer({\n ...viteConfig,\n server: {middlewareMode: true},\n appType: 'custom',\n optimizeDeps: {\n include: [renderModulePath],\n },\n esbuild: {\n jsx: 'automatic',\n jsxImportSource: 'preact',\n },\n plugins: [...(viteConfig.plugins || []), pluginRoot()],\n });\n\n const rootMiddleware = async (\n req: Request,\n res: Response,\n next: NextFunction\n ) => {\n const url = req.originalUrl;\n const render = await viteServer.ssrLoadModule(renderModulePath);\n const renderer = new render.Renderer(rootConfig) as Renderer;\n try {\n // Create a dev asset map using Vite dev server's module graph.\n const assetMap = new DevServerAssetMap(viteServer.moduleGraph);\n const data = await renderer.render(url, {\n assetMap: assetMap,\n });\n // Inject the Vite HMR client.\n const html = await htmlMinify(\n await viteServer.transformIndexHtml(url, data.html || '')\n );\n\n res.status(200).set({'Content-Type': 'text/html'}).end(html);\n } catch (e) {\n // If an error is caught, let Vite fix the stack trace so it maps back to\n // your actual source code.\n viteServer.ssrFixStacktrace(e);\n try {\n const {html} = await renderer.renderError(e);\n res.status(500).set({'Content-Type': 'text/html'}).end(html);\n } catch (e2) {\n console.error('failed to render custom error');\n console.error(e2);\n next(e);\n }\n }\n };\n\n return [viteServer.middlewares, rootMiddleware];\n}\n\nexport function dev(rootDir?: string) {\n createServer({rootDir});\n}\n","import path from 'path';\nimport glob from 'tiny-glob';\nimport {ViteDevServer} from 'vite';\n\nconst ELEMENTS_REGEX = /h\\(\"(\\w[\\w-]+\\w)\"/g;\n\nexport interface RootPluginOptions {\n // Project directory.\n rootDir?: string;\n}\n\nexport function pluginRoot(options?: RootPluginOptions) {\n const rootDir = options?.rootDir || process.cwd();\n let config: any;\n let server: ViteDevServer;\n let elementMap: Record<string, string>;\n\n async function updateElementMap() {\n elementMap = {};\n const files = await glob('./elements/**/*', {cwd: rootDir});\n files.forEach((file) => {\n const parts = path.parse(file);\n if (isJsFile(parts.base)) {\n elementMap[parts.name] = `${rootDir}/${file}`;\n }\n });\n }\n\n async function getElementImport(tagName: string): Promise<string | null> {\n if (!elementMap) {\n await updateElementMap();\n }\n if (tagName in elementMap) {\n const filePath = elementMap[tagName];\n if (server && server.moduleGraph) {\n const moduleSet = server.moduleGraph.getModulesByFile(filePath);\n if (moduleSet && moduleSet.size > 0) {\n const module = moduleSet.values().next().value;\n return module.url;\n }\n }\n }\n return null;\n }\n\n return {\n name: 'vite-plugin-root',\n\n // TODO(stevenle): when the config is resolved, store a list of places to\n // find custom elements.\n configResolved(resolvedConfig: any) {\n config = resolvedConfig;\n },\n\n configureServer(_server: ViteDevServer) {\n server = _server;\n },\n\n async transform(src: string, id: string): Promise<any> {\n if (id.includes('/elements/') && isJsFile(id)) {\n const idParts = path.parse(id);\n const deps = new Set<string>();\n const elementsRe = ELEMENTS_REGEX;\n for (const match of src.matchAll(elementsRe)) {\n const tagName = match[1];\n // All custom elements should contain a dash.\n if (!tagName.includes('-')) {\n continue;\n }\n // Avoid circular deps.\n if (tagName === idParts.name) {\n continue;\n }\n deps.add(tagName);\n }\n const importUrls: string[] = [];\n await Promise.all(\n Array.from(deps).map(async (tagName) => {\n const importUrl = await getElementImport(tagName);\n if (importUrl) {\n importUrls.push(importUrl);\n }\n })\n );\n if (importUrls.length > 0) {\n const importLines = importUrls\n .map((url) => `import '${url}';`)\n .join('\\n');\n const code = `${src}\n\n// autogenerated by root:\n${importLines}\n`;\n return {code};\n }\n return null;\n }\n },\n };\n}\n\nfunction isJsFile(file: string): boolean {\n return !!file.match(/\\.(j|t)sx?$/);\n}\n\nexport default pluginRoot;\n","import path from 'node:path';\nimport {ModuleGraph, ModuleNode} from 'vite';\nimport {Asset, AssetMap} from './asset-map';\n\nexport class DevServerAssetMap implements AssetMap {\n private moduleGraph: ModuleGraph;\n\n constructor(moduleGraph: ModuleGraph) {\n this.moduleGraph = moduleGraph;\n }\n\n async get(moduleId: string): Promise<Asset | null> {\n const viteModule = await this.moduleGraph.getModuleByUrl(moduleId);\n if (!viteModule || !viteModule.id) {\n return null;\n }\n return new DevServerAsset(this, viteModule);\n }\n}\n\nexport class DevServerAsset implements Asset {\n moduleId: string;\n assetUrl: string;\n private assetMap: AssetMap;\n private viteModule: ModuleNode;\n\n constructor(assetMap: AssetMap, viteModule: ModuleNode) {\n this.assetMap = assetMap;\n this.viteModule = viteModule;\n this.moduleId = this.viteModule.id!;\n this.assetUrl = this.viteModule.url;\n }\n\n async getCssDeps(): Promise<string[]> {\n const visited = new Set<string>();\n const deps = new Set<string>();\n this.collectCss(this, deps, visited);\n return Array.from(deps);\n }\n\n async getJsDeps(): Promise<string[]> {\n const visited = new Set<string>();\n const deps = new Set<string>();\n this.collectJs(this, deps, visited);\n return Array.from(deps);\n }\n\n getImportedModules() {\n return this.viteModule.importedModules;\n }\n\n private collectJs(\n asset: DevServerAsset | null,\n urls: Set<string>,\n visited: Set<string>\n ) {\n if (!asset) {\n return;\n }\n if (!asset.moduleId) {\n return;\n }\n if (visited.has(asset.moduleId)) {\n return;\n }\n visited.add(asset.moduleId);\n const parts = path.parse(asset.assetUrl);\n if (\n ['.js', '.jsx', '.ts', '.tsx'].includes(parts.ext) &&\n asset.moduleId.includes('/elements/')\n ) {\n urls.add(asset.assetUrl);\n }\n asset.getImportedModules().forEach((viteModule) => {\n if (viteModule.id) {\n const importedAsset = new DevServerAsset(this.assetMap, viteModule);\n this.collectJs(importedAsset, urls, visited);\n }\n });\n }\n\n private collectCss(\n asset: DevServerAsset | null,\n urls: Set<string>,\n visited: Set<string>\n ) {\n if (!asset) {\n return;\n }\n if (!asset.assetUrl) {\n return;\n }\n if (visited.has(asset.assetUrl)) {\n return;\n }\n visited.add(asset.assetUrl);\n if (asset.moduleId.endsWith('.scss')) {\n const parts = path.parse(asset.assetUrl);\n if (!parts.name.startsWith('_')) {\n urls.add(asset.assetUrl);\n }\n }\n asset.getImportedModules().forEach((viteModule) => {\n if (viteModule.id) {\n const importedAsset = new DevServerAsset(this.assetMap, viteModule);\n this.collectCss(importedAsset, urls, visited);\n }\n });\n }\n}\n","import {bundleRequire} from 'bundle-require';\nimport JoyCon from 'joycon';\nimport {RootConfig} from '../core/config';\n\nexport async function loadRootConfig(rootDir: string): Promise<RootConfig> {\n const joycon = new JoyCon();\n const configPath = await joycon.resolve({\n cwd: rootDir,\n files: ['root.config.ts'],\n });\n if (configPath) {\n const configBundle = await bundleRequire({\n filepath: configPath,\n });\n return configBundle.mod.default || {};\n }\n return {};\n}\n","import {minify} from 'html-minifier-terser';\n\nexport async function htmlMinify(html: string): Promise<string> {\n const min = await minify(html, {\n collapseWhitespace: true,\n removeComments: true,\n preserveLineBreaks: true,\n });\n return min.trimStart();\n}\n","import path from 'node:path';\nimport {fileURLToPath} from 'node:url';\nimport fsExtra from 'fs-extra';\nimport glob from 'tiny-glob';\nimport {build as viteBuild} from 'vite';\nimport {pluginRoot} from '../../render/vite-plugin-root.js';\nimport {BuildAssetMap} from '../../render/asset-map/build-asset-map.js';\nimport {loadRootConfig} from '../load-config.js';\nimport {\n copyDir,\n isDirectory,\n isJsFile,\n loadJson,\n makeDir,\n rmDir,\n writeFile,\n} from '../../core/fsutils.js';\nimport {Renderer} from '../../render/render.js';\nimport {htmlMinify} from '../../render/html-minify.js';\n\nconst __dirname = path.dirname(fileURLToPath(import.meta.url));\n\nexport async function build(rootDir?: string) {\n const version = process.env.npm_package_version || 'dev';\n console.log(`🌳 Root.js v${version}`);\n\n if (!rootDir) {\n rootDir = process.cwd();\n }\n const rootConfig = await loadRootConfig(rootDir);\n const distDir = path.join(rootDir, 'dist');\n await rmDir(distDir);\n await makeDir(distDir);\n\n const pages: string[] = [];\n if (await isDirectory(path.join(rootDir, 'routes'))) {\n const pageFiles = await glob(path.join(rootDir, 'routes/**/*'));\n pageFiles.forEach((file) => {\n const parts = path.parse(file);\n if (!parts.name.startsWith('_') && isJsFile(parts.base)) {\n pages.push(file);\n }\n });\n }\n\n const elements: string[] = [];\n if (await isDirectory(path.join(rootDir, 'elements'))) {\n const elementFiles = await glob(path.join(rootDir, 'elements/**/*'));\n elementFiles.forEach((file) => {\n const parts = path.parse(file);\n if (isJsFile(parts.base)) {\n elements.push(file);\n }\n });\n }\n\n const bundleScripts: string[] = [];\n if (await isDirectory(path.join(rootDir, 'bundles'))) {\n const bundleFiles = await glob(path.join(rootDir, 'bundles/*'));\n bundleFiles.forEach((file) => {\n const parts = path.parse(file);\n if (isJsFile(parts.base)) {\n bundleScripts.push(file);\n }\n });\n }\n\n const viteConfig = rootConfig.vite || {};\n const baseConfig = {\n ...viteConfig,\n root: rootDir,\n esbuild: {\n jsxFactory: 'h',\n jsxFragment: 'Fragment',\n jsxInject: 'import {h, Fragment} from \"preact\";',\n },\n plugins: [...(viteConfig.plugins || []), pluginRoot()],\n };\n\n // Bundle the render.js file with vite, which is pre-optimized for rendering\n // HTML routes.\n await viteBuild({\n ...baseConfig,\n mode: 'production',\n publicDir: false,\n build: {\n rollupOptions: {\n input: [path.resolve(__dirname, './render.js')],\n output: {\n format: 'esm',\n chunkFileNames: 'chunks/[name].[hash].js',\n assetFileNames: 'assets/[name].[hash][extname]',\n },\n },\n outDir: path.join(distDir, 'server'),\n ssr: true,\n ssrManifest: false,\n cssCodeSplit: true,\n target: 'esnext',\n minify: false,\n polyfillModulePreload: false,\n reportCompressedSize: false,\n },\n });\n\n // Pre-render any client scripts and CSS deps.\n await viteBuild({\n ...baseConfig,\n mode: 'production',\n publicDir: false,\n build: {\n rollupOptions: {\n input: [...pages, ...elements, ...bundleScripts],\n output: {\n format: 'esm',\n chunkFileNames: 'chunks/[name].[hash].js',\n assetFileNames: 'assets/[name].[hash][extname]',\n },\n },\n outDir: path.join(distDir, 'client'),\n ssr: false,\n ssrManifest: false,\n manifest: true,\n cssCodeSplit: true,\n target: 'esnext',\n minify: true,\n polyfillModulePreload: false,\n reportCompressedSize: false,\n },\n });\n\n const manifest = await loadJson(path.join(distDir, 'client/manifest.json'));\n\n // Use the output of the client build to generate an asset map, which is used\n // by the renderer for automatically injecting dependencies for a page.\n const assetMap = new BuildAssetMap(manifest);\n\n // Save the asset map to `dist/client` for use by the prod SSR server.\n writeFile(\n path.join(distDir, 'client/root-manifest.json'),\n JSON.stringify(assetMap.toJson(), null, 2)\n );\n\n // Write SSG output to `dist/html`.\n const buildDir = path.join(distDir, 'html');\n\n // Recursively copy files from `public` to `dist/html`.\n const publicDir = path.join(rootDir, 'public');\n if (fsExtra.existsSync(path.join(rootDir, 'public'))) {\n fsExtra.copySync(publicDir, buildDir);\n } else {\n makeDir(buildDir);\n }\n\n // Copy files from `dist/client/{assets,chunks}` to `dist/html`.\n copyDir(path.join(distDir, 'client/assets'), path.join(buildDir, 'assets'));\n copyDir(path.join(distDir, 'client/chunks'), path.join(buildDir, 'chunks'));\n\n // Render HTML pages.\n const render = await import(path.join(distDir, 'server/render.js'));\n const renderer = new render.Renderer(rootConfig) as Renderer;\n const sitemap = await renderer.getSitemap();\n\n await Promise.all(\n Object.keys(sitemap).map(async (urlPath) => {\n const {route, params} = sitemap[urlPath];\n const data = await renderer.renderRoute(route, {\n assetMap,\n routeParams: params,\n });\n\n // The renderer currently assumes that all paths serve HTML.\n // TODO(stevenle): support non-HTML routes using `routes/[name].[ext].ts`.\n let outPath = path.join(distDir, `html${urlPath}`, 'index.html');\n\n if (outPath.endsWith('404/index.html')) {\n outPath = outPath.replace('404/index.html', '404.html');\n }\n\n const html = await htmlMinify(data.html || '');\n await writeFile(outPath, html);\n\n const relPath = outPath.slice(path.dirname(distDir).length + 1);\n console.log(`saved ${relPath}`);\n })\n );\n}\n","import path from 'path';\nimport {Manifest, ManifestChunk} from 'vite';\nimport {Asset, AssetMap} from './asset-map';\n\nexport class BuildAssetMap implements AssetMap {\n private manifest: Manifest;\n private moduleIdToAsset: Map<string, BuildAsset>;\n\n constructor(manifest: Manifest) {\n this.manifest = manifest;\n this.moduleIdToAsset = new Map();\n Object.keys(this.manifest).forEach((manifestKey) => {\n const moduleId = `/${manifestKey}`;\n this.moduleIdToAsset.set(\n moduleId,\n new BuildAsset(this, moduleId, this.manifest[manifestKey])\n );\n });\n }\n\n async get(moduleId: string): Promise<Asset | null> {\n return this.moduleIdToAsset.get(moduleId) || null;\n }\n\n toJson(): any {\n const result: any = {};\n for (const moduleId of this.moduleIdToAsset.keys()) {\n result[moduleId] = this.moduleIdToAsset.get(moduleId)!.toJson();\n }\n return result;\n }\n}\n\nexport class BuildAsset {\n moduleId: string;\n assetUrl: string;\n private assetMap: BuildAssetMap;\n private manifestData: ManifestChunk;\n private importedModules: string[];\n private importedCss: string[];\n\n constructor(\n assetMap: BuildAssetMap,\n moduleId: string,\n manifestData: ManifestChunk\n ) {\n this.assetMap = assetMap;\n this.moduleId = moduleId;\n this.manifestData = manifestData;\n this.assetUrl = `/${manifestData.file}`;\n this.importedModules = (this.manifestData.imports || []).map(\n (relPath) => `/${relPath}`\n );\n this.importedCss = (this.manifestData.css || []).map(\n (relPath) => `/${relPath}`\n );\n }\n\n async getCssDeps(): Promise<string[]> {\n const visited = new Set<string>();\n const deps = new Set<string>();\n await this.collectCss(this, deps, visited);\n return Array.from(deps);\n }\n\n async getJsDeps(): Promise<string[]> {\n const visited = new Set<string>();\n const deps = new Set<string>();\n await this.collectJs(this, deps, visited);\n return Array.from(deps);\n }\n\n private async collectJs(\n asset: BuildAsset | null,\n urls: Set<string>,\n visited: Set<string>\n ) {\n if (!asset) {\n return;\n }\n if (!asset.moduleId) {\n return;\n }\n if (visited.has(asset.moduleId)) {\n return;\n }\n visited.add(asset.moduleId);\n const parts = path.parse(asset.assetUrl);\n if (\n ['.ts', '.tsx'].includes(parts.ext) &&\n asset.moduleId.includes('/elements/')\n ) {\n urls.add(asset.assetUrl);\n }\n await Promise.all(\n asset.importedModules.map(async (moduleId) => {\n const importedAsset = (await this.assetMap.get(moduleId)) as BuildAsset;\n this.collectJs(importedAsset, urls, visited);\n })\n );\n }\n\n private async collectCss(\n asset: BuildAsset | null,\n urls: Set<string>,\n visited: Set<string>\n ) {\n if (!asset) {\n return;\n }\n if (!asset.assetUrl) {\n return;\n }\n if (visited.has(asset.moduleId)) {\n return;\n }\n visited.add(asset.moduleId);\n if (asset.importedCss) {\n asset.importedCss.forEach((cssUrl) => urls.add(cssUrl));\n }\n await Promise.all(\n asset.importedModules.map(async (moduleId) => {\n const importedAsset = (await this.assetMap.get(moduleId)) as BuildAsset;\n this.collectCss(importedAsset, urls, visited);\n })\n );\n }\n\n toJson(): any {\n return {\n moduleId: this.moduleId,\n assetUrl: this.assetUrl,\n importedModules: this.importedModules,\n importedCss: this.importedCss,\n };\n }\n}\n","import {promises as fs} from 'node:fs';\nimport path from 'node:path';\nimport fsExtra from 'fs-extra';\n\nexport function isJsFile(file: string) {\n return !!file.match(/\\.(j|t)sx?$/);\n}\n\nexport async function writeFile(filePath: string, content: string) {\n const dirPath = path.dirname(filePath);\n await makeDir(dirPath);\n await fs.writeFile(filePath, content);\n}\n\nexport async function makeDir(dirPath: string) {\n try {\n await fs.access(dirPath);\n } catch (e) {\n await fs.mkdir(dirPath, {recursive: true});\n }\n}\n\nexport async function copyDir(srcDir: string, dstDir: string) {\n if (!fsExtra.existsSync(srcDir)) {\n return;\n }\n fsExtra.copySync(srcDir, dstDir, {recursive: true, overwrite: true});\n}\n\nexport async function rmDir(dirPath: string) {\n await fs.rm(dirPath, {recursive: true, force: true});\n}\n\nexport async function loadJson(filePath: string): Promise<any> {\n const content = await fs.readFile(filePath, 'utf-8');\n return JSON.parse(content);\n}\n\nexport async function isDirectory(dirPath: string) {\n return fs\n .stat(dirPath)\n .then((fsStat) => {\n return fsStat.isDirectory();\n })\n .catch((err) => {\n if (err.code === 'ENOENT') {\n return false;\n }\n throw err;\n });\n}\n\nexport function fileExists(filePath: string): Promise<boolean> {\n return fs\n .access(filePath)\n .then(() => true)\n .catch(() => false);\n}\n","export async function start(rootDir?: string) {\n console.log('SSR production server is coming soon');\n}\n"],"mappings":";AAAA;AACA;AACA;AACA;;;ACHA;AACA;AAGA,IAAM,iBAAiB;AAOhB,oBAAoB,SAA6B;AACtD,QAAM,UAAU,oCAAS,YAAW,QAAQ,IAAI;AAChD,MAAI;AACJ,MAAI;AACJ,MAAI;AAEJ,oCAAkC;AAChC,iBAAa,CAAC;AACd,UAAM,QAAQ,MAAM,KAAK,mBAAmB,EAAC,KAAK,QAAO,CAAC;AAC1D,UAAM,QAAQ,CAAC,SAAS;AACtB,YAAM,QAAQ,KAAK,MAAM,IAAI;AAC7B,UAAI,SAAS,MAAM,IAAI,GAAG;AACxB,mBAAW,MAAM,QAAQ,GAAG,WAAW;AAAA,MACzC;AAAA,IACF,CAAC;AAAA,EACH;AAEA,kCAAgC,SAAyC;AACvE,QAAI,CAAC,YAAY;AACf,YAAM,iBAAiB;AAAA,IACzB;AACA,QAAI,WAAW,YAAY;AACzB,YAAM,WAAW,WAAW;AAC5B,UAAI,UAAU,OAAO,aAAa;AAChC,cAAM,YAAY,OAAO,YAAY,iBAAiB,QAAQ;AAC9D,YAAI,aAAa,UAAU,OAAO,GAAG;AACnC,gBAAM,SAAS,UAAU,OAAO,EAAE,KAAK,EAAE;AACzC,iBAAO,OAAO;AAAA,QAChB;AAAA,MACF;AAAA,IACF;AACA,WAAO;AAAA,EACT;AAEA,SAAO;AAAA,IACL,MAAM;AAAA,IAIN,eAAe,gBAAqB;AAClC,eAAS;AAAA,IACX;AAAA,IAEA,gBAAgB,SAAwB;AACtC,eAAS;AAAA,IACX;AAAA,IAEA,MAAM,UAAU,KAAa,IAA0B;AACrD,UAAI,GAAG,SAAS,YAAY,KAAK,SAAS,EAAE,GAAG;AAC7C,cAAM,UAAU,KAAK,MAAM,EAAE;AAC7B,cAAM,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AM,UAAU,SAAS,IAAI;AAE7B,UAAM,UAAU,QAAQ,MAAM,MAAK,QAAQ,OAAO,EAAE,SAAS,CAAC;AAC9D,YAAQ,IAAI,SAAS,SAAS;AAAA,EAChC,CAAC,CACH;AACF;;;AG1LA,qBAA4B,SAAkB;AAC5C,UAAQ,IAAI,sCAAsC;AACpD;","names":[]}
1
+ {"version":3,"sources":["../src/cli/commands/dev.ts","../src/render/vite-plugin-root.ts","../src/render/asset-map/dev-asset-map.ts","../src/cli/load-config.ts","../src/render/html-minify.ts","../src/core/fsutils.ts","../src/cli/commands/build.ts","../src/render/asset-map/build-asset-map.ts","../src/cli/commands/start.ts"],"sourcesContent":["import path from 'node:path';\nimport {fileURLToPath} from 'node:url';\nimport {default as express, Request, Response, NextFunction} from 'express';\nimport {createServer as createViteServer} from 'vite';\nimport pluginRoot from '../../render/vite-plugin-root.js';\nimport {DevServerAssetMap} from '../../render/asset-map/dev-asset-map.js';\nimport {loadRootConfig} from '../load-config.js';\nimport {htmlMinify} from '../../render/html-minify.js';\nimport {Renderer} from '../../render/render.js';\nimport {isDirectory, isJsFile} from '../../core/fsutils.js';\nimport glob from 'tiny-glob';\n\nconst __dirname = path.dirname(fileURLToPath(import.meta.url));\n\nexport async function createServer(options?: {rootDir?: string}) {\n const app = express();\n\n app.use(express.static('public'));\n const middlewares = await getMiddlewares({rootDir: options?.rootDir});\n middlewares.forEach((middleware) => app.use(middleware));\n\n const port = parseInt(process.env.PORT || '4007');\n console.log('🌳 Root.js');\n console.log();\n console.log(`Started server: http://localhost:${port}`);\n app.listen(port);\n}\n\nexport async function getMiddlewares(options?: {rootDir?: string}) {\n const rootDir = options?.rootDir || process.cwd();\n const rootConfig = await loadRootConfig(rootDir);\n const viteConfig = rootConfig.vite || {};\n const renderModulePath = path.resolve(__dirname, './render.js');\n\n const pages: string[] = [];\n if (await isDirectory(path.join(rootDir, 'routes'))) {\n const pageFiles = await glob(path.join(rootDir, 'routes/**/*'));\n pageFiles.forEach((file) => {\n const parts = path.parse(file);\n if (!parts.name.startsWith('_') && isJsFile(parts.base)) {\n pages.push(file);\n }\n });\n }\n\n const elements: string[] = [];\n if (await isDirectory(path.join(rootDir, 'elements'))) {\n const elementFiles = await glob(path.join(rootDir, 'elements/**/*'));\n elementFiles.forEach((file) => {\n const parts = path.parse(file);\n if (isJsFile(parts.base)) {\n elements.push(file);\n }\n });\n }\n\n const bundleScripts: string[] = [];\n if (await isDirectory(path.join(rootDir, 'bundles'))) {\n const bundleFiles = await glob(path.join(rootDir, 'bundles/*'));\n bundleFiles.forEach((file) => {\n const parts = path.parse(file);\n if (isJsFile(parts.base)) {\n bundleScripts.push(file);\n }\n });\n }\n\n const viteServer = await createViteServer({\n ...viteConfig,\n server: {middlewareMode: true},\n appType: 'custom',\n optimizeDeps: {\n include: [...pages, ...elements, ...bundleScripts],\n },\n ssr: {\n noExternal: ['@blinkk/root'],\n },\n esbuild: {\n jsx: 'automatic',\n jsxImportSource: 'preact',\n },\n plugins: [...(viteConfig.plugins || []), pluginRoot()],\n });\n\n const rootMiddleware = async (\n req: Request,\n res: Response,\n next: NextFunction\n ) => {\n const url = req.originalUrl;\n const render = await viteServer.ssrLoadModule(renderModulePath);\n const renderer = new render.Renderer(rootConfig) as Renderer;\n try {\n // Create a dev asset map using Vite dev server's module graph.\n const assetMap = new DevServerAssetMap(viteServer.moduleGraph);\n const data = await renderer.render(url, {\n assetMap: assetMap,\n });\n // Inject the Vite HMR client.\n const html = await htmlMinify(\n await viteServer.transformIndexHtml(url, data.html || '')\n );\n\n res.status(200).set({'Content-Type': 'text/html'}).end(html);\n } catch (e) {\n // If an error is caught, let Vite fix the stack trace so it maps back to\n // your actual source code.\n viteServer.ssrFixStacktrace(e);\n try {\n const {html} = await renderer.renderError(e);\n res.status(500).set({'Content-Type': 'text/html'}).end(html);\n } catch (e2) {\n console.error('failed to render custom error');\n console.error(e2);\n next(e);\n }\n }\n };\n\n return [viteServer.middlewares, rootMiddleware];\n}\n\nexport function dev(rootDir?: string) {\n createServer({rootDir});\n}\n","import path from 'path';\nimport glob from 'tiny-glob';\nimport {ViteDevServer} from 'vite';\n\nconst ELEMENTS_REGEX = /h\\(\"(\\w[\\w-]+\\w)\"/g;\n\nexport interface RootPluginOptions {\n // Project directory.\n rootDir?: string;\n}\n\nexport function pluginRoot(options?: RootPluginOptions) {\n const rootDir = options?.rootDir || process.cwd();\n let config: any;\n let server: ViteDevServer;\n let elementMap: Record<string, string>;\n\n async function updateElementMap() {\n elementMap = {};\n const files = await glob('./elements/**/*', {cwd: rootDir});\n files.forEach((file) => {\n const parts = path.parse(file);\n if (isJsFile(parts.base)) {\n elementMap[parts.name] = `${rootDir}/${file}`;\n }\n });\n }\n\n async function getElementImport(tagName: string): Promise<string | null> {\n if (!elementMap) {\n await updateElementMap();\n }\n if (tagName in elementMap) {\n const filePath = elementMap[tagName];\n if (server && server.moduleGraph) {\n const moduleSet = server.moduleGraph.getModulesByFile(filePath);\n if (moduleSet && moduleSet.size > 0) {\n const module = moduleSet.values().next().value;\n return module.url;\n }\n }\n }\n return null;\n }\n\n return {\n name: 'vite-plugin-root',\n\n // TODO(stevenle): when the config is resolved, store a list of places to\n // find custom elements.\n configResolved(resolvedConfig: any) {\n config = resolvedConfig;\n },\n\n configureServer(_server: ViteDevServer) {\n server = _server;\n },\n\n async transform(src: string, id: string): Promise<any> {\n if (id.includes('/elements/') && isJsFile(id)) {\n const idParts = path.parse(id);\n const deps = new Set<string>();\n const elementsRe = ELEMENTS_REGEX;\n for (const match of src.matchAll(elementsRe)) {\n const tagName = match[1];\n // All custom elements should contain a dash.\n if (!tagName.includes('-')) {\n continue;\n }\n // Avoid circular deps.\n if (tagName === idParts.name) {\n continue;\n }\n deps.add(tagName);\n }\n const importUrls: string[] = [];\n await Promise.all(\n Array.from(deps).map(async (tagName) => {\n const importUrl = await getElementImport(tagName);\n if (importUrl) {\n importUrls.push(importUrl);\n }\n })\n );\n if (importUrls.length > 0) {\n const importLines = importUrls\n .map((url) => `import '${url}';`)\n .join('\\n');\n const code = `${src}\n\n// autogenerated by root:\n${importLines}\n`;\n return {code};\n }\n return null;\n }\n },\n };\n}\n\nfunction isJsFile(file: string): boolean {\n return !!file.match(/\\.(j|t)sx?$/);\n}\n\nexport default pluginRoot;\n","import path from 'node:path';\nimport {ModuleGraph, ModuleNode} from 'vite';\nimport {Asset, AssetMap} from './asset-map';\n\nexport class DevServerAssetMap implements AssetMap {\n private moduleGraph: ModuleGraph;\n\n constructor(moduleGraph: ModuleGraph) {\n this.moduleGraph = moduleGraph;\n }\n\n async get(moduleId: string): Promise<Asset | null> {\n const viteModule = await this.moduleGraph.getModuleByUrl(moduleId);\n if (!viteModule || !viteModule.id) {\n return null;\n }\n return new DevServerAsset(this, viteModule);\n }\n}\n\nexport class DevServerAsset implements Asset {\n moduleId: string;\n assetUrl: string;\n private assetMap: AssetMap;\n private viteModule: ModuleNode;\n\n constructor(assetMap: AssetMap, viteModule: ModuleNode) {\n this.assetMap = assetMap;\n this.viteModule = viteModule;\n this.moduleId = this.viteModule.id!;\n this.assetUrl = this.viteModule.url;\n }\n\n async getCssDeps(): Promise<string[]> {\n const visited = new Set<string>();\n const deps = new Set<string>();\n this.collectCss(this, deps, visited);\n return Array.from(deps);\n }\n\n async getJsDeps(): Promise<string[]> {\n const visited = new Set<string>();\n const deps = new Set<string>();\n this.collectJs(this, deps, visited);\n return Array.from(deps);\n }\n\n getImportedModules() {\n return this.viteModule.importedModules;\n }\n\n private collectJs(\n asset: DevServerAsset | null,\n urls: Set<string>,\n visited: Set<string>\n ) {\n if (!asset) {\n return;\n }\n if (!asset.moduleId) {\n return;\n }\n if (visited.has(asset.moduleId)) {\n return;\n }\n visited.add(asset.moduleId);\n const parts = path.parse(asset.assetUrl);\n if (\n ['.js', '.jsx', '.ts', '.tsx'].includes(parts.ext) &&\n asset.moduleId.includes('/elements/')\n ) {\n urls.add(asset.assetUrl);\n }\n asset.getImportedModules().forEach((viteModule) => {\n if (viteModule.id) {\n const importedAsset = new DevServerAsset(this.assetMap, viteModule);\n this.collectJs(importedAsset, urls, visited);\n }\n });\n }\n\n private collectCss(\n asset: DevServerAsset | null,\n urls: Set<string>,\n visited: Set<string>\n ) {\n if (!asset) {\n return;\n }\n if (!asset.assetUrl) {\n return;\n }\n if (visited.has(asset.assetUrl)) {\n return;\n }\n visited.add(asset.assetUrl);\n if (asset.moduleId.endsWith('.scss')) {\n const parts = path.parse(asset.assetUrl);\n if (!parts.name.startsWith('_')) {\n urls.add(asset.assetUrl);\n }\n }\n asset.getImportedModules().forEach((viteModule) => {\n if (viteModule.id) {\n const importedAsset = new DevServerAsset(this.assetMap, viteModule);\n this.collectCss(importedAsset, urls, visited);\n }\n });\n }\n}\n","import {bundleRequire} from 'bundle-require';\nimport JoyCon from 'joycon';\nimport {RootConfig} from '../core/config';\n\nexport async function loadRootConfig(rootDir: string): Promise<RootConfig> {\n const joycon = new JoyCon();\n const configPath = await joycon.resolve({\n cwd: rootDir,\n files: ['root.config.ts'],\n });\n if (configPath) {\n const configBundle = await bundleRequire({\n filepath: configPath,\n });\n return configBundle.mod.default || {};\n }\n return {};\n}\n","import {minify} from 'html-minifier-terser';\n\nexport async function htmlMinify(html: string): Promise<string> {\n const min = await minify(html, {\n collapseWhitespace: true,\n removeComments: true,\n preserveLineBreaks: true,\n });\n return min.trimStart();\n}\n","import {promises as fs} from 'node:fs';\nimport path from 'node:path';\nimport fsExtra from 'fs-extra';\n\nexport function isJsFile(file: string) {\n return !!file.match(/\\.(j|t)sx?$/);\n}\n\nexport async function writeFile(filePath: string, content: string) {\n const dirPath = path.dirname(filePath);\n await makeDir(dirPath);\n await fs.writeFile(filePath, content);\n}\n\nexport async function makeDir(dirPath: string) {\n try {\n await fs.access(dirPath);\n } catch (e) {\n await fs.mkdir(dirPath, {recursive: true});\n }\n}\n\nexport async function copyDir(srcDir: string, dstDir: string) {\n if (!fsExtra.existsSync(srcDir)) {\n return;\n }\n fsExtra.copySync(srcDir, dstDir, {recursive: true, overwrite: true});\n}\n\nexport async function rmDir(dirPath: string) {\n await fs.rm(dirPath, {recursive: true, force: true});\n}\n\nexport async function loadJson(filePath: string): Promise<any> {\n const content = await fs.readFile(filePath, 'utf-8');\n return JSON.parse(content);\n}\n\nexport async function isDirectory(dirPath: string) {\n return fs\n .stat(dirPath)\n .then((fsStat) => {\n return fsStat.isDirectory();\n })\n .catch((err) => {\n if (err.code === 'ENOENT') {\n return false;\n }\n throw err;\n });\n}\n\nexport function fileExists(filePath: string): Promise<boolean> {\n return fs\n .access(filePath)\n .then(() => true)\n .catch(() => false);\n}\n","import path from 'node:path';\nimport {fileURLToPath} from 'node:url';\nimport fsExtra from 'fs-extra';\nimport glob from 'tiny-glob';\nimport {build as viteBuild} from 'vite';\nimport {pluginRoot} from '../../render/vite-plugin-root.js';\nimport {BuildAssetMap} from '../../render/asset-map/build-asset-map.js';\nimport {loadRootConfig} from '../load-config.js';\nimport {\n copyDir,\n isDirectory,\n isJsFile,\n loadJson,\n makeDir,\n rmDir,\n writeFile,\n} from '../../core/fsutils.js';\nimport {Renderer} from '../../render/render.js';\nimport {htmlMinify} from '../../render/html-minify.js';\n\nconst __dirname = path.dirname(fileURLToPath(import.meta.url));\n\nexport async function build(rootDir?: string) {\n console.log('🌳 Root.js');\n\n if (!rootDir) {\n rootDir = process.cwd();\n }\n const rootConfig = await loadRootConfig(rootDir);\n const distDir = path.join(rootDir, 'dist');\n await rmDir(distDir);\n await makeDir(distDir);\n\n const pages: string[] = [];\n if (await isDirectory(path.join(rootDir, 'routes'))) {\n const pageFiles = await glob(path.join(rootDir, 'routes/**/*'));\n pageFiles.forEach((file) => {\n const parts = path.parse(file);\n if (!parts.name.startsWith('_') && isJsFile(parts.base)) {\n pages.push(file);\n }\n });\n }\n\n const elements: string[] = [];\n if (await isDirectory(path.join(rootDir, 'elements'))) {\n const elementFiles = await glob(path.join(rootDir, 'elements/**/*'));\n elementFiles.forEach((file) => {\n const parts = path.parse(file);\n if (isJsFile(parts.base)) {\n elements.push(file);\n }\n });\n }\n\n const bundleScripts: string[] = [];\n if (await isDirectory(path.join(rootDir, 'bundles'))) {\n const bundleFiles = await glob(path.join(rootDir, 'bundles/*'));\n bundleFiles.forEach((file) => {\n const parts = path.parse(file);\n if (isJsFile(parts.base)) {\n bundleScripts.push(file);\n }\n });\n }\n\n const viteConfig = rootConfig.vite || {};\n const baseConfig = {\n ...viteConfig,\n root: rootDir,\n esbuild: {\n jsxFactory: 'h',\n jsxFragment: 'Fragment',\n jsxInject: 'import {h, Fragment} from \"preact\";',\n },\n plugins: [...(viteConfig.plugins || []), pluginRoot()],\n };\n\n // Bundle the render.js file with vite, which is pre-optimized for rendering\n // HTML routes.\n await viteBuild({\n ...baseConfig,\n mode: 'production',\n publicDir: false,\n build: {\n rollupOptions: {\n input: [path.resolve(__dirname, './render.js')],\n output: {\n format: 'esm',\n chunkFileNames: 'chunks/[name].[hash].js',\n assetFileNames: 'assets/[name].[hash][extname]',\n },\n },\n outDir: path.join(distDir, 'server'),\n ssr: true,\n ssrManifest: false,\n cssCodeSplit: true,\n target: 'esnext',\n minify: false,\n polyfillModulePreload: false,\n reportCompressedSize: false,\n },\n ssr: {\n noExternal: ['@blinkk/root'],\n },\n });\n\n // Pre-render any client scripts and CSS deps.\n await viteBuild({\n ...baseConfig,\n mode: 'production',\n publicDir: false,\n build: {\n rollupOptions: {\n input: [...pages, ...elements, ...bundleScripts],\n output: {\n format: 'esm',\n chunkFileNames: 'chunks/[name].[hash].js',\n assetFileNames: 'assets/[name].[hash][extname]',\n },\n },\n outDir: path.join(distDir, 'client'),\n ssr: false,\n ssrManifest: false,\n manifest: true,\n cssCodeSplit: true,\n target: 'esnext',\n minify: true,\n polyfillModulePreload: false,\n reportCompressedSize: false,\n },\n });\n\n const manifest = await loadJson(path.join(distDir, 'client/manifest.json'));\n\n // Use the output of the client build to generate an asset map, which is used\n // by the renderer for automatically injecting dependencies for a page.\n const assetMap = new BuildAssetMap(manifest);\n\n // Save the asset map to `dist/client` for use by the prod SSR server.\n writeFile(\n path.join(distDir, 'client/root-manifest.json'),\n JSON.stringify(assetMap.toJson(), null, 2)\n );\n\n // Write SSG output to `dist/html`.\n const buildDir = path.join(distDir, 'html');\n\n // Recursively copy files from `public` to `dist/html`.\n const publicDir = path.join(rootDir, 'public');\n if (fsExtra.existsSync(path.join(rootDir, 'public'))) {\n fsExtra.copySync(publicDir, buildDir);\n } else {\n makeDir(buildDir);\n }\n\n // Copy files from `dist/client/{assets,chunks}` to `dist/html`.\n copyDir(path.join(distDir, 'client/assets'), path.join(buildDir, 'assets'));\n copyDir(path.join(distDir, 'client/chunks'), path.join(buildDir, 'chunks'));\n\n // Render HTML pages.\n const render = await import(path.join(distDir, 'server/render.js'));\n const renderer = new render.Renderer(rootConfig) as Renderer;\n const sitemap = await renderer.getSitemap();\n\n await Promise.all(\n Object.keys(sitemap).map(async (urlPath) => {\n const {route, params} = sitemap[urlPath];\n const data = await renderer.renderRoute(route, {\n assetMap,\n routeParams: params,\n });\n\n // The renderer currently assumes that all paths serve HTML.\n // TODO(stevenle): support non-HTML routes using `routes/[name].[ext].ts`.\n let outPath = path.join(distDir, `html${urlPath}`, 'index.html');\n\n if (outPath.endsWith('404/index.html')) {\n outPath = outPath.replace('404/index.html', '404.html');\n }\n\n const html = await htmlMinify(data.html || '');\n await writeFile(outPath, html);\n\n const relPath = outPath.slice(path.dirname(distDir).length + 1);\n console.log(`saved ${relPath}`);\n })\n );\n}\n","import path from 'path';\nimport {Manifest, ManifestChunk} from 'vite';\nimport {Asset, AssetMap} from './asset-map';\n\nexport class BuildAssetMap implements AssetMap {\n private manifest: Manifest;\n private moduleIdToAsset: Map<string, BuildAsset>;\n\n constructor(manifest: Manifest) {\n this.manifest = manifest;\n this.moduleIdToAsset = new Map();\n Object.keys(this.manifest).forEach((manifestKey) => {\n const moduleId = `/${manifestKey}`;\n this.moduleIdToAsset.set(\n moduleId,\n new BuildAsset(this, moduleId, this.manifest[manifestKey])\n );\n });\n }\n\n async get(moduleId: string): Promise<Asset | null> {\n return this.moduleIdToAsset.get(moduleId) || null;\n }\n\n toJson(): any {\n const result: any = {};\n for (const moduleId of this.moduleIdToAsset.keys()) {\n result[moduleId] = this.moduleIdToAsset.get(moduleId)!.toJson();\n }\n return result;\n }\n}\n\nexport class BuildAsset {\n moduleId: string;\n assetUrl: string;\n private assetMap: BuildAssetMap;\n private manifestData: ManifestChunk;\n private importedModules: string[];\n private importedCss: string[];\n\n constructor(\n assetMap: BuildAssetMap,\n moduleId: string,\n manifestData: ManifestChunk\n ) {\n this.assetMap = assetMap;\n this.moduleId = moduleId;\n this.manifestData = manifestData;\n this.assetUrl = `/${manifestData.file}`;\n this.importedModules = (this.manifestData.imports || []).map(\n (relPath) => `/${relPath}`\n );\n this.importedCss = (this.manifestData.css || []).map(\n (relPath) => `/${relPath}`\n );\n }\n\n async getCssDeps(): Promise<string[]> {\n const visited = new Set<string>();\n const deps = new Set<string>();\n await this.collectCss(this, deps, visited);\n return Array.from(deps);\n }\n\n async getJsDeps(): Promise<string[]> {\n const visited = new Set<string>();\n const deps = new Set<string>();\n await this.collectJs(this, deps, visited);\n return Array.from(deps);\n }\n\n private async collectJs(\n asset: BuildAsset | null,\n urls: Set<string>,\n visited: Set<string>\n ) {\n if (!asset) {\n return;\n }\n if (!asset.moduleId) {\n return;\n }\n if (visited.has(asset.moduleId)) {\n return;\n }\n visited.add(asset.moduleId);\n const parts = path.parse(asset.assetUrl);\n if (\n ['.ts', '.tsx'].includes(parts.ext) &&\n asset.moduleId.includes('/elements/')\n ) {\n urls.add(asset.assetUrl);\n }\n await Promise.all(\n asset.importedModules.map(async (moduleId) => {\n const importedAsset = (await this.assetMap.get(moduleId)) as BuildAsset;\n this.collectJs(importedAsset, urls, visited);\n })\n );\n }\n\n private async collectCss(\n asset: BuildAsset | null,\n urls: Set<string>,\n visited: Set<string>\n ) {\n if (!asset) {\n return;\n }\n if (!asset.assetUrl) {\n return;\n }\n if (visited.has(asset.moduleId)) {\n return;\n }\n visited.add(asset.moduleId);\n if (asset.importedCss) {\n asset.importedCss.forEach((cssUrl) => urls.add(cssUrl));\n }\n await Promise.all(\n asset.importedModules.map(async (moduleId) => {\n const importedAsset = (await this.assetMap.get(moduleId)) as BuildAsset;\n this.collectCss(importedAsset, urls, visited);\n })\n );\n }\n\n toJson(): any {\n return {\n moduleId: this.moduleId,\n assetUrl: this.assetUrl,\n importedModules: this.importedModules,\n importedCss: this.importedCss,\n };\n }\n}\n","export async function start(rootDir?: string) {\n console.log('SSR production server is coming soon');\n}\n"],"mappings":";AAAA;AACA;AACA;AACA;;;ACHA;AACA;AAGA,IAAM,iBAAiB;AAOhB,oBAAoB,SAA6B;AACtD,QAAM,UAAU,oCAAS,YAAW,QAAQ,IAAI;AAChD,MAAI;AACJ,MAAI;AACJ,MAAI;AAEJ,oCAAkC;AAChC,iBAAa,CAAC;AACd,UAAM,QAAQ,MAAM,KAAK,mBAAmB,EAAC,KAAK,QAAO,CAAC;AAC1D,UAAM,QAAQ,CAAC,SAAS;AACtB,YAAM,QAAQ,KAAK,MAAM,IAAI;AAC7B,UAAI,SAAS,MAAM,IAAI,GAAG;AACxB,mBAAW,MAAM,QAAQ,GAAG,WAAW;AAAA,MACzC;AAAA,IACF,CAAC;AAAA,EACH;AAEA,kCAAgC,SAAyC;AACvE,QAAI,CAAC,YAAY;AACf,YAAM,iBAAiB;AAAA,IACzB;AACA,QAAI,WAAW,YAAY;AACzB,YAAM,WAAW,WAAW;AAC5B,UAAI,UAAU,OAAO,aAAa;AAChC,cAAM,YAAY,OAAO,YAAY,iBAAiB,QAAQ;AAC9D,YAAI,aAAa,UAAU,OAAO,GAAG;AACnC,gBAAM,SAAS,UAAU,OAAO,EAAE,KAAK,EAAE;AACzC,iBAAO,OAAO;AAAA,QAChB;AAAA,MACF;AAAA,IACF;AACA,WAAO;AAAA,EACT;AAEA,SAAO;AAAA,IACL,MAAM;AAAA,IAIN,eAAe,gBAAqB;AAClC,eAAS;AAAA,IACX;AAAA,IAEA,gBA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