@tmbr/bundler 1.1.0 → 1.2.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/cli.js +52 -3
- package/error.js +6 -3
- package/package.json +3 -3
package/cli.js
CHANGED
|
@@ -3,8 +3,8 @@ const esbuild = require('esbuild');
|
|
|
3
3
|
const path = require('path');
|
|
4
4
|
const exec = require('child_process').execSync;
|
|
5
5
|
const styles = require('esbuild-sass-plugin').sassPlugin;
|
|
6
|
-
const qrcode = require('qrcode-terminal');
|
|
7
6
|
const chalk = require('chalk');
|
|
7
|
+
const qr = require('qrcode-terminal');
|
|
8
8
|
const bs = require('browser-sync').create();
|
|
9
9
|
const renderError = require('./error');
|
|
10
10
|
|
|
@@ -20,6 +20,50 @@ if (!['build', 'watch'].includes(command)) {
|
|
|
20
20
|
|
|
21
21
|
exec(`rm -rf ${cwd}/build/*`);
|
|
22
22
|
|
|
23
|
+
/* const logger = (options = {}) => ({
|
|
24
|
+
name: 'logger',
|
|
25
|
+
setup(build) {
|
|
26
|
+
|
|
27
|
+
let info;
|
|
28
|
+
// const cache = new Map;
|
|
29
|
+
|
|
30
|
+
function reset() {
|
|
31
|
+
console.clear();
|
|
32
|
+
info.external && console.log(info.qrcode);
|
|
33
|
+
console.log(`Proxying: ${chalk.green(info.proxying)}`);
|
|
34
|
+
console.log(`External: ${chalk.cyan(info.external || 'offline')}`);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
build.onEnd(() => {
|
|
38
|
+
|
|
39
|
+
if (typeof info === 'undefined') {
|
|
40
|
+
|
|
41
|
+
const host = bs.getOption('proxy').get('target');
|
|
42
|
+
const port = bs.getOption('port');
|
|
43
|
+
|
|
44
|
+
info = {};
|
|
45
|
+
info.proxying = `${host}:${port}`;
|
|
46
|
+
info.external = bs.getOption('urls').get('external');
|
|
47
|
+
|
|
48
|
+
info.external && qr.generate(info.external, {small: true}, qrcode => {
|
|
49
|
+
info.qrcode = qrcode;
|
|
50
|
+
reset();
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
error = result.errors[0];
|
|
57
|
+
|
|
58
|
+
if (error) {
|
|
59
|
+
bs.reload();
|
|
60
|
+
} else {
|
|
61
|
+
reset();
|
|
62
|
+
}
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
}); */
|
|
66
|
+
|
|
23
67
|
const assets = (options = {}) => ({
|
|
24
68
|
name: 'assets',
|
|
25
69
|
setup(build) {
|
|
@@ -33,6 +77,7 @@ const assets = (options = {}) => ({
|
|
|
33
77
|
const errors = (options = {}) => ({
|
|
34
78
|
name: 'errors',
|
|
35
79
|
setup(build) {
|
|
80
|
+
|
|
36
81
|
build.onEnd(result => {
|
|
37
82
|
error = result.errors[0];
|
|
38
83
|
error && bs.reload();
|
|
@@ -42,7 +87,7 @@ const errors = (options = {}) => ({
|
|
|
42
87
|
|
|
43
88
|
function entryPoints(suffix = '') {
|
|
44
89
|
|
|
45
|
-
if (!suffix.startsWith('.')) {
|
|
90
|
+
if (suffix.length && !suffix.startsWith('.')) {
|
|
46
91
|
suffix = `.${suffix}`;
|
|
47
92
|
}
|
|
48
93
|
|
|
@@ -126,9 +171,13 @@ if (command === 'watch') {
|
|
|
126
171
|
const port = bs.getOption('port');
|
|
127
172
|
const proxying = `${host}:${port}`;
|
|
128
173
|
const external = bs.getOption('urls').get('external');
|
|
174
|
+
external && qr.generate(external, {small: true}, console.log);
|
|
129
175
|
|
|
130
|
-
external && qrcode.generate(external, {small: true}, console.log);
|
|
131
176
|
console.log(`Proxying: ${chalk.green(proxying)}`);
|
|
132
177
|
console.log(`External: ${chalk.cyan(external || 'offline')}`);
|
|
133
178
|
});
|
|
134
179
|
}
|
|
180
|
+
|
|
181
|
+
process.on('SIGINT', () => {
|
|
182
|
+
process.exit();
|
|
183
|
+
})
|
package/error.js
CHANGED
|
@@ -7,18 +7,21 @@ module.exports = error => {
|
|
|
7
7
|
|
|
8
8
|
const lines = fs.readFileSync(file, 'UTF-8').split(/\r?\n/);
|
|
9
9
|
const index = line - 1;
|
|
10
|
-
const space = ' ';
|
|
11
|
-
|
|
12
10
|
const inset = String((lines[index + 2] && line + 2) || (lines[index + 1] && line + 1) || line).split('').length;
|
|
11
|
+
|
|
13
12
|
const print = offset => (
|
|
14
13
|
`<span class="c-gray">${String(line + offset).padStart(2 + inset, ' ')} | </span>` + encode(lines[index + offset])
|
|
15
14
|
);
|
|
16
15
|
|
|
16
|
+
const space = length => {
|
|
17
|
+
return ' '.repeat(length);
|
|
18
|
+
};
|
|
19
|
+
|
|
17
20
|
const output = [
|
|
18
21
|
(index - 2) >= 0 && print(-2),
|
|
19
22
|
(index - 1) >= 0 && print(-1),
|
|
20
23
|
`<span class="c-red fw-700">></span><span class="c-gray"> ${line} | </span>${encode(lines[index])}`,
|
|
21
|
-
` <span class="c-gray">${space
|
|
24
|
+
` <span class="c-gray">${space(2 + inset)}| </span>${space(column ? column - 1 : 0)}<span class="c-red fw-700">^</span>`,
|
|
22
25
|
(index + 1) <= lines.length - 1 && print(1),
|
|
23
26
|
(index + 2) <= lines.length - 1 && print(2),
|
|
24
27
|
].filter(Boolean).join('\n');
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tmbr/bundler",
|
|
3
3
|
"author": "TMBR (https://wearetmbr.com/)",
|
|
4
|
-
"version": "1.
|
|
4
|
+
"version": "1.2.0",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": "https://github.com/TMBR/tmbr-bundler",
|
|
7
7
|
"description": "WordPress development toolkit built on esbuild and browser-sync",
|
|
@@ -11,8 +11,8 @@
|
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"browser-sync": "^2.27.5",
|
|
13
13
|
"chalk": "^4.1.2",
|
|
14
|
-
"esbuild": "^0.
|
|
15
|
-
"esbuild-sass-plugin": "^
|
|
14
|
+
"esbuild": "^0.14.14",
|
|
15
|
+
"esbuild-sass-plugin": "^2.2.1",
|
|
16
16
|
"html-entities": "^2.3.2",
|
|
17
17
|
"qrcode-terminal": "^0.12.0"
|
|
18
18
|
}
|