@vanillaes/esmtk 0.10.0 → 0.11.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/.vscode/launch.json +12 -0
- package/README.md +1 -0
- package/bin/commands/minify.js +12 -2
- package/bin/esmtk.js +3 -2
- package/package.json +1 -1
package/.vscode/launch.json
CHANGED
|
@@ -49,6 +49,18 @@
|
|
|
49
49
|
"args": ["typings", "./src/index.js"],
|
|
50
50
|
"console": "integratedTerminal",
|
|
51
51
|
},
|
|
52
|
+
{
|
|
53
|
+
"name": "Minify",
|
|
54
|
+
"type": "node",
|
|
55
|
+
"request": "launch",
|
|
56
|
+
"skipFiles": [
|
|
57
|
+
"<node_internals>/**"
|
|
58
|
+
],
|
|
59
|
+
"program": "${workspaceFolder}/bin/esmtk.js",
|
|
60
|
+
"cwd": "${workspaceFolder}",
|
|
61
|
+
"args": ["minify", "--sourcemap", "./src/index.js", "./src/index.min.js"],
|
|
62
|
+
"console": "integratedTerminal",
|
|
63
|
+
},
|
|
52
64
|
{
|
|
53
65
|
"name": "CopyFileToFile",
|
|
54
66
|
"type": "node",
|
package/README.md
CHANGED
package/bin/commands/minify.js
CHANGED
|
@@ -6,7 +6,7 @@ import { spawn } from 'child_process'
|
|
|
6
6
|
* @param {string} input the input path
|
|
7
7
|
* @param {string} output the output path
|
|
8
8
|
*/
|
|
9
|
-
export async function minify (input, output) {
|
|
9
|
+
export async function minify (input, output, options) {
|
|
10
10
|
const npmExists = await which('npm')
|
|
11
11
|
if (!npmExists) {
|
|
12
12
|
console.error('npm not found')
|
|
@@ -21,7 +21,17 @@ export async function minify (input, output) {
|
|
|
21
21
|
process.exit(1)
|
|
22
22
|
}
|
|
23
23
|
|
|
24
|
-
|
|
24
|
+
const args = []
|
|
25
|
+
args.push('--format=esm')
|
|
26
|
+
args.push('--minify')
|
|
27
|
+
args.push('--bundle')
|
|
28
|
+
if (options?.sourcemap) {
|
|
29
|
+
args.push('--sourcemap')
|
|
30
|
+
}
|
|
31
|
+
args.push(input)
|
|
32
|
+
args.push(`--outfile=${output}`)
|
|
33
|
+
|
|
34
|
+
spawn('esbuild', args, {
|
|
25
35
|
cwd: process.cwd(),
|
|
26
36
|
stdio: ['pipe', process.stdout, process.stderr]
|
|
27
37
|
}).on('error', err => {
|
package/bin/esmtk.js
CHANGED
|
@@ -43,8 +43,9 @@ program.command('commonjs <input> <output>')
|
|
|
43
43
|
|
|
44
44
|
program.command('minify <input> <output>')
|
|
45
45
|
.description('Minify the source using ESBuild')
|
|
46
|
-
.
|
|
47
|
-
|
|
46
|
+
.option('--sourcemap', 'Generate a source map')
|
|
47
|
+
.action((input, output, options) => {
|
|
48
|
+
minify(input, output, options)
|
|
48
49
|
})
|
|
49
50
|
|
|
50
51
|
program.command('cp <source> <target>')
|