@jpp-toolkit/plugin-build-react 0.0.3

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/LICENSE.md ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Julien Papini
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,23 @@
1
+ import { Command } from "@jpp-toolkit/core";
2
+ import * as _oclif_core_interfaces0 from "@oclif/core/interfaces";
3
+
4
+ //#region src/react-build-command.d.ts
5
+ declare class ReactBuildCommand extends Command {
6
+ static summary: string;
7
+ static flags: {
8
+ watch: _oclif_core_interfaces0.BooleanFlag<boolean>;
9
+ };
10
+ static examples: {
11
+ description: string;
12
+ command: string;
13
+ }[];
14
+ run(): Promise<void>;
15
+ }
16
+ //#endregion
17
+ //#region src/index.d.ts
18
+ declare const commands: {
19
+ 'build:react': typeof ReactBuildCommand;
20
+ };
21
+ //#endregion
22
+ export { commands };
23
+ //# sourceMappingURL=index.d.mts.map
package/dist/index.mjs ADDED
@@ -0,0 +1,59 @@
1
+ import { Command } from "@jpp-toolkit/core";
2
+ import { createReactRspackConfig } from "@jpp-toolkit/rspack-config";
3
+ import { Flags } from "@oclif/core";
4
+ import { rspack } from "@rspack/core";
5
+ import { RspackDevServer } from "@rspack/dev-server";
6
+
7
+ //#region src/react-build-command.ts
8
+ var ReactBuildCommand = class ReactBuildCommand extends Command {
9
+ static summary = "Build React project using Rspack.";
10
+ static flags = { watch: Flags.boolean({
11
+ char: "w",
12
+ description: "Watch files for changes and rebuild automatically.",
13
+ default: false
14
+ }) };
15
+ static examples = [{
16
+ description: "Build the React project once.",
17
+ command: "<%= config.bin %> <%= command.id %>"
18
+ }, {
19
+ description: "Build the React project in watch mode.",
20
+ command: "<%= config.bin %> <%= command.id %> --watch"
21
+ }];
22
+ async run() {
23
+ const { flags: { watch } } = await this.parse(ReactBuildCommand);
24
+ const config = createReactRspackConfig(void 0, { isProduction: !watch })({
25
+ RSPACK_BUILD: !watch,
26
+ RSPACK_WATCH: watch
27
+ });
28
+ const compiler = rspack(config);
29
+ const compilerCallback = (err, stats) => {
30
+ if (err) {
31
+ this.logger.error(err.toString());
32
+ return;
33
+ }
34
+ if (!stats) return;
35
+ this.logger.log(stats.toString({
36
+ preset: "normal",
37
+ colors: true
38
+ }), "\n");
39
+ };
40
+ if (watch) {
41
+ const devServerOptions = config.devServer ?? {};
42
+ devServerOptions.hot = true;
43
+ await new RspackDevServer(devServerOptions, compiler).start();
44
+ } else compiler.run((error, stats) => {
45
+ compiler.close((closeErr) => {
46
+ if (closeErr) this.logger.error(closeErr.toString());
47
+ compilerCallback(error, stats);
48
+ });
49
+ });
50
+ }
51
+ };
52
+
53
+ //#endregion
54
+ //#region src/index.ts
55
+ const commands = { "build:react": ReactBuildCommand };
56
+
57
+ //#endregion
58
+ export { commands };
59
+ //# sourceMappingURL=index.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.mjs","names":[],"sources":["../src/react-build-command.ts","../src/index.ts"],"sourcesContent":["import { Command } from '@jpp-toolkit/core';\nimport { createReactRspackConfig } from '@jpp-toolkit/rspack-config';\nimport { Flags } from '@oclif/core';\nimport type { MultiStats, Stats } from '@rspack/core';\nimport { rspack } from '@rspack/core';\nimport { RspackDevServer } from '@rspack/dev-server';\n\nexport class ReactBuildCommand extends Command {\n static override summary = 'Build React project using Rspack.';\n\n static override flags = {\n watch: Flags.boolean({\n char: 'w',\n description: 'Watch files for changes and rebuild automatically.',\n default: false,\n }),\n };\n\n static override examples = [\n {\n description: 'Build the React project once.',\n command: '<%= config.bin %> <%= command.id %>',\n },\n {\n description: 'Build the React project in watch mode.',\n command: '<%= config.bin %> <%= command.id %> --watch',\n },\n ];\n\n public async run(): Promise<void> {\n const {\n flags: { watch },\n } = await this.parse(ReactBuildCommand);\n\n const config = createReactRspackConfig(undefined, {\n isProduction: !watch,\n })({\n RSPACK_BUILD: !watch,\n RSPACK_WATCH: watch,\n });\n const compiler = rspack(config);\n\n const compilerCallback = (err: Error | null, stats: Stats | MultiStats | undefined) => {\n if (err) {\n this.logger.error(err.toString());\n return;\n }\n if (!stats) return;\n this.logger.log(stats.toString({ preset: 'normal', colors: true }), '\\n');\n };\n\n if (watch) {\n const devServerOptions = config.devServer ?? {};\n devServerOptions.hot = true;\n const devServer = new RspackDevServer(devServerOptions, compiler);\n await devServer.start();\n } else {\n compiler.run((error: Error | null, stats: Stats | MultiStats | undefined) => {\n compiler.close((closeErr) => {\n if (closeErr) this.logger.error(closeErr.toString());\n compilerCallback(error, stats);\n });\n });\n }\n }\n}\n","import { ReactBuildCommand } from './react-build-command';\n\nexport const commands = {\n 'build:react': ReactBuildCommand,\n};\n"],"mappings":";;;;;;;AAOA,IAAa,oBAAb,MAAa,0BAA0B,QAAQ;CAC3C,OAAgB,UAAU;CAE1B,OAAgB,QAAQ,EACpB,OAAO,MAAM,QAAQ;EACjB,MAAM;EACN,aAAa;EACb,SAAS;EACZ,CAAC,EACL;CAED,OAAgB,WAAW,CACvB;EACI,aAAa;EACb,SAAS;EACZ,EACD;EACI,aAAa;EACb,SAAS;EACZ,CACJ;CAED,MAAa,MAAqB;EAC9B,MAAM,EACF,OAAO,EAAE,YACT,MAAM,KAAK,MAAM,kBAAkB;EAEvC,MAAM,SAAS,wBAAwB,QAAW,EAC9C,cAAc,CAAC,OAClB,CAAC,CAAC;GACC,cAAc,CAAC;GACf,cAAc;GACjB,CAAC;EACF,MAAM,WAAW,OAAO,OAAO;EAE/B,MAAM,oBAAoB,KAAmB,UAA0C;AACnF,OAAI,KAAK;AACL,SAAK,OAAO,MAAM,IAAI,UAAU,CAAC;AACjC;;AAEJ,OAAI,CAAC,MAAO;AACZ,QAAK,OAAO,IAAI,MAAM,SAAS;IAAE,QAAQ;IAAU,QAAQ;IAAM,CAAC,EAAE,KAAK;;AAG7E,MAAI,OAAO;GACP,MAAM,mBAAmB,OAAO,aAAa,EAAE;AAC/C,oBAAiB,MAAM;AAEvB,SADkB,IAAI,gBAAgB,kBAAkB,SAAS,CACjD,OAAO;QAEvB,UAAS,KAAK,OAAqB,UAA0C;AACzE,YAAS,OAAO,aAAa;AACzB,QAAI,SAAU,MAAK,OAAO,MAAM,SAAS,UAAU,CAAC;AACpD,qBAAiB,OAAO,MAAM;KAChC;IACJ;;;;;;AC5Dd,MAAa,WAAW,EACpB,eAAe,mBAClB"}
@@ -0,0 +1,13 @@
1
+ export default {
2
+ description: 'Plugin that add the react build command to the jpp cli.',
3
+ commands: {
4
+ strategy: 'explicit',
5
+ target: './dist/index.mjs',
6
+ identifier: 'commands',
7
+ },
8
+ topics: {
9
+ build: {
10
+ description: 'Commands for building code.',
11
+ },
12
+ },
13
+ };
@@ -0,0 +1,36 @@
1
+ {
2
+ "commands": {
3
+ "build:react": {
4
+ "aliases": [],
5
+ "args": {},
6
+ "examples": [
7
+ {
8
+ "description": "Build the React project once.",
9
+ "command": "<%= config.bin %> <%= command.id %>"
10
+ },
11
+ {
12
+ "description": "Build the React project in watch mode.",
13
+ "command": "<%= config.bin %> <%= command.id %> --watch"
14
+ }
15
+ ],
16
+ "flags": {
17
+ "watch": {
18
+ "char": "w",
19
+ "description": "Watch files for changes and rebuild automatically.",
20
+ "name": "watch",
21
+ "allowNo": false,
22
+ "type": "boolean"
23
+ }
24
+ },
25
+ "hasDynamicHelp": false,
26
+ "hiddenAliases": [],
27
+ "id": "build:react",
28
+ "pluginAlias": "@jpp-toolkit/plugin-build-react",
29
+ "pluginName": "@jpp-toolkit/plugin-build-react",
30
+ "pluginType": "core",
31
+ "strict": true,
32
+ "summary": "Build React project using Rspack."
33
+ }
34
+ },
35
+ "version": "0.0.3"
36
+ }
package/package.json ADDED
@@ -0,0 +1,61 @@
1
+ {
2
+ "name": "@jpp-toolkit/plugin-build-react",
3
+ "version": "0.0.3",
4
+ "description": "Plugin that add the react build command to the jpp cli.",
5
+ "keywords": [
6
+ "jpp",
7
+ "plugin",
8
+ "build",
9
+ "react"
10
+ ],
11
+ "homepage": "https://github.com/jpapini/jpp-toolkit/tree/main/packages/plugin-build-react#readme",
12
+ "bugs": {
13
+ "url": "https://github.com/jpapini/jpp-toolkit/issues"
14
+ },
15
+ "repository": {
16
+ "type": "git",
17
+ "url": "git+https://github.com/jpapini/jpp-toolkit.git",
18
+ "directory": "packages/plugin-build-react"
19
+ },
20
+ "license": "MIT",
21
+ "author": "Julien Papini <julien.papini@gmail.com> (https://github.com/jpapini)",
22
+ "type": "module",
23
+ "exports": {
24
+ ".": {
25
+ "types": "./dist/index.d.mts",
26
+ "default": "./dist/index.mjs"
27
+ },
28
+ "./package.json": "./package.json"
29
+ },
30
+ "files": [
31
+ "dist",
32
+ "src",
33
+ "oclif.config.js",
34
+ "oclif.manifest.json"
35
+ ],
36
+ "dependencies": {
37
+ "@oclif/core": "4.8.0",
38
+ "@rspack/core": "1.7.2",
39
+ "@rspack/dev-server": "1.1.5",
40
+ "@jpp-toolkit/core": "0.0.23",
41
+ "@jpp-toolkit/rspack-config": "0.0.19"
42
+ },
43
+ "devDependencies": {
44
+ "oclif": "4.22.67"
45
+ },
46
+ "engines": {
47
+ "node": "24",
48
+ "pnpm": "10"
49
+ },
50
+ "volta": {
51
+ "extends": "../../package.json"
52
+ },
53
+ "publishConfig": {
54
+ "access": "public"
55
+ },
56
+ "scripts": {
57
+ "typecheck": "tsc --noEmit --pretty",
58
+ "dev": "build-lib --watch",
59
+ "build": "build-lib"
60
+ }
61
+ }
package/src/index.ts ADDED
@@ -0,0 +1,5 @@
1
+ import { ReactBuildCommand } from './react-build-command';
2
+
3
+ export const commands = {
4
+ 'build:react': ReactBuildCommand,
5
+ };
@@ -0,0 +1,66 @@
1
+ import { Command } from '@jpp-toolkit/core';
2
+ import { createReactRspackConfig } from '@jpp-toolkit/rspack-config';
3
+ import { Flags } from '@oclif/core';
4
+ import type { MultiStats, Stats } from '@rspack/core';
5
+ import { rspack } from '@rspack/core';
6
+ import { RspackDevServer } from '@rspack/dev-server';
7
+
8
+ export class ReactBuildCommand extends Command {
9
+ static override summary = 'Build React project using Rspack.';
10
+
11
+ static override flags = {
12
+ watch: Flags.boolean({
13
+ char: 'w',
14
+ description: 'Watch files for changes and rebuild automatically.',
15
+ default: false,
16
+ }),
17
+ };
18
+
19
+ static override examples = [
20
+ {
21
+ description: 'Build the React project once.',
22
+ command: '<%= config.bin %> <%= command.id %>',
23
+ },
24
+ {
25
+ description: 'Build the React project in watch mode.',
26
+ command: '<%= config.bin %> <%= command.id %> --watch',
27
+ },
28
+ ];
29
+
30
+ public async run(): Promise<void> {
31
+ const {
32
+ flags: { watch },
33
+ } = await this.parse(ReactBuildCommand);
34
+
35
+ const config = createReactRspackConfig(undefined, {
36
+ isProduction: !watch,
37
+ })({
38
+ RSPACK_BUILD: !watch,
39
+ RSPACK_WATCH: watch,
40
+ });
41
+ const compiler = rspack(config);
42
+
43
+ const compilerCallback = (err: Error | null, stats: Stats | MultiStats | undefined) => {
44
+ if (err) {
45
+ this.logger.error(err.toString());
46
+ return;
47
+ }
48
+ if (!stats) return;
49
+ this.logger.log(stats.toString({ preset: 'normal', colors: true }), '\n');
50
+ };
51
+
52
+ if (watch) {
53
+ const devServerOptions = config.devServer ?? {};
54
+ devServerOptions.hot = true;
55
+ const devServer = new RspackDevServer(devServerOptions, compiler);
56
+ await devServer.start();
57
+ } else {
58
+ compiler.run((error: Error | null, stats: Stats | MultiStats | undefined) => {
59
+ compiler.close((closeErr) => {
60
+ if (closeErr) this.logger.error(closeErr.toString());
61
+ compilerCallback(error, stats);
62
+ });
63
+ });
64
+ }
65
+ }
66
+ }