lilact 0.8.4 → 0.9.1
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 +22 -8
- package/bin/bundle.cjs +46 -37
- package/dist/lilact.development.js +73 -72
- package/dist/lilact.development.js.map +1 -1
- package/dist/lilact.development.min.js +1 -1
- package/dist/lilact.development.min.js.map +1 -1
- package/dist/lilact.production.min.js +1 -1
- package/dist/lilact.production.min.js.map +1 -1
- package/docs/assets/hierarchy.js +1 -1
- package/docs/assets/navigation.js +1 -1
- package/docs/assets/search.js +1 -1
- package/docs/classes/accessories.ErrorBoundary.html +7 -7
- package/docs/classes/accessories.Suspense.html +4 -5
- package/docs/classes/components.Component.html +2 -2
- package/docs/classes/components.HTMLComponent.html +1 -1
- package/docs/classes/components.RootComponent.html +1 -1
- package/docs/functions/hooks.createContext.html +3 -2
- package/docs/functions/hooks.useActionState.html +3 -2
- package/docs/functions/hooks.useContext.html +3 -2
- package/docs/functions/hooks.useState.html +3 -2
- package/docs/functions/misc.classNames.html +2 -1
- package/docs/functions/misc.deepEqual.html +3 -1
- package/docs/functions/misc.findDOMNode.html +3 -2
- package/docs/functions/misc.isAsync.html +3 -2
- package/docs/functions/misc.isClass.html +3 -2
- package/docs/functions/misc.isEmpty.html +3 -2
- package/docs/functions/misc.isError.html +3 -2
- package/docs/functions/misc.isThenable.html +3 -2
- package/docs/functions/misc.isValidElement.html +3 -2
- package/docs/functions/misc.shallowEqual.html +3 -1
- package/docs/functions/misc.toBool.html +3 -2
- package/docs/functions/router.NavLink.html +4 -2
- package/docs/functions/router.Route.html +1 -1
- package/docs/functions/router.Routes.html +1 -1
- package/docs/functions/timers.clearInterval.html +3 -2
- package/docs/functions/timers.clearTimeout.html +3 -2
- package/docs/functions/timers.setInterval.html +3 -2
- package/docs/functions/timers.setTimeout.html +4 -2
- package/docs/hierarchy.html +1 -1
- package/docs/index.html +19 -6
- package/docs/modules.html +1 -1
- package/docs/static/lilact.development.js +73 -72
- package/docs/static/lilact.development.min.js +1 -1
- package/docs/static/lilact.production.min.js +1 -1
- package/package.json +1 -1
- package/root/lilact.development.js +73 -72
- package/root/lilact.development.min.js +1 -1
- package/root/lilact.production.min.js +1 -1
- package/src/accessories.jsx +0 -4
- package/src/components.jsx +1 -1
- package/src/hooks.jsx +14 -14
- package/src/jsx.js +8 -5
- package/src/lilact.jsx +1 -1
- package/src/misc.jsx +31 -31
- package/src/router.jsx +3 -1
- package/src/run.jsx +1 -1
- package/src/timers.jsx +8 -8
- package/typedoc.json +1 -1
- package/bin/bundle.js +0 -118
- package/docs/functions/jsx.transpileJSX.html +0 -6
- package/docs/modules/jsx.html +0 -1
package/README.md
CHANGED
|
@@ -6,16 +6,24 @@
|
|
|
6
6
|
|
|
7
7
|
---
|
|
8
8
|
|
|
9
|
-
[Docs on GitHub Pages](https://arashkazemi.github.io/lilact/)
|
|
10
|
-
|
|
11
|
-
[
|
|
12
|
-
|
|
13
|
-
[
|
|
9
|
+
[Docs on GitHub Pages](https://arashkazemi.github.io/lilact/)
|
|
10
|
+
||
|
|
11
|
+
[Demos on GitHub Pages](https://arashkazemi.github.io/lilact/static)
|
|
12
|
+
||
|
|
13
|
+
[Official Repository](https://github.com/arashkazemi/lilact)
|
|
14
|
+
||
|
|
15
|
+
[npm Package](https://www.npmjs.com/package/lilact)
|
|
16
|
+
||
|
|
17
|
+
[Lilact/Node/Express Demo](https://github.com/arashkazemi/lilact-express)
|
|
18
|
+
||
|
|
19
|
+
[Lilact/PHP Demo](https://github.com/arashkazemi/lilact-php-demo)
|
|
20
|
+
||
|
|
21
|
+
[Lilact/Python Demo](https://github.com/arashkazemi/lilact-python-demo)
|
|
14
22
|
|
|
15
23
|
---
|
|
16
24
|
|
|
17
25
|
If you find Lilact useful, please consider sponsoring. Your support funds ongoing maintenance, performance improvements, and new features.
|
|
18
|
-
[Sponsor me on GitHub](github.com/sponsors/arashkazemi)
|
|
26
|
+
[Sponsor me on GitHub](https://github.com/sponsors/arashkazemi)
|
|
19
27
|
|
|
20
28
|
---
|
|
21
29
|
|
|
@@ -76,16 +84,22 @@ A `webpack` based bundler is available in the `bin` directory. It can be used li
|
|
|
76
84
|
npx lilact-bundle --entry client/App.jsx --mode production --name bundle.js --out public/dist
|
|
77
85
|
```
|
|
78
86
|
|
|
87
|
+
If you add a `--watch` argument, the bundler will not exit and keep watching the input file(s),
|
|
88
|
+
and update the bundle if any file is changed.
|
|
89
|
+
|
|
79
90
|
---
|
|
80
91
|
|
|
81
92
|
## Using Lilact Outside Node.js (Browser / Script Tag Integration)
|
|
82
93
|
|
|
83
94
|
`Lilact` runs in the browser, so if you use `Lilact` outside Node, it uses `eval` to run the transpiled scripts, so it cannot use `import`/`export` the same way as a module.
|
|
84
95
|
|
|
85
|
-
Import the functions using this convention
|
|
96
|
+
Import the `Lilact` functions using this convention. There is also a `require` function that you can use
|
|
97
|
+
to load other JSX or JS files.
|
|
86
98
|
|
|
87
99
|
```js
|
|
88
|
-
const { useState, useRef, render } = Lilact;
|
|
100
|
+
const { useState, useRef, render, require } = Lilact;
|
|
101
|
+
|
|
102
|
+
const App = require('./App.jsx');
|
|
89
103
|
```
|
|
90
104
|
|
|
91
105
|
To export:
|
package/bin/bundle.cjs
CHANGED
|
@@ -32,18 +32,19 @@
|
|
|
32
32
|
const path = require("path");
|
|
33
33
|
const webpack = require("webpack");
|
|
34
34
|
|
|
35
|
-
|
|
36
35
|
function parseArgs(argv) {
|
|
37
|
-
// Simple args:
|
|
38
|
-
// bundler --entry ./src/index.js --out ./dist/bundle
|
|
39
36
|
const args = {};
|
|
40
37
|
for (let i = 2; i < argv.length; i++) {
|
|
41
38
|
const k = argv[i];
|
|
42
39
|
if (!k.startsWith("--")) continue;
|
|
43
40
|
const key = k.slice(2);
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
41
|
+
if(key==='watch') {
|
|
42
|
+
args[key] = true;
|
|
43
|
+
}
|
|
44
|
+
else {
|
|
45
|
+
const v = argv[++i];
|
|
46
|
+
args[key] = v;
|
|
47
|
+
}
|
|
47
48
|
}
|
|
48
49
|
return args;
|
|
49
50
|
}
|
|
@@ -52,22 +53,20 @@ async function run() {
|
|
|
52
53
|
const args = parseArgs(process.argv);
|
|
53
54
|
|
|
54
55
|
const userProjectRoot = process.cwd(); // MUST be user's project root
|
|
55
|
-
const userEntry = args.entry
|
|
56
|
-
? path.resolve(userProjectRoot, args.entry)
|
|
57
|
-
: null;
|
|
56
|
+
const userEntry = args.entry ? path.resolve(userProjectRoot, args.entry) : null;
|
|
58
57
|
|
|
59
58
|
if (!userEntry) {
|
|
60
|
-
console.error(
|
|
59
|
+
console.error(
|
|
60
|
+
"Usage: lilact-bundler --watch --entry ./path/to/entry.js --mode production --out ./dist/out --name bundle.js"
|
|
61
|
+
);
|
|
61
62
|
process.exit(1);
|
|
62
63
|
}
|
|
63
64
|
|
|
64
65
|
const name = args.name ?? "bundle.js";
|
|
65
66
|
const mode = args.mode ?? "production";
|
|
67
|
+
const watch = args?.watch===true;
|
|
66
68
|
|
|
67
|
-
// Locate lilact root reliably (where this CLI is installed)
|
|
68
69
|
const lilactRoot = path.dirname(require.resolve("lilact/package.json"));
|
|
69
|
-
|
|
70
|
-
// Load config factory from your package
|
|
71
70
|
const configFactoryPath = path.join(lilactRoot, "webpack.config.factory.cjs");
|
|
72
71
|
const configFactory = require(configFactoryPath);
|
|
73
72
|
|
|
@@ -75,44 +74,54 @@ async function run() {
|
|
|
75
74
|
? path.resolve(userProjectRoot, args.out)
|
|
76
75
|
: path.resolve(userProjectRoot, "dist");
|
|
77
76
|
|
|
78
|
-
// Build config using a factory, then override resolution for user's project
|
|
79
77
|
const baseConfig = configFactory({
|
|
80
78
|
entry: userEntry,
|
|
81
79
|
outputPath: userOutDir,
|
|
82
80
|
userProjectRoot,
|
|
83
|
-
mode,
|
|
81
|
+
mode,
|
|
82
|
+
name
|
|
84
83
|
});
|
|
85
84
|
|
|
86
85
|
// ---- Critical: ensure resolution happens from user's project ----
|
|
87
86
|
baseConfig.context = userProjectRoot;
|
|
88
87
|
baseConfig.resolve = baseConfig.resolve || {};
|
|
89
|
-
baseConfig.resolve.modules = [
|
|
90
|
-
path.join(userProjectRoot, "node_modules"),
|
|
91
|
-
"node_modules"
|
|
92
|
-
];
|
|
88
|
+
baseConfig.resolve.modules = [path.join(userProjectRoot, "node_modules"), "node_modules"];
|
|
93
89
|
|
|
94
90
|
const compiler = webpack(baseConfig);
|
|
95
91
|
|
|
96
|
-
compiler.
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
92
|
+
const watching = compiler.watch(
|
|
93
|
+
{
|
|
94
|
+
// You can tweak these; leaving as defaults usually works.
|
|
95
|
+
// aggregateTimeout: 300,
|
|
96
|
+
// poll: 1000
|
|
97
|
+
},
|
|
98
|
+
(err, stats) => {
|
|
99
|
+
if (err) {
|
|
100
|
+
console.error(err);
|
|
101
|
+
return; // keep watching
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
if (stats?.hasErrors?.()) {
|
|
105
|
+
console.error(stats.toString("errors-only"));
|
|
106
|
+
return; // keep watching
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
console.log(
|
|
110
|
+
stats?.toString?.({
|
|
111
|
+
colors: true,
|
|
112
|
+
chunks: false
|
|
113
|
+
}) || "Build finished."
|
|
114
|
+
);
|
|
115
|
+
|
|
116
|
+
if(!watch) process.exit(1);
|
|
108
117
|
}
|
|
118
|
+
);
|
|
109
119
|
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
);
|
|
120
|
+
process.on("SIGINT", () => {
|
|
121
|
+
watching.close(() => process.exit(0));
|
|
122
|
+
});
|
|
123
|
+
process.on("SIGTERM", () => {
|
|
124
|
+
watching.close(() => process.exit(0));
|
|
116
125
|
});
|
|
117
126
|
}
|
|
118
127
|
|