anu-verzum 1.12.0 → 1.13.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/README.md +107 -19
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -17,26 +17,85 @@ npm install anu-verzum
17
17
 
18
18
  <h3>Babel setup</h3>
19
19
 
20
- The package ships with a Babel preset that configures both JSX and TypeScript for you.
21
- Add it to your project's <code>babel.config.json</code>:
20
+ Create a `babel.config.json` in your project root:
22
21
 
23
22
  ```json
24
23
  {
25
- "presets": ["anu-verzum/babel-preset"]
24
+ "presets": [
25
+ "anu-verzum/babel-preset",
26
+ ["@babel/preset-env", { "targets": "last 2 Chrome versions" }]
27
+ ]
26
28
  }
27
29
  ```
28
30
 
29
- This preset does two things automatically:
31
+ `anu-verzum/babel-preset` handles two things automatically:
30
32
 
31
- - Transforms JSX to <code>Anu.createElement()</code> calls, including the <code>&lt;&gt;...&lt;/&gt;</code> fragment shorthand (mapped to <code>Anu.Fragment</code>).
32
- - Strips TypeScript types via <code>@babel/plugin-transform-typescript</code> with <code>jsxPragma: 'Anu'</code> pre-configured, so the <code>Anu</code> import is never incorrectly elided — even in files that use only host elements like <code>&lt;div&gt;</code> or <code>&lt;span&gt;</code>.
33
+ - Transforms JSX to `Anu.createElement()` calls, including the `<>...</>` fragment shorthand (mapped to `Anu.Fragment`).
34
+ - Strips TypeScript syntax via `@babel/plugin-transform-typescript` with `jsxPragma: 'Anu'` pre-configured, so the `Anu` import is never incorrectly elided — even in files that only use host elements like `<div>` or `<span>`.
33
35
 
34
- Because the preset handles TypeScript stripping itself, **do not** add <code>@babel/preset-typescript</code> separately — running both would transform TypeScript twice and cause errors.
36
+ Because the preset handles TypeScript stripping itself, **do not** add `@babel/preset-typescript` separately — running both would transform TypeScript twice and cause errors.
37
+
38
+ <h3>Webpack setup</h3>
39
+
40
+ Install the required build dependencies:
41
+
42
+ ```bash
43
+ npm install --save-dev webpack webpack-cli webpack-dev-server html-webpack-plugin babel-loader @babel/core @babel/preset-env
44
+ ```
45
+
46
+ Create (or update) `webpack.config.js`:
47
+
48
+ ```js
49
+ const path = require('path');
50
+ const HtmlWebpackPlugin = require('html-webpack-plugin');
51
+
52
+ module.exports = {
53
+ mode: 'development',
54
+ entry: './src/index.tsx', // use index.js for JavaScript-only projects
55
+ output: {
56
+ path: path.resolve(__dirname, 'dist'),
57
+ filename: 'bundle.js',
58
+ publicPath: '/'
59
+ },
60
+ module: {
61
+ rules: [
62
+ {
63
+ test: /\.[jt]sx?$/, // use /\.jsx?$/ for JavaScript-only projects
64
+ exclude: /node_modules/,
65
+ use: 'babel-loader'
66
+ }
67
+ ]
68
+ },
69
+ resolve: {
70
+ extensions: ['.js', '.jsx', '.tsx', '.ts']
71
+ },
72
+ plugins: [
73
+ new HtmlWebpackPlugin({ template: './index.html' })
74
+ ],
75
+ devServer: {
76
+ port: 3000,
77
+ historyApiFallback: true,
78
+ open: true
79
+ }
80
+ };
81
+ ```
82
+
83
+ Add scripts to `package.json`:
84
+
85
+ ```json
86
+ {
87
+ "scripts": {
88
+ "start": "webpack serve",
89
+ "build": "webpack --mode production"
90
+ }
91
+ }
92
+ ```
35
93
 
36
94
  <h3>Importing in your files</h3>
37
95
 
38
- Every file that contains JSX must import <code>Anu</code>, because the JSX transform
39
- expands to <code>Anu.createElement(...)</code> calls at compile time:
96
+ Every file that contains JSX should import `Anu`, because the JSX transform expands to
97
+ `Anu.createElement(...)` calls at compile time. The preset keeps this import in scope
98
+ automatically, but it is still required at runtime:
40
99
 
41
100
  ```javascript
42
101
  import Anu from 'anu-verzum';
@@ -50,26 +109,55 @@ Anu.render(<App />, document.getElementById('root'));
50
109
 
51
110
  <h3>TypeScript setup</h3>
52
111
 
53
- The library is written in TypeScript and ships with declaration files (`.d.ts`) out of the box —
54
- no extra `@types` package is needed. The `dist/` directory contains only compiled `.js` files and
55
- `.d.ts` declarations, so the package works correctly under all standard TypeScript `moduleResolution`
56
- modes including `"node"`, `"node16"`, and `"bundler"`.
112
+ The library ships with declaration files (`.d.ts`) out of the box — no `@types` package is needed.
113
+
114
+ Install TypeScript for type checking:
115
+
116
+ ```bash
117
+ npm install --save-dev typescript
118
+ ```
119
+
120
+ > **Note:** `@babel/preset-typescript` is **not** needed — `anu-verzum/babel-preset` already handles TypeScript stripping. Only install `typescript` to get the `tsc` CLI for type checking.
57
121
 
58
- If your project uses TypeScript, add the following to your `tsconfig.json` so the compiler
59
- understands JSX produced by ANUVerzum:
122
+ Create `tsconfig.json`:
60
123
 
61
124
  ```json
62
125
  {
63
126
  "compilerOptions": {
127
+ "target": "ES2017",
128
+ "module": "ESNext",
129
+ "moduleResolution": "bundler",
64
130
  "jsx": "react",
65
131
  "jsxFactory": "Anu.createElement",
66
- "jsxFragmentFactory": "Anu.Fragment"
67
- }
132
+ "jsxFragmentFactory": "Anu.Fragment",
133
+ "strict": true,
134
+ "noEmit": true,
135
+ "skipLibCheck": true,
136
+ "esModuleInterop": true
137
+ },
138
+ "include": ["src"]
68
139
  }
69
140
  ```
70
141
 
71
- Every JSX file must still import `Anu` so that `Anu.createElement` is in scope at runtime (same
72
- as the plain JavaScript case).
142
+ | Option | Value | Reason |
143
+ |--------|-------|--------|
144
+ | `jsx` | `"react"` | Enables JSX type-checking with a custom factory |
145
+ | `jsxFactory` | `"Anu.createElement"` | Matches ANUVerzum's JSX transform |
146
+ | `jsxFragmentFactory` | `"Anu.Fragment"` | Matches ANUVerzum's fragment syntax |
147
+ | `noEmit` | `true` | Type checking only — Babel handles compilation |
148
+ | `skipLibCheck` | `true` | Skips type checking inside `node_modules` |
149
+ | `moduleResolution` | `"bundler"` | Correct setting for Webpack/Babel projects |
150
+
151
+ #### Build pipeline
152
+
153
+ Compilation and type checking are intentionally separate:
154
+
155
+ ```bash
156
+ npm start # dev server — Babel compiles, always succeeds
157
+ npx tsc --noEmit # type check only — surfaces type errors
158
+ ```
159
+
160
+ Because compilation goes through Babel, `npm start` and `npm run build` succeed regardless of type errors. Run `npx tsc --noEmit` during development to catch type issues without blocking the build.
73
161
 
74
162
  #### Typed class components
75
163
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "anu-verzum",
3
- "version": "1.12.0",
3
+ "version": "1.13.0",
4
4
  "description": "A \"React-like\" UI library that supports JSX syntax, Redux-like state management, array-rendering, i18n, routing and many more.",
5
5
  "keywords": [
6
6
  "anu-verzum",