@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.
@@ -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
@@ -85,6 +85,7 @@ Bundle and Minify the source code to an ECMAScript module (using ESBuild)
85
85
 
86
86
  - `[input]` - the input source file path
87
87
  - `[output]` - the output bundle file path
88
+ - `--sourcemap` - generate a source map for the minified bundle
88
89
 
89
90
  ### Usage
90
91
 
@@ -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
- spawn('esbuild', ['--format=esm', '--minify', '--bundle', input, `--outfile=${output}`], {
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
- .action((input, output) => {
47
- minify(input, output)
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>')
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vanillaes/esmtk",
3
- "version": "0.10.0",
3
+ "version": "0.11.0",
4
4
  "description": "ES Module Toolkit",
5
5
  "keywords": [
6
6
  "esm",