lilact 0.8.3 → 0.9.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/bin/bundle.js DELETED
@@ -1,118 +0,0 @@
1
- #!/usr/bin/env node
2
-
3
- /*
4
-
5
- Lilact
6
- Copyright (C) 2024-2025 Arash Kazemi <contact.arash.kazemi@gmail.com>
7
- All rights reserved.
8
- BSD-2-Clause
9
-
10
- Redistribution and use in source and binary forms, with or without
11
- modification, are permitted provided that the following conditions are met:
12
-
13
- * Redistributions of source code must retain the above copyright
14
- notice, this list of conditions and the following disclaimer.
15
- * Redistributions in binary form must reproduce the above copyright
16
- notice, this list of conditions and the following disclaimer in the
17
- documentation and/or other materials provided with the distribution.
18
-
19
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
20
- AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21
- IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22
- ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
23
- DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
24
- (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
25
- LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
26
- ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27
- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
28
- THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29
-
30
- */
31
-
32
- const path = require("path");
33
- const webpack = require("webpack");
34
-
35
-
36
- function parseArgs(argv) {
37
- // Simple args:
38
- // bundler --entry ./src/index.js --out ./dist/bundle
39
- const args = {};
40
- for (let i = 2; i < argv.length; i++) {
41
- const k = argv[i];
42
- if (!k.startsWith("--")) continue;
43
- const key = k.slice(2);
44
- const v = argv[i + 1];
45
- i++;
46
- args[key] = v;
47
- }
48
- return args;
49
- }
50
-
51
- async function run() {
52
- const args = parseArgs(process.argv);
53
-
54
- const userProjectRoot = process.cwd(); // MUST be user's project root
55
- const userEntry = args.entry
56
- ? path.resolve(userProjectRoot, args.entry)
57
- : null;
58
-
59
- if (!userEntry) {
60
- console.error("Usage: bundler --entry ./path/to/entry.js --out ./dist/out");
61
- process.exit(1);
62
- }
63
-
64
- // Locate lilact root reliably (where this CLI is installed)
65
- const myPackageRoot = path.dirname(require.resolve("lilact/package.json"));
66
-
67
- // Load config factory from your package
68
- const configFactoryPath = path.join(myPackageRoot, "webpack.config.factory.cjs");
69
- const configFactory = require(configFactoryPath);
70
-
71
- const userOutDir = args.out
72
- ? path.resolve(userProjectRoot, args.out)
73
- : path.resolve(userProjectRoot, "dist/bundle-out");
74
-
75
- // Build config using a factory, then override resolution for user's project
76
- const baseConfig = configFactory({
77
- entry: userEntry,
78
- outputPath: userOutDir,
79
- userProjectRoot
80
- });
81
-
82
- // ---- Critical: ensure resolution happens from user's project ----
83
- baseConfig.context = userProjectRoot;
84
- baseConfig.resolve = baseConfig.resolve || {};
85
- baseConfig.resolve.modules = [
86
- path.join(userProjectRoot, "node_modules"),
87
- "node_modules"
88
- ];
89
-
90
- const compiler = webpack(baseConfig);
91
-
92
- compiler.run((err, stats) => {
93
- // webpack keeps resources; close when available
94
- compiler.close(() => {});
95
-
96
- if (err) {
97
- console.error(err);
98
- process.exit(1);
99
- }
100
-
101
- if (stats?.hasErrors?.()) {
102
- console.error(stats.toString("errors-only"));
103
- process.exit(1);
104
- }
105
-
106
- console.log(
107
- stats?.toString?.({
108
- colors: true,
109
- chunks: false
110
- }) || "Build finished."
111
- );
112
- });
113
- }
114
-
115
- run().catch((e) => {
116
- console.error(e);
117
- process.exit(1);
118
- });