bimba-cli 0.2.4 → 0.2.5
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/index.js +25 -18
- package/package.json +6 -3
- package/plugin.js +1 -48
package/index.js
CHANGED
|
@@ -101,26 +101,33 @@ async function bundle() {
|
|
|
101
101
|
|
|
102
102
|
console.log("──────────────────────────────────────────────────────────────────────");
|
|
103
103
|
console.log(theme.start(`Start building the Imba entrypoint: ${theme.filedir(entrypoint)}`));
|
|
104
|
-
|
|
105
|
-
const result = await Bun.build({
|
|
106
|
-
entrypoints: [entrypoint],
|
|
107
|
-
outdir: flags.outdir,
|
|
108
|
-
target: flags.target || 'browser',
|
|
109
|
-
sourcemap: flags.sourcemap || 'none',
|
|
110
|
-
minify: flags.minify || true,
|
|
111
|
-
plugins: [imbaPlugin]
|
|
112
|
-
});
|
|
113
104
|
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
105
|
+
let result = undefined
|
|
106
|
+
try {
|
|
107
|
+
result = await Bun.build({
|
|
108
|
+
entrypoints: [entrypoint],
|
|
109
|
+
outdir: flags.outdir,
|
|
110
|
+
target: flags.target || 'browser',
|
|
111
|
+
sourcemap: flags.sourcemap || 'none',
|
|
112
|
+
minify: flags.minify || true,
|
|
113
|
+
plugins: [imbaPlugin]
|
|
114
|
+
});
|
|
118
115
|
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
116
|
+
if(stats.failed)
|
|
117
|
+
console.log(theme.start(theme.failure("Failure.") +` Imba compiler failed to proceed ${theme.count(stats.failed)} file${stats.failed > 1 ? 's' : ''}`));
|
|
118
|
+
else
|
|
119
|
+
console.log(theme.start(theme.success("Success.") +` It took ${theme.time(Date.now() - start)} ms to bundle ${theme.count(stats.bundled)} file${stats.bundled > 1 ? 's' : ''} to the folder: ${theme.filedir(flags.outdir)}`));
|
|
120
|
+
|
|
121
|
+
if(!result.success && !stats.errors){
|
|
122
|
+
for (const log of result.logs) {
|
|
123
|
+
console.log(log);
|
|
124
|
+
}
|
|
122
125
|
}
|
|
123
126
|
}
|
|
124
|
-
|
|
125
|
-
|
|
127
|
+
catch {
|
|
128
|
+
console.log(theme.start(theme.failure("Failure.") +` Unknown error. Chech the syntax.`));
|
|
129
|
+
}
|
|
130
|
+
finally {
|
|
131
|
+
bundling = false;
|
|
132
|
+
};
|
|
126
133
|
}
|
package/package.json
CHANGED
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "bimba-cli",
|
|
3
|
-
"version": "0.2.
|
|
4
|
-
"repository":
|
|
3
|
+
"version": "0.2.5",
|
|
4
|
+
"repository": {
|
|
5
|
+
"type": "git",
|
|
6
|
+
"url": "git+https://github.com/HeapVoid/bimba.git"
|
|
7
|
+
},
|
|
5
8
|
"module": "index.js",
|
|
6
9
|
"bin": {
|
|
7
|
-
"bimba": "
|
|
10
|
+
"bimba": "index.js"
|
|
8
11
|
},
|
|
9
12
|
"scripts": {
|
|
10
13
|
"upload": "npm publish"
|
package/plugin.js
CHANGED
|
@@ -22,57 +22,13 @@ export const imbaPlugin = {
|
|
|
22
22
|
name: "imba",
|
|
23
23
|
async setup(build) {
|
|
24
24
|
|
|
25
|
-
// // when there is import without file extension
|
|
26
|
-
// build.onResolve({filter: /^.*[^.]{5}$/ }, ({ path, importer }) => {
|
|
27
|
-
|
|
28
|
-
// let filename = path;
|
|
29
|
-
// // resolve relative path
|
|
30
|
-
// if (path.startsWith('.')) { filename = dir.resolve(dir.dirname(importer), filename) };
|
|
31
|
-
|
|
32
|
-
// // assume that the file is .js
|
|
33
|
-
// try { return {path: Bun.resolveSync(filename + '.js', '.')}}
|
|
34
|
-
// catch (error) {
|
|
35
|
-
// // assume that the file is .mjs
|
|
36
|
-
// try { return {path: Bun.resolveSync(filename + '.mjs', '.')}}
|
|
37
|
-
// catch (error) {
|
|
38
|
-
// // assume that the file is .cs
|
|
39
|
-
// try { return {path: Bun.resolveSync(filename + '.cjs', '.')}}
|
|
40
|
-
// catch (error) {
|
|
41
|
-
// // assume that the file is .imba
|
|
42
|
-
// try { return {path: Bun.resolveSync(filename + '.imba', '.')}}
|
|
43
|
-
// catch (error) {
|
|
44
|
-
// // if direct resolution failed
|
|
45
|
-
// filename += '.imba';
|
|
46
|
-
|
|
47
|
-
// // assume that the relative path should be resolved relative to importer
|
|
48
|
-
// let fn = dir.resolve(dir.dirname(importer), filename);
|
|
49
|
-
// if (fs.existsSync(fn)) return {path: fn};
|
|
50
|
-
// // assume that the relative path should be resolved relative to node_modules
|
|
51
|
-
// fn = dir.resolve('./node_modules', filename);
|
|
52
|
-
// if (fs.existsSync(fn)) return {path: fn};
|
|
53
|
-
// // assume that the relative path should be resolved relative to project root
|
|
54
|
-
// fn = dir.resolve(process.cwd(), filename);
|
|
55
|
-
// if (fs.existsSync(fn)) return {path: fn};
|
|
56
|
-
|
|
57
|
-
// // if the path still is unresolved throw error and leave the further resolution on Bun's resolver
|
|
58
|
-
// if (error instanceof Error) {
|
|
59
|
-
// throw new Error(error.message);
|
|
60
|
-
// }
|
|
61
|
-
// else
|
|
62
|
-
// throw new Error('Could not resolve file: ' + path);
|
|
63
|
-
// }
|
|
64
|
-
// }
|
|
65
|
-
// }
|
|
66
|
-
// }
|
|
67
|
-
// })
|
|
68
|
-
|
|
69
25
|
// when an .imba file is imported...
|
|
70
26
|
build.onLoad({ filter: /\.imba$/ }, async ({ path }) => {
|
|
71
27
|
|
|
72
28
|
const f = dir.parse(path)
|
|
73
29
|
let contents = '';
|
|
74
30
|
|
|
75
|
-
// return the cached version if
|
|
31
|
+
// return the cached version if exists
|
|
76
32
|
const cached = cache + Bun.hash(path) + '_' + fs.statSync(path).mtimeMs + '.js';
|
|
77
33
|
if (fs.existsSync(cached)) {
|
|
78
34
|
stats.bundled++;
|
|
@@ -95,9 +51,6 @@ export const imbaPlugin = {
|
|
|
95
51
|
platform: 'browser'
|
|
96
52
|
})
|
|
97
53
|
|
|
98
|
-
// print about file complitaion
|
|
99
|
-
|
|
100
|
-
|
|
101
54
|
// the file has been successfully compiled
|
|
102
55
|
if (!out.errors || !out.errors.length) {
|
|
103
56
|
console.log(theme.action("compiling: ") + theme.folder(dir.join(f.dir,'/')) + theme.filename(f.base) + " - " + theme.success("cached"));
|