@vanillaes/esmtk 0.13.0 → 0.14.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/commonjs.js +12 -2
- package/bin/esmtk.js +3 -2
- package/package.json +1 -1
package/.vscode/launch.json
CHANGED
|
@@ -73,6 +73,18 @@
|
|
|
73
73
|
"args": ["minify", "--sourcemap", "--platform=node", "./src/index.js", "./dist/index.min.js"],
|
|
74
74
|
"console": "integratedTerminal",
|
|
75
75
|
},
|
|
76
|
+
{
|
|
77
|
+
"name": "CommonJS",
|
|
78
|
+
"type": "node",
|
|
79
|
+
"request": "launch",
|
|
80
|
+
"skipFiles": [
|
|
81
|
+
"<node_internals>/**"
|
|
82
|
+
],
|
|
83
|
+
"program": "${workspaceFolder}/bin/esmtk.js",
|
|
84
|
+
"cwd": "${workspaceFolder}",
|
|
85
|
+
"args": ["commonjs", "--platform=node", "./src/index.js", "./dist/index.cjs"],
|
|
86
|
+
"console": "integratedTerminal",
|
|
87
|
+
},
|
|
76
88
|
{
|
|
77
89
|
"name": "CopyFileToFile",
|
|
78
90
|
"type": "node",
|
package/README.md
CHANGED
package/bin/commands/commonjs.js
CHANGED
|
@@ -5,8 +5,9 @@ import { spawn } from 'child_process'
|
|
|
5
5
|
* Bundle CJS (CommonJS) code
|
|
6
6
|
* @param {string} input the input path
|
|
7
7
|
* @param {string} output the output path
|
|
8
|
+
* @param {any} options commonjs options
|
|
8
9
|
*/
|
|
9
|
-
export async function commonjs (input, output) {
|
|
10
|
+
export async function commonjs (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 commonjs (input, output) {
|
|
|
21
22
|
process.exit(1)
|
|
22
23
|
}
|
|
23
24
|
|
|
24
|
-
|
|
25
|
+
const args = []
|
|
26
|
+
args.push('--bundle')
|
|
27
|
+
args.push('--format=cjs')
|
|
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/esmtk.js
CHANGED
|
@@ -38,8 +38,9 @@ program.command('bundle <input> <output>')
|
|
|
38
38
|
|
|
39
39
|
program.command('commonjs <input> <output>')
|
|
40
40
|
.description('Transpile the source to CommonJS using ESBuild')
|
|
41
|
-
.
|
|
42
|
-
|
|
41
|
+
.option('--platform <platform>', 'Target a specific platform (ex node)')
|
|
42
|
+
.action((input, output, options) => {
|
|
43
|
+
commonjs(input, output, options)
|
|
43
44
|
})
|
|
44
45
|
|
|
45
46
|
program.command('minify <input> <output>')
|