@nestjs-ssr/react 0.3.16 → 0.3.18

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/dist/cli/init.js CHANGED
@@ -9,6 +9,75 @@ var consola = require('consola');
9
9
  var citty = require('citty');
10
10
 
11
11
  var _documentCurrentScript = typeof document !== 'undefined' ? document.currentScript : null;
12
+ var __defProp = Object.defineProperty;
13
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
14
+
15
+ // src/cli/swc-support.ts
16
+ var TSX_EXTENSIONS = [
17
+ ".js",
18
+ ".ts",
19
+ ".tsx"
20
+ ];
21
+ function configureNestCliForSwc(nestCli) {
22
+ const builder = nestCli.compilerOptions?.builder;
23
+ const usesSwc = builder === "swc" || typeof builder === "object" && builder !== null && builder.type === "swc";
24
+ if (!usesSwc || !nestCli.compilerOptions) {
25
+ return {
26
+ usesSwc,
27
+ updatedNestCli: null
28
+ };
29
+ }
30
+ const result = structuredClone(nestCli);
31
+ if (typeof builder === "string") {
32
+ result.compilerOptions.builder = {
33
+ type: "swc",
34
+ options: {
35
+ extensions: TSX_EXTENSIONS
36
+ }
37
+ };
38
+ return {
39
+ usesSwc,
40
+ updatedNestCli: result
41
+ };
42
+ }
43
+ const existing = builder.options?.extensions;
44
+ if (existing && existing.includes(".tsx")) {
45
+ return {
46
+ usesSwc,
47
+ updatedNestCli: null
48
+ };
49
+ }
50
+ const builderObj = result.compilerOptions.builder;
51
+ if (!builderObj.options) {
52
+ builderObj.options = {};
53
+ }
54
+ builderObj.options.extensions = TSX_EXTENSIONS;
55
+ return {
56
+ usesSwc,
57
+ updatedNestCli: result
58
+ };
59
+ }
60
+ __name(configureNestCliForSwc, "configureNestCliForSwc");
61
+ function getSwcRcConfig() {
62
+ return {
63
+ jsc: {
64
+ parser: {
65
+ syntax: "typescript",
66
+ tsx: true,
67
+ decorators: true,
68
+ dynamicImport: true
69
+ },
70
+ transform: {
71
+ react: {
72
+ runtime: "automatic"
73
+ }
74
+ }
75
+ }
76
+ };
77
+ }
78
+ __name(getSwcRcConfig, "getSwcRcConfig");
79
+
80
+ // src/cli/init.ts
12
81
  var __filename$1 = url.fileURLToPath((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('init.js', document.baseURI).href)));
13
82
  var __dirname$1 = path.dirname(__filename$1);
14
83
  var main = citty.defineCommand({
@@ -277,6 +346,7 @@ export default defineConfig({
277
346
  }
278
347
  consola.consola.start("Configuring nest-cli.json...");
279
348
  const nestCliPath = path.join(cwd, "nest-cli.json");
349
+ let usesSwc = false;
280
350
  try {
281
351
  if (fs.existsSync(nestCliPath)) {
282
352
  const nestCli = JSON.parse(fs.readFileSync(nestCliPath, "utf-8"));
@@ -289,8 +359,14 @@ export default defineConfig({
289
359
  nestCli.exclude.push("**/entry-client.tsx");
290
360
  nestUpdated = true;
291
361
  }
362
+ const swcResult = configureNestCliForSwc(nestCli);
363
+ usesSwc = swcResult.usesSwc;
364
+ const configToWrite = swcResult.updatedNestCli ?? nestCli;
365
+ if (swcResult.updatedNestCli) {
366
+ nestUpdated = true;
367
+ }
292
368
  if (nestUpdated) {
293
- fs.writeFileSync(nestCliPath, JSON.stringify(nestCli, null, 2));
369
+ fs.writeFileSync(nestCliPath, JSON.stringify(configToWrite, null, 2));
294
370
  consola.consola.success("Updated nest-cli.json");
295
371
  } else {
296
372
  consola.consola.info("nest-cli.json already configured");
@@ -301,6 +377,16 @@ export default defineConfig({
301
377
  } catch (error) {
302
378
  consola.consola.error("Failed to update nest-cli.json:", error);
303
379
  }
380
+ if (usesSwc) {
381
+ consola.consola.start("Configuring .swcrc for SWC...");
382
+ const swcrcPath = path.join(cwd, ".swcrc");
383
+ if (fs.existsSync(swcrcPath) && !args.force) {
384
+ consola.consola.warn(".swcrc already exists (use --force to overwrite)");
385
+ } else {
386
+ fs.writeFileSync(swcrcPath, JSON.stringify(getSwcRcConfig(), null, 2) + "\n");
387
+ consola.consola.success("Created .swcrc with TSX support");
388
+ }
389
+ }
304
390
  consola.consola.start("Configuring main.ts...");
305
391
  const mainTsPath = path.join(cwd, "src/main.ts");
306
392
  try {
package/dist/cli/init.mjs CHANGED
@@ -6,6 +6,75 @@ import { execSync } from 'child_process';
6
6
  import { consola } from 'consola';
7
7
  import { defineCommand, runMain } from 'citty';
8
8
 
9
+ var __defProp = Object.defineProperty;
10
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
11
+
12
+ // src/cli/swc-support.ts
13
+ var TSX_EXTENSIONS = [
14
+ ".js",
15
+ ".ts",
16
+ ".tsx"
17
+ ];
18
+ function configureNestCliForSwc(nestCli) {
19
+ const builder = nestCli.compilerOptions?.builder;
20
+ const usesSwc = builder === "swc" || typeof builder === "object" && builder !== null && builder.type === "swc";
21
+ if (!usesSwc || !nestCli.compilerOptions) {
22
+ return {
23
+ usesSwc,
24
+ updatedNestCli: null
25
+ };
26
+ }
27
+ const result = structuredClone(nestCli);
28
+ if (typeof builder === "string") {
29
+ result.compilerOptions.builder = {
30
+ type: "swc",
31
+ options: {
32
+ extensions: TSX_EXTENSIONS
33
+ }
34
+ };
35
+ return {
36
+ usesSwc,
37
+ updatedNestCli: result
38
+ };
39
+ }
40
+ const existing = builder.options?.extensions;
41
+ if (existing && existing.includes(".tsx")) {
42
+ return {
43
+ usesSwc,
44
+ updatedNestCli: null
45
+ };
46
+ }
47
+ const builderObj = result.compilerOptions.builder;
48
+ if (!builderObj.options) {
49
+ builderObj.options = {};
50
+ }
51
+ builderObj.options.extensions = TSX_EXTENSIONS;
52
+ return {
53
+ usesSwc,
54
+ updatedNestCli: result
55
+ };
56
+ }
57
+ __name(configureNestCliForSwc, "configureNestCliForSwc");
58
+ function getSwcRcConfig() {
59
+ return {
60
+ jsc: {
61
+ parser: {
62
+ syntax: "typescript",
63
+ tsx: true,
64
+ decorators: true,
65
+ dynamicImport: true
66
+ },
67
+ transform: {
68
+ react: {
69
+ runtime: "automatic"
70
+ }
71
+ }
72
+ }
73
+ };
74
+ }
75
+ __name(getSwcRcConfig, "getSwcRcConfig");
76
+
77
+ // src/cli/init.ts
9
78
  var __filename$1 = fileURLToPath(import.meta.url);
10
79
  var __dirname$1 = dirname(__filename$1);
11
80
  var main = defineCommand({
@@ -274,6 +343,7 @@ export default defineConfig({
274
343
  }
275
344
  consola.start("Configuring nest-cli.json...");
276
345
  const nestCliPath = join(cwd, "nest-cli.json");
346
+ let usesSwc = false;
277
347
  try {
278
348
  if (existsSync(nestCliPath)) {
279
349
  const nestCli = JSON.parse(readFileSync(nestCliPath, "utf-8"));
@@ -286,8 +356,14 @@ export default defineConfig({
286
356
  nestCli.exclude.push("**/entry-client.tsx");
287
357
  nestUpdated = true;
288
358
  }
359
+ const swcResult = configureNestCliForSwc(nestCli);
360
+ usesSwc = swcResult.usesSwc;
361
+ const configToWrite = swcResult.updatedNestCli ?? nestCli;
362
+ if (swcResult.updatedNestCli) {
363
+ nestUpdated = true;
364
+ }
289
365
  if (nestUpdated) {
290
- writeFileSync(nestCliPath, JSON.stringify(nestCli, null, 2));
366
+ writeFileSync(nestCliPath, JSON.stringify(configToWrite, null, 2));
291
367
  consola.success("Updated nest-cli.json");
292
368
  } else {
293
369
  consola.info("nest-cli.json already configured");
@@ -298,6 +374,16 @@ export default defineConfig({
298
374
  } catch (error) {
299
375
  consola.error("Failed to update nest-cli.json:", error);
300
376
  }
377
+ if (usesSwc) {
378
+ consola.start("Configuring .swcrc for SWC...");
379
+ const swcrcPath = join(cwd, ".swcrc");
380
+ if (existsSync(swcrcPath) && !args.force) {
381
+ consola.warn(".swcrc already exists (use --force to overwrite)");
382
+ } else {
383
+ writeFileSync(swcrcPath, JSON.stringify(getSwcRcConfig(), null, 2) + "\n");
384
+ consola.success("Created .swcrc with TSX support");
385
+ }
386
+ }
301
387
  consola.start("Configuring main.ts...");
302
388
  const mainTsPath = join(cwd, "src/main.ts");
303
389
  try {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nestjs-ssr/react",
3
- "version": "0.3.16",
3
+ "version": "0.3.18",
4
4
  "description": "React SSR for NestJS that respects Clean Architecture. Proper DI, SOLID principles, clear separation of concerns.",
5
5
  "keywords": [
6
6
  "nestjs",
@@ -151,6 +151,7 @@
151
151
  "@nestjs/platform-express": "^11.1.17",
152
152
  "@nestjs/testing": "^11.1.17",
153
153
  "@playwright/test": "^1.58.2",
154
+ "@swc/core": "^1.15.21",
154
155
  "@testing-library/jest-dom": "^6.9.1",
155
156
  "@testing-library/react": "^16.3.2",
156
157
  "@types/escape-html": "^1.0.4",
@@ -160,9 +161,9 @@
160
161
  "@types/react-dom": "^19.2.3",
161
162
  "@types/supertest": "^7.2.0",
162
163
  "@vitejs/plugin-react": "^6.0.1",
163
- "@vitest/coverage-v8": "^4.1.0",
164
- "@vitest/ui": "^4.1.0",
165
- "happy-dom": "^20.8.4",
164
+ "@vitest/coverage-v8": "^4.1.2",
165
+ "@vitest/ui": "^4.1.2",
166
+ "happy-dom": "^20.8.9",
166
167
  "react": "^19.2.4",
167
168
  "react-dom": "^19.2.4",
168
169
  "rxjs": "^7.8.2",
@@ -170,7 +171,7 @@
170
171
  "tsup": "^8.5.1",
171
172
  "typescript": "^5.9.3",
172
173
  "vite": "^8.0.1",
173
- "vitest": "^4.1.0"
174
+ "vitest": "^4.1.2"
174
175
  },
175
176
  "publishConfig": {
176
177
  "access": "public"