rollerwheel 0.0.2 → 0.0.4

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.
Files changed (4) hide show
  1. package/README.md +41 -0
  2. package/package.json +2 -2
  3. package/roller.js +15 -6
  4. package/.env +0 -0
package/README.md ADDED
@@ -0,0 +1,41 @@
1
+ ## rollerwheel
2
+
3
+ For creating clientside JavaScript bundles.
4
+
5
+ No config file necessary. Allows for mixing CommonJS and ESM in same file (primarily supporting CommonJS; your ESM mileage may vary).
6
+
7
+ Under the hood it is a convenience wrapper for an opinionated Rollup and Babel configuration that Just Works™
8
+
9
+
10
+ ### usage
11
+
12
+ *client.js*
13
+
14
+ #####
15
+ ```javascript
16
+ //some example deps
17
+ const { $j, $click, Grow } = require('html-template-utils')
18
+ import * as d3 from "d3"
19
+
20
+ console.log('hello world')
21
+
22
+ //your app code
23
+ ```
24
+
25
+ *from your terminal:*
26
+
27
+ ```bash
28
+ npm install rollerwheel
29
+ npx rollerwheel
30
+ #^ reads "client.js" and outputs browser-ready bundle to "client.bundle.js"
31
+
32
+ npx rollerwheel -w
33
+ #^ same but watches/re-bundles when client.js is edited
34
+
35
+ npx rollerwheel admin.js -w
36
+ #^ reads admin.js and outputs to "admin.bundle.js"
37
+
38
+ ```
39
+
40
+ If you have a dir called `static` in the same dir from which you call rollerwheel, the bundle will output to said static dir.
41
+
package/package.json CHANGED
@@ -1,10 +1,10 @@
1
1
  {
2
2
  "name": "rollerwheel",
3
- "version": "0.0.2",
3
+ "version": "0.0.4",
4
4
  "description": "CLI tool for bundling client.js with Rollup",
5
5
  "main": "roller.js",
6
6
  "bin": {
7
- "roller": "./roller.js"
7
+ "rollerwheel": "./roller.js"
8
8
  },
9
9
  "keywords": [
10
10
  "rollup",
package/roller.js CHANGED
@@ -9,29 +9,38 @@ const nodePolyfills = require('rollup-plugin-polyfill-node')
9
9
  const ignore = require('rollup-plugin-ignore')
10
10
  const babel = require('@rollup/plugin-babel').babel
11
11
  const { existsSync } = require('fs')
12
- const { join, dirname } = require('path')
12
+ const { join, basename } = require('path')
13
13
  const json = require('@rollup/plugin-json')
14
14
 
15
15
  // Parse command line args
16
16
  const args = process.argv.slice(2)
17
17
  const watchMode = args.includes('--watch') || args.includes('-w')
18
18
 
19
+ // Get file parameter (first arg that doesn't start with -)
20
+ const fileArg = args.find(arg => !arg.startsWith('-'))
21
+ const inputFileName = fileArg || 'client.js'
22
+
19
23
  const main = async () => {
20
24
  try {
21
25
  const cwd = process.cwd()
22
- const inputFile = join(cwd, 'client.js')
26
+ const inputFile = join(cwd, inputFileName)
23
27
 
24
- // Check if client.js exists
28
+ // Check if input file exists
25
29
  if (!existsSync(inputFile)) {
26
- warn(`Error: client.js not found in ${cwd}`)
30
+ warn(`Error: ${inputFileName} not found in ${cwd}`)
27
31
  process.exit(1)
28
32
  }
29
33
 
34
+ // Determine output filename based on input
35
+ // e.g., client.js -> client.bundle.js, admin-client.js -> admin-client.bundle.js
36
+ const baseName = basename(inputFileName, '.js')
37
+ const outputFileName = `${baseName}.bundle.js`
38
+
30
39
  // Determine output path
31
40
  const staticDir = join(cwd, 'static')
32
41
  const outputFile = existsSync(staticDir)
33
- ? join(staticDir, 'client.bundle.js')
34
- : join(cwd, 'client.bundle.js')
42
+ ? join(staticDir, outputFileName)
43
+ : join(cwd, outputFileName)
35
44
 
36
45
  const config = {
37
46
  input: inputFile,
package/.env DELETED
File without changes