onlybuild 1.3.0 → 1.4.1

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/CHANGELOG.md CHANGED
@@ -1,5 +1,19 @@
1
1
  # Changelog
2
2
 
3
+ ## [v1.4.1](https://github.com/neogeek/onlybuild/tree/v1.4.1) - (2024-05-09)
4
+
5
+ [Full Changelog](https://github.com/neogeek/onlybuild/compare/v1.4.0...v1.4.1)
6
+
7
+ - [hotfix] Added missing flag to pass options in shebang line. [#19](https://github.com/neogeek/onlybuild/pull/19)
8
+
9
+ ## [v1.4.0](https://github.com/neogeek/onlybuild/tree/v1.4.0) - (2024-05-08)
10
+
11
+ [Full Changelog](https://github.com/neogeek/onlybuild/compare/v1.3.0...v1.4.0)
12
+
13
+ - [feat] Switch typescript work without a flag. [#18](https://github.com/neogeek/onlybuild/pull/18)
14
+ - [feat] TSX/React.js Support [#17](https://github.com/neogeek/onlybuild/pull/17)
15
+ - [hotfix] Fixed TypeScript logic to not override JavaScript functionality. [#16](https://github.com/neogeek/onlybuild/pull/16)
16
+
3
17
  ## [v1.3.0](https://github.com/neogeek/onlybuild/tree/v1.3.0) - (2024-05-08)
4
18
 
5
19
  [Full Changelog](https://github.com/neogeek/onlybuild/compare/v1.2.1...v1.3.0)
package/README.md CHANGED
@@ -32,6 +32,7 @@
32
32
  - [Getting Started](#getting-started)
33
33
  - [File Structure](#file-structure)
34
34
  - [Ignore Files](#ignore-files)
35
+ - [React](#react)
35
36
  - [TypeScript](#typescript)
36
37
  - [Formatting Files](#formatting-files)
37
38
  - [Watching For Changes](#watching-for-changes)
@@ -92,7 +93,6 @@ Usage: onlybuild <path> [options]
92
93
  -v, --version Display the current installed version.
93
94
  -o, --out Sets build directory. Default path is build/
94
95
  -i, --ignore Sets ignore file path. Default path is .onlyignore
95
- -t, --typescript Parse TypeScript files. (experimental)
96
96
  ```
97
97
 
98
98
  ## Quick Start Guide
@@ -264,18 +264,34 @@ screenshot.png
264
264
  LICENSE
265
265
  ```
266
266
 
267
- ## TypeScript
267
+ ## React
268
268
 
269
- > [!WARNING]
270
- > This feature is experimental.
269
+ If you want to use [React.js](https://react.dev/), instead of <code>&#96;html&#96;</code> string templates, you can do that by using `react-dom/server` in a `.jsx` or `.tsx` file.
271
270
 
272
- By default `onlybuild` looks for `.mjs` files, but if you add the `--typescript` flag to the build command, it will instead look for `.ts` files.
271
+ ```javascript
272
+ import React from 'react';
273
+ import { renderToString } from 'react-dom/server';
273
274
 
274
- ```bash
275
- $ npx onlybuild --typescript
275
+ function Hello() {
276
+ return <h1>Hello, React!</h1>;
277
+ }
278
+
279
+ export default renderToString(<Hello />);
280
+ ```
281
+
282
+ In order for `.jsx` or `.tsx` files to work property you will need to add `"type": "module"` to your `package.json`.
283
+
284
+ ```json
285
+ {
286
+ ...
287
+ "type": "module",
288
+ ...
289
+ }
276
290
  ```
277
291
 
278
- You will also need to add `"type": "module"` to your `package.json` file for imports to work correctly.
292
+ ## TypeScript
293
+
294
+ In order for TypeScript files to work property you will need to add `"type": "module"` to your `package.json`.
279
295
 
280
296
  ```json
281
297
  {
@@ -350,6 +366,7 @@ Serving the files once the build is complete is easy using the NPM package [http
350
366
  1. [External API](./examples/external-api/) - Output data fetched from an external API.
351
367
  1. [<code>&#96;html&#96;</code> String Template](./examples/html-string-template/) - Use the <code>&#96;html&#96;</code> string template utility to add syntax highlighting to HTML.
352
368
  1. [Includes](./examples/includes/) - An example that uses reusable includes for building multiple pages.
369
+ 1. [React.js](./examples/react.js/) - An example using React.js to render HTML.
353
370
 
354
371
  ## Benchmark
355
372
 
@@ -1,3 +1,4 @@
1
- #!/usr/bin/env node --no-warnings
1
+ #!/usr/bin/env -S node --no-warnings
2
2
  import 'dotenv/config';
3
+ import 'tsx/esm';
3
4
  export {};
package/dist/bin/index.js CHANGED
@@ -1,6 +1,6 @@
1
- #!/usr/bin/env node --no-warnings
1
+ #!/usr/bin/env -S node --no-warnings
2
2
  import 'dotenv/config';
3
- import { register } from 'tsx/esm/api';
3
+ import 'tsx/esm';
4
4
  import { globby } from 'globby';
5
5
  import parseCmdArgs from 'parse-cmd-args';
6
6
  import { buildFiles, writeFiles } from '../src/build.js';
@@ -22,7 +22,6 @@ else if (args.flags['--help'] || args.flags['-h']) {
22
22
  -v, --version Display the current installed version.
23
23
  -o, --out Sets build directory. Default path is build/
24
24
  -i, --ignore Sets ignore file path. Default path is .onlyignore
25
- -t, --typescript Parse TypeScript files. (experimental)
26
25
  `);
27
26
  process.exit();
28
27
  }
@@ -32,25 +31,25 @@ const [buildDir = 'build/'] = [args.flags['--out'], args.flags['-o']]
32
31
  const [ignoreFile = '.onlyignore'] = [args.flags['--ignore'], args.flags['-i']]
33
32
  .filter(flag => typeof flag === 'string')
34
33
  .map(String);
35
- const [typescript = false] = [args.flags['--typescript'], args.flags['-t']]
36
- .filter(flag => typeof flag === 'boolean')
37
- .map(Boolean);
38
- if (typescript) {
39
- register();
40
- }
41
34
  const filesToBuild = await globby([
42
- typescript ? '**/*.ts' : '**/*.mjs',
35
+ '**/*.mjs',
36
+ '**/*.jsx',
37
+ '**/*.ts',
38
+ '**/*.tsx',
43
39
  '!_*/**/*',
44
40
  '!node_modules/',
45
41
  `!${buildDir}`
46
- ], {
42
+ ].filter(Boolean), {
47
43
  gitignore: false,
48
44
  ignoreFiles: [ignoreFile],
49
45
  cwd: args.inputs[0]
50
46
  });
51
47
  const filesToCopy = await globby([
52
48
  '**/*',
53
- typescript ? '!**/*.ts' : '!**/*.mjs',
49
+ '!**/*.mjs',
50
+ '!**/*.jsx',
51
+ '!**/*.ts',
52
+ '!**/*.tsx',
54
53
  '!_*/**/*',
55
54
  '!package.json',
56
55
  '!package-lock.json',
package/dist/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "onlybuild",
3
3
  "description": "A zero-config cli for building static websites.",
4
- "version": "1.3.0",
4
+ "version": "1.4.1",
5
5
  "engines": {
6
6
  "node": ">=20.x"
7
7
  },
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "onlybuild",
3
3
  "description": "A zero-config cli for building static websites.",
4
- "version": "1.3.0",
4
+ "version": "1.4.1",
5
5
  "engines": {
6
6
  "node": ">=20.x"
7
7
  },