katabatic 1.0.1 → 1.1.0

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 (2) hide show
  1. package/package.json +3 -2
  2. package/src/index.js +6 -2
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "katabatic",
3
3
  "license": "MIT",
4
- "version": "1.0.1",
4
+ "version": "1.1.0",
5
5
  "type": "module",
6
6
  "repository": {
7
7
  "type": "git",
@@ -20,7 +20,8 @@
20
20
  "node": ">=20.0.0"
21
21
  },
22
22
  "dependencies": {
23
- "@katabatic/compiler": "^1.0.0",
23
+ "@katabatic/compiler": "^1.1.0",
24
+ "@katabatic/dev-server-hmr": "^1.0.0",
24
25
  "@web/dev-server": "^0.4.6"
25
26
  }
26
27
  }
package/src/index.js CHANGED
@@ -3,6 +3,7 @@ import path from 'path'
3
3
  import { watch as watchDir, existsSync } from 'fs'
4
4
  import { parseArgs } from 'node:util'
5
5
  import { startDevServer } from '@web/dev-server'
6
+ import { hmrPlugin } from '@katabatic/dev-server-hmr'
6
7
  import { walkDir } from './utils/files.js'
7
8
  import { hash } from './utils/misc.js'
8
9
  import { printHelp, withHelp } from './utils/help.js'
@@ -21,6 +22,7 @@ const options = {
21
22
  help: { type: 'boolean', short: 'h', description: 'get help' },
22
23
  watch: { type: 'boolean', short: 'w', description: 'watches the file system' },
23
24
  serve: { type: 'boolean', short: 's', description: 'starts the development server' },
25
+ hot: { type: 'boolean', description: 'generate code to support hot module replacement' },
24
26
  rewriteRelativeImportExtensions: {
25
27
  type: 'boolean',
26
28
  description: 'rewrite imported katabatic files extension (.html or .ktb) in .js'
@@ -35,6 +37,7 @@ const outDirPath = path.join(rootPath, args.outDir ?? '.')
35
37
  const routesDirPath = path.join(srcDirPath, args.routesDir ?? './routes')
36
38
  const hasRoutes = existsSync(routesDirPath)
37
39
 
40
+ const hot = (args.hot || args.serve) ?? false
38
41
  const rewriteRelativeImportExtensions = args.rewriteRelativeImportExtensions ?? false
39
42
 
40
43
  if (args.help) {
@@ -93,7 +96,7 @@ function watch(registry) {
93
96
  }
94
97
 
95
98
  function serve() {
96
- const plugins = []
99
+ const plugins = [hmrPlugin()]
97
100
 
98
101
  if (hasRoutes) {
99
102
  plugins.push(route(outDirPath))
@@ -104,7 +107,7 @@ function serve() {
104
107
  rootDir: rootPath,
105
108
  port: 3000,
106
109
  watch: true,
107
- open: true,
110
+ open: false,
108
111
  nodeResolve: true,
109
112
  plugins
110
113
  },
@@ -143,6 +146,7 @@ function resolve(srcFilePath, isModule) {
143
146
  isLayout,
144
147
  routerImport,
145
148
  hash: moduleHash,
149
+ hot,
146
150
  rewriteRelativeImportExtensions,
147
151
  src: {
148
152
  filePath: srcFilePath