@vanillaes/esmtk 0.12.0 → 0.13.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 +13 -1
- package/README.md +1 -0
- package/bin/commands/bundle.js +12 -2
- package/bin/commands/minify.js +1 -1
- 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": "Bundle",
|
|
54
|
+
"type": "node",
|
|
55
|
+
"request": "launch",
|
|
56
|
+
"skipFiles": [
|
|
57
|
+
"<node_internals>/**"
|
|
58
|
+
],
|
|
59
|
+
"program": "${workspaceFolder}/bin/esmtk.js",
|
|
60
|
+
"cwd": "${workspaceFolder}",
|
|
61
|
+
"args": ["bundle", "--platform=node", "./src/index.js", "./dist/index.js"],
|
|
62
|
+
"console": "integratedTerminal",
|
|
63
|
+
},
|
|
52
64
|
{
|
|
53
65
|
"name": "Minify",
|
|
54
66
|
"type": "node",
|
|
@@ -58,7 +70,7 @@
|
|
|
58
70
|
],
|
|
59
71
|
"program": "${workspaceFolder}/bin/esmtk.js",
|
|
60
72
|
"cwd": "${workspaceFolder}",
|
|
61
|
-
"args": ["minify", "--sourcemap", "--platform=node", "./src/index.js", "./
|
|
73
|
+
"args": ["minify", "--sourcemap", "--platform=node", "./src/index.js", "./dist/index.min.js"],
|
|
62
74
|
"console": "integratedTerminal",
|
|
63
75
|
},
|
|
64
76
|
{
|
package/README.md
CHANGED
package/bin/commands/bundle.js
CHANGED
|
@@ -5,8 +5,9 @@ import { spawn } from 'child_process'
|
|
|
5
5
|
* Bundle ESM (ECMAScript Module) code (with tree-shaking)
|
|
6
6
|
* @param {string} input the input path
|
|
7
7
|
* @param {string} output the output path
|
|
8
|
+
* @param {any} options bundle options
|
|
8
9
|
*/
|
|
9
|
-
export async function bundle (input, output) {
|
|
10
|
+
export async function bundle (input, output, options) {
|
|
10
11
|
const npmExists = await which('npm')
|
|
11
12
|
if (!npmExists) {
|
|
12
13
|
console.error('npm not found')
|
|
@@ -21,7 +22,16 @@ export async function bundle (input, output) {
|
|
|
21
22
|
process.exit(1)
|
|
22
23
|
}
|
|
23
24
|
|
|
24
|
-
|
|
25
|
+
const args = []
|
|
26
|
+
args.push('--bundle')
|
|
27
|
+
args.push('--format=esm')
|
|
28
|
+
if (options?.platform) {
|
|
29
|
+
args.push(`--platform=${options?.platform}`)
|
|
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/commands/minify.js
CHANGED
|
@@ -23,9 +23,9 @@ export async function minify (input, output, options) {
|
|
|
23
23
|
}
|
|
24
24
|
|
|
25
25
|
const args = []
|
|
26
|
+
args.push('--bundle')
|
|
26
27
|
args.push('--format=esm')
|
|
27
28
|
args.push('--minify')
|
|
28
|
-
args.push('--bundle')
|
|
29
29
|
if (options?.platform) {
|
|
30
30
|
args.push(`--platform=${options?.platform}`)
|
|
31
31
|
}
|
package/bin/esmtk.js
CHANGED
|
@@ -31,8 +31,9 @@ program.command('typings <entry>')
|
|
|
31
31
|
|
|
32
32
|
program.command('bundle <input> <output>')
|
|
33
33
|
.description('Bundle the source using ESBuild')
|
|
34
|
-
.
|
|
35
|
-
|
|
34
|
+
.option('--platform <platform>', 'Target a specific platform (ex node)')
|
|
35
|
+
.action((input, output, options) => {
|
|
36
|
+
bundle(input, output, options)
|
|
36
37
|
})
|
|
37
38
|
|
|
38
39
|
program.command('commonjs <input> <output>')
|