anu-verzum 1.11.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.
- package/README.md +109 -17
- package/babel-preset.js +7 -0
- package/package.json +3 -2
package/README.md
CHANGED
|
@@ -17,22 +17,85 @@ npm install anu-verzum
|
|
|
17
17
|
|
|
18
18
|
<h3>Babel setup</h3>
|
|
19
19
|
|
|
20
|
-
|
|
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": [
|
|
24
|
+
"presets": [
|
|
25
|
+
"anu-verzum/babel-preset",
|
|
26
|
+
["@babel/preset-env", { "targets": "last 2 Chrome versions" }]
|
|
27
|
+
]
|
|
26
28
|
}
|
|
27
29
|
```
|
|
28
30
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
+
`anu-verzum/babel-preset` handles two things automatically:
|
|
32
|
+
|
|
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>`.
|
|
35
|
+
|
|
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
|
+
```
|
|
31
93
|
|
|
32
94
|
<h3>Importing in your files</h3>
|
|
33
95
|
|
|
34
|
-
Every file that contains JSX
|
|
35
|
-
|
|
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:
|
|
36
99
|
|
|
37
100
|
```javascript
|
|
38
101
|
import Anu from 'anu-verzum';
|
|
@@ -46,26 +109,55 @@ Anu.render(<App />, document.getElementById('root'));
|
|
|
46
109
|
|
|
47
110
|
<h3>TypeScript setup</h3>
|
|
48
111
|
|
|
49
|
-
The library
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
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.
|
|
53
121
|
|
|
54
|
-
|
|
55
|
-
understands JSX produced by ANUVerzum:
|
|
122
|
+
Create `tsconfig.json`:
|
|
56
123
|
|
|
57
124
|
```json
|
|
58
125
|
{
|
|
59
126
|
"compilerOptions": {
|
|
127
|
+
"target": "ES2017",
|
|
128
|
+
"module": "ESNext",
|
|
129
|
+
"moduleResolution": "bundler",
|
|
60
130
|
"jsx": "react",
|
|
61
131
|
"jsxFactory": "Anu.createElement",
|
|
62
|
-
"jsxFragmentFactory": "Anu.Fragment"
|
|
63
|
-
|
|
132
|
+
"jsxFragmentFactory": "Anu.Fragment",
|
|
133
|
+
"strict": true,
|
|
134
|
+
"noEmit": true,
|
|
135
|
+
"skipLibCheck": true,
|
|
136
|
+
"esModuleInterop": true
|
|
137
|
+
},
|
|
138
|
+
"include": ["src"]
|
|
64
139
|
}
|
|
65
140
|
```
|
|
66
141
|
|
|
67
|
-
|
|
68
|
-
|
|
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.
|
|
69
161
|
|
|
70
162
|
#### Typed class components
|
|
71
163
|
|
package/babel-preset.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "anu-verzum",
|
|
3
|
-
"version": "1.
|
|
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",
|
|
@@ -38,7 +38,8 @@
|
|
|
38
38
|
"test": "echo \"Error: no test specified\" && exit 1"
|
|
39
39
|
},
|
|
40
40
|
"dependencies": {
|
|
41
|
-
"@babel/plugin-transform-react-jsx": "^7.21.0"
|
|
41
|
+
"@babel/plugin-transform-react-jsx": "^7.21.0",
|
|
42
|
+
"@babel/plugin-transform-typescript": "^7.28.6"
|
|
42
43
|
},
|
|
43
44
|
"devDependencies": {
|
|
44
45
|
"@babel/cli": "^7.21.0",
|