what-compiler 0.5.3 → 0.5.4

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/README.md +102 -0
  2. package/package.json +2 -2
package/README.md ADDED
@@ -0,0 +1,102 @@
1
+ # what-compiler
2
+
3
+ JSX compiler for [What Framework](https://whatfw.com). Transforms JSX into optimized DOM operations via a Babel plugin, with a Vite plugin for seamless integration. Also provides file-based routing via `virtual:what-routes`.
4
+
5
+ ## Install
6
+
7
+ ```bash
8
+ npm install what-compiler --save-dev
9
+ ```
10
+
11
+ ## Vite Plugin
12
+
13
+ The recommended way to use the compiler. Add it to your Vite config:
14
+
15
+ ```js
16
+ // vite.config.js
17
+ import { defineConfig } from 'vite';
18
+ import what from 'what-compiler/vite';
19
+
20
+ export default defineConfig({
21
+ plugins: [what()],
22
+ });
23
+ ```
24
+
25
+ ### Options
26
+
27
+ ```js
28
+ what({
29
+ include: /\.[jt]sx$/, // File extensions to process (default: .jsx/.tsx)
30
+ exclude: /node_modules/, // Files to exclude (default: node_modules)
31
+ sourceMaps: true, // Enable source maps (default: true)
32
+ production: false, // Enable production optimizations (default: auto)
33
+ pages: 'src/pages', // Pages directory for file-based routing
34
+ })
35
+ ```
36
+
37
+ ## Babel Plugin
38
+
39
+ Use the Babel plugin directly for custom build setups:
40
+
41
+ ```js
42
+ // babel.config.js
43
+ export default {
44
+ plugins: [
45
+ ['what-compiler/babel', { production: false }],
46
+ ],
47
+ };
48
+ ```
49
+
50
+ ## File-Based Routing
51
+
52
+ The compiler scans a pages directory and generates a virtual routes module.
53
+
54
+ ```
55
+ src/pages/
56
+ index.jsx -> /
57
+ about.jsx -> /about
58
+ blog/
59
+ index.jsx -> /blog
60
+ [slug].jsx -> /blog/:slug
61
+ [...all].jsx -> /*
62
+ ```
63
+
64
+ Import the generated routes in your app:
65
+
66
+ ```jsx
67
+ import { routes } from 'virtual:what-routes';
68
+ import { FileRouter } from 'what-router';
69
+ import { mount } from 'what-framework';
70
+
71
+ mount(<FileRouter routes={routes} />, '#app');
72
+ ```
73
+
74
+ ## Sub-path Exports
75
+
76
+ | Path | Contents |
77
+ |---|---|
78
+ | `what-compiler` | All exports |
79
+ | `what-compiler/vite` | Vite plugin |
80
+ | `what-compiler/babel` | Babel plugin |
81
+ | `what-compiler/runtime` | Compiler runtime helpers |
82
+ | `what-compiler/file-router` | `scanPages`, `extractPageConfig`, `generateRoutesModule` |
83
+
84
+ ## API
85
+
86
+ | Export | Description |
87
+ |---|---|
88
+ | `vitePlugin(options?)` | Vite plugin for JSX transform and file routing |
89
+ | `what(options?)` | Named alias for the Vite plugin |
90
+ | `babelPlugin` | Babel plugin for JSX transformation |
91
+ | `scanPages(dir)` | Scan a directory for page files |
92
+ | `extractPageConfig(file)` | Extract page configuration from a file |
93
+ | `generateRoutesModule(pagesDir, rootDir)` | Generate a routes module string |
94
+
95
+ ## Links
96
+
97
+ - [Documentation](https://whatfw.com)
98
+ - [GitHub](https://github.com/zvndev/what-fw)
99
+
100
+ ## License
101
+
102
+ MIT
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "what-compiler",
3
- "version": "0.5.3",
3
+ "version": "0.5.4",
4
4
  "description": "JSX compiler for What Framework - transforms JSX to optimized DOM operations",
5
5
  "main": "src/index.js",
6
6
  "type": "module",
@@ -39,5 +39,5 @@
39
39
  "bugs": {
40
40
  "url": "https://github.com/zvndev/what-fw/issues"
41
41
  },
42
- "homepage": "https://whatframework.dev"
42
+ "homepage": "https://whatfw.com"
43
43
  }