@tdk-landscape/tdk-cli-core 1.3.74 → 1.3.76

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.
@@ -0,0 +1,126 @@
1
+ # React-specific Vite templates for frontend resources.
2
+
3
+ REACT_VITE_FRONTEND = """{header}
4
+ import {{ resolve }} from 'node:path';
5
+ import react from '@vitejs/plugin-react';
6
+ import {{ defineConfig }} from 'vite';
7
+
8
+ export default defineConfig({{
9
+ base: '{base_path}',
10
+ build: {{
11
+ cssCodeSplit: false,
12
+ minify: false,
13
+ modulePreload: false,
14
+ rollupOptions: {{
15
+ output: {{
16
+ entryFileNames: '[name].js',
17
+ format: 'esm',
18
+ }},
19
+ }},
20
+ target: 'esnext',
21
+ }},
22
+ define: {{
23
+ global: 'globalThis',
24
+ }},
25
+ optimizeDeps: {{
26
+ include: [{optimize_deps_include}],
27
+ }},
28
+ plugins: [react()],
29
+ preview: {{
30
+ host: '0.0.0.0',
31
+ port: {port},
32
+ }},
33
+ resolve: {{
34
+ alias: {{
35
+ // 🎯 IMPORTANT: Order matters! More specific aliases must come FIRST
36
+ '@/autogenerated': resolve(__dirname),
37
+ '@': resolve(__dirname, '../src'),
38
+ 'set-cookie-parser': resolve(__dirname, '../src/utils/empty-module.js'),
39
+ {internal_aliases}
40
+ }},
41
+ }},
42
+ server: {{
43
+ host: '0.0.0.0',
44
+ port: {port},
45
+ hmr: {{
46
+ port: {hmr_port},
47
+ }},
48
+ {proxy_config}
49
+ }},
50
+ }});
51
+ """
52
+
53
+ REACT_VITE_FRONTEND_BUILD = """{header}
54
+ import {{ resolve }} from 'node:path';
55
+ import react from '@vitejs/plugin-react';
56
+ import {{ defineConfig }} from 'vite';
57
+
58
+ export default defineConfig({{
59
+ mode: 'production',
60
+ base: '{base_path}',
61
+ build: {{
62
+ cssCodeSplit: false,
63
+ minify: true,
64
+ modulePreload: false,
65
+ rollupOptions: {{
66
+ output: {{
67
+ entryFileNames: '[name].js',
68
+ format: 'esm',
69
+ // Inline all node_modules to prevent lazy dynamic imports for CJS modules
70
+ manualChunks: undefined,
71
+ }},
72
+ }},
73
+ target: 'esnext',
74
+ }},
75
+ define: {{
76
+ global: 'globalThis',
77
+ __DEV__: 'false',
78
+ 'process.env.NODE_ENV': '"production"',
79
+ }},
80
+ esbuild: {{
81
+ // Force production JSX runtime
82
+ jsx: 'automatic',
83
+ jsxImportSource: 'react',
84
+ // CRITICAL: Disable development JSX (jsxDEV) for Vite 8 + Rolldown compatibility
85
+ jsxDev: false,
86
+ }},
87
+ optimizeDeps: {{
88
+ include: [
89
+ 'react',
90
+ 'react-dom',
91
+ 'react-dom/client',
92
+ 'react/jsx-runtime',
93
+ '@tanstack/react-query',
94
+ // Internal packages (auto-generated)
95
+ {optimize_deps_include}
96
+ ],
97
+ esbuildOptions: {{
98
+ format: 'esm',
99
+ target: 'esnext',
100
+ // Use production JSX runtime
101
+ jsx: 'automatic',
102
+ jsxImportSource: 'react',
103
+ jsxDev: false,
104
+ }},
105
+ }},
106
+ plugins: [
107
+ react({{
108
+ // Force automatic JSX runtime in production mode
109
+ jsxRuntime: 'automatic',
110
+ jsxImportSource: 'react',
111
+ }}),
112
+ ],
113
+ resolve: {{
114
+ alias: {{
115
+ // 🎯 IMPORTANT: Order matters! More specific aliases must come FIRST
116
+ '@/autogenerated': resolve(__dirname),
117
+ '@': resolve(__dirname, '../src'),
118
+ 'set-cookie-parser': resolve(__dirname, '../src/utils/empty-module.js'),
119
+ // Force production JSX runtime - alias dev runtime to production runtime
120
+ 'react/jsx-dev-runtime': 'react/jsx-runtime',
121
+ }},
122
+ conditions: ['browser', 'import', 'module', 'es2020', 'default'],
123
+ mainFields: ['browser', 'module', 'jsnext:main', 'jsnext', 'main'],
124
+ }},
125
+ }});
126
+ """
@@ -0,0 +1,92 @@
1
+ # Vue-specific Vite templates for frontend resources.
2
+
3
+ VUE_VITE_FRONTEND = """{header}
4
+ import {{ resolve }} from 'node:path';
5
+ import vue from '@vitejs/plugin-vue';
6
+ import {{ defineConfig }} from 'vite';
7
+
8
+ export default defineConfig({{
9
+ base: '{base_path}',
10
+ build: {{
11
+ cssCodeSplit: false,
12
+ minify: false,
13
+ modulePreload: false,
14
+ rollupOptions: {{
15
+ output: {{
16
+ entryFileNames: '[name].js',
17
+ format: 'esm',
18
+ }},
19
+ }},
20
+ target: 'esnext',
21
+ }},
22
+ define: {{
23
+ global: 'globalThis',
24
+ }},
25
+ optimizeDeps: {{
26
+ include: [{optimize_deps_include}],
27
+ }},
28
+ plugins: [vue()],
29
+ preview: {{
30
+ host: '0.0.0.0',
31
+ port: {port},
32
+ }},
33
+ resolve: {{
34
+ alias: {{
35
+ '@/autogenerated': resolve(__dirname),
36
+ '@': resolve(__dirname, '../src'),
37
+ 'set-cookie-parser': resolve(__dirname, '../src/utils/empty-module.js'),
38
+ {internal_aliases}
39
+ }},
40
+ }},
41
+ server: {{
42
+ host: '0.0.0.0',
43
+ port: {port},
44
+ hmr: {{
45
+ port: {hmr_port},
46
+ }},
47
+ {proxy_config}
48
+ }},
49
+ }});
50
+ """
51
+
52
+ VUE_VITE_FRONTEND_BUILD = """{header}
53
+ import {{ resolve }} from 'node:path';
54
+ import vue from '@vitejs/plugin-vue';
55
+ import {{ defineConfig }} from 'vite';
56
+
57
+ export default defineConfig({{
58
+ mode: 'production',
59
+ base: '{base_path}',
60
+ build: {{
61
+ cssCodeSplit: false,
62
+ minify: true,
63
+ modulePreload: false,
64
+ rollupOptions: {{
65
+ output: {{
66
+ entryFileNames: '[name].js',
67
+ format: 'esm',
68
+ manualChunks: undefined,
69
+ }},
70
+ }},
71
+ target: 'esnext',
72
+ }},
73
+ define: {{
74
+ global: 'globalThis',
75
+ __DEV__: 'false',
76
+ 'process.env.NODE_ENV': '"production"',
77
+ }},
78
+ optimizeDeps: {{
79
+ include: [{optimize_deps_include}],
80
+ }},
81
+ plugins: [vue()],
82
+ resolve: {{
83
+ alias: {{
84
+ '@/autogenerated': resolve(__dirname),
85
+ '@': resolve(__dirname, '../src'),
86
+ 'set-cookie-parser': resolve(__dirname, '../src/utils/empty-module.js'),
87
+ }},
88
+ conditions: ['browser', 'import', 'module', 'es2020', 'default'],
89
+ mainFields: ['browser', 'module', 'jsnext:main', 'jsnext', 'main'],
90
+ }},
91
+ }});
92
+ """
@@ -15,7 +15,8 @@ load('../../../../topologies/tilt/manifest/constants.star', 'GENERATED_CONFIG_FI
15
15
  # =============================================================================
16
16
 
17
17
 
18
- load('./templates.star', 'TEMPLATE_VITE_FRONTEND', 'TEMPLATE_VITE_FRONTEND_BUILD')
18
+ load('./frameworks/react.star', 'REACT_VITE_FRONTEND', 'REACT_VITE_FRONTEND_BUILD')
19
+ load('./frameworks/vue.star', 'VUE_VITE_FRONTEND', 'VUE_VITE_FRONTEND_BUILD')
19
20
  load('../../../platform/docker/networking/api_path_constants.star', 'get_frontend_base_path')
20
21
  load('./helpers.star',
21
22
  'build_header',
@@ -28,6 +29,17 @@ load('./helpers.star',
28
29
  VITE_FRONTEND_CONFIG_PATH = '/' + OUTPUT.AUTOGENERATED_FOLDER + '/' + GENERATED_CONFIG_FILENAMES['vite_frontend']
29
30
  VITE_FRONTEND_BUILD_CONFIG_PATH = '/' + OUTPUT.AUTOGENERATED_FOLDER + '/' + GENERATED_CONFIG_FILENAMES['vite_build']
30
31
 
32
+ _FRAMEWORK_TEMPLATES = {
33
+ 'react': {
34
+ 'dev': REACT_VITE_FRONTEND,
35
+ 'build': REACT_VITE_FRONTEND_BUILD,
36
+ },
37
+ 'vue': {
38
+ 'dev': VUE_VITE_FRONTEND,
39
+ 'build': VUE_VITE_FRONTEND_BUILD,
40
+ },
41
+ }
42
+
31
43
  def _normalize_vite_base_path(base_path):
32
44
  """Vite subpath deploys are more reliable with a trailing slash."""
33
45
  if not base_path:
@@ -40,7 +52,7 @@ def _normalize_vite_base_path(base_path):
40
52
 
41
53
  def generate_frontend(manifest, backend_manifest=None, write_fn=None):
42
54
  """
43
- Generate vite.config.ts for FRONTEND services.
55
+ Generate dev and build Vite configs under the resource's .autogenerated/ directory.
44
56
 
45
57
  Features:
46
58
  - Auto-proxy to backend based on backend manifest port
@@ -52,6 +64,11 @@ def generate_frontend(manifest, backend_manifest=None, write_fn=None):
52
64
  """
53
65
  if manifest.get('appType') != 'frontend':
54
66
  fail("Vite.frontend() requires a frontend manifest, got: " + manifest.get('appType', 'unknown'))
67
+
68
+ framework_id = manifest.get('framework', 'react')
69
+ framework_templates = _FRAMEWORK_TEMPLATES.get(framework_id)
70
+ if framework_templates == None:
71
+ fail("Unknown frontend framework for Vite generation: " + str(framework_id))
55
72
 
56
73
  resource_path = manifest.get('_resource_path', '')
57
74
  stack = manifest.get('stack', 'app')
@@ -75,7 +92,7 @@ def generate_frontend(manifest, backend_manifest=None, write_fn=None):
75
92
  internal_aliases = generate_frontend_internal_aliases(resource_path, manifest, 1)
76
93
  optimize_deps_include = generate_frontend_optimize_deps(manifest)
77
94
 
78
- config = TEMPLATE_VITE_FRONTEND.format(
95
+ config = framework_templates['dev'].format(
79
96
  header=header,
80
97
  base_path=vite_base_path,
81
98
  port=port,
@@ -86,7 +103,7 @@ def generate_frontend(manifest, backend_manifest=None, write_fn=None):
86
103
  )
87
104
 
88
105
  build_cfg_header = build_header('Vite.frontend()', app_name, 'Build-only Vite config')
89
- build_config = TEMPLATE_VITE_FRONTEND_BUILD.format(
106
+ build_config = framework_templates['build'].format(
90
107
  header=build_cfg_header,
91
108
  base_path=vite_base_path,
92
109
  optimize_deps_include=optimize_deps_include,
@@ -20,131 +20,6 @@ def _load_npm_scope():
20
20
 
21
21
  _NPM_SCOPE = _load_npm_scope()
22
22
 
23
- TEMPLATE_VITE_FRONTEND = """{header}
24
- import {{ resolve }} from 'node:path';
25
- import react from '@vitejs/plugin-react';
26
- import {{ defineConfig }} from 'vite';
27
-
28
- export default defineConfig({{
29
- base: '{base_path}',
30
- build: {{
31
- cssCodeSplit: false,
32
- minify: false,
33
- modulePreload: false,
34
- rollupOptions: {{
35
- output: {{
36
- entryFileNames: '[name].js',
37
- format: 'esm',
38
- }},
39
- }},
40
- target: 'esnext',
41
- }},
42
- define: {{
43
- global: 'globalThis',
44
- }},
45
- optimizeDeps: {{
46
- include: [{optimize_deps_include}],
47
- }},
48
- plugins: [react()],
49
- preview: {{
50
- host: '0.0.0.0',
51
- port: {port},
52
- }},
53
- resolve: {{
54
- alias: {{
55
- // 🎯 IMPORTANT: Order matters! More specific aliases must come FIRST
56
- '@/autogenerated': resolve(__dirname),
57
- '@': resolve(__dirname, '../src'),
58
- 'set-cookie-parser': resolve(__dirname, '../src/utils/empty-module.js'),
59
- {internal_aliases}
60
- }},
61
- }},
62
- server: {{
63
- host: '0.0.0.0',
64
- port: {port},
65
- hmr: {{
66
- port: {hmr_port},
67
- }},
68
- {proxy_config}
69
- }},
70
- }});
71
- """
72
-
73
- TEMPLATE_VITE_FRONTEND_BUILD = """{header}
74
- import {{ resolve }} from 'node:path';
75
- import react from '@vitejs/plugin-react';
76
- import {{ defineConfig }} from 'vite';
77
-
78
- export default defineConfig({{
79
- mode: 'production',
80
- base: '{base_path}',
81
- build: {{
82
- cssCodeSplit: false,
83
- minify: true,
84
- modulePreload: false,
85
- rollupOptions: {{
86
- output: {{
87
- entryFileNames: '[name].js',
88
- format: 'esm',
89
- // Inline all node_modules to prevent lazy dynamic imports for CJS modules
90
- manualChunks: undefined,
91
- }},
92
- }},
93
- target: 'esnext',
94
- }},
95
- define: {{
96
- global: 'globalThis',
97
- __DEV__: 'false',
98
- 'process.env.NODE_ENV': '"production"',
99
- }},
100
- esbuild: {{
101
- // Force production JSX runtime
102
- jsx: 'automatic',
103
- jsxImportSource: 'react',
104
- // CRITICAL: Disable development JSX (jsxDEV) for Vite 8 + Rolldown compatibility
105
- jsxDev: false,
106
- }},
107
- optimizeDeps: {{
108
- include: [
109
- 'react',
110
- 'react-dom',
111
- 'react-dom/client',
112
- 'react/jsx-runtime',
113
- '@tanstack/react-query',
114
- // Internal packages (auto-generated)
115
- {optimize_deps_include}
116
- ],
117
- esbuildOptions: {{
118
- format: 'esm',
119
- target: 'esnext',
120
- // Use production JSX runtime
121
- jsx: 'automatic',
122
- jsxImportSource: 'react',
123
- jsxDev: false,
124
- }},
125
- }},
126
- plugins: [
127
- react({{
128
- // Force automatic JSX runtime in production mode
129
- jsxRuntime: 'automatic',
130
- jsxImportSource: 'react',
131
- }}),
132
- ],
133
- resolve: {{
134
- alias: {{
135
- // 🎯 IMPORTANT: Order matters! More specific aliases must come FIRST
136
- '@/autogenerated': resolve(__dirname),
137
- '@': resolve(__dirname, '../src'),
138
- 'set-cookie-parser': resolve(__dirname, '../src/utils/empty-module.js'),
139
- // Force production JSX runtime - alias dev runtime to production runtime
140
- 'react/jsx-dev-runtime': 'react/jsx-runtime',
141
- }},
142
- conditions: ['browser', 'import', 'module', 'es2020', 'default'],
143
- mainFields: ['browser', 'module', 'jsnext:main', 'jsnext', 'main'],
144
- }},
145
- }});
146
- """
147
-
148
23
  TEMPLATE_VITE_BACKEND_WITH_NODE = """{header}
149
24
  import path from 'node:path';
150
25
  import {{ VitePluginNode }} from 'vite-plugin-node';
@@ -555,137 +430,6 @@ export default defineConfig({{
555
430
  }});
556
431
  """
557
432
 
558
- TEMPLATE_VITE_FRONTEND_DEV = """{header}
559
- import {{ resolve }} from 'node:path';
560
- import react from '@vitejs/plugin-react';
561
- import {{ defineConfig }} from 'vite';
562
-
563
- export default defineConfig({{
564
- mode: 'development',
565
- base: '{base_path}',
566
- build: {{
567
- cssCodeSplit: false,
568
- minify: false,
569
- modulePreload: false,
570
- rollupOptions: {{
571
- output: {{
572
- entryFileNames: '[name].js',
573
- format: 'esm',
574
- }},
575
- }},
576
- target: 'esnext',
577
- }},
578
- define: {{
579
- global: 'globalThis',
580
- __DEV__: 'true',
581
- 'process.env.NODE_ENV': '"development"',
582
- }},
583
- optimizeDeps: {{
584
- include: [
585
- 'react',
586
- 'react-dom',
587
- 'react-dom/client',
588
- 'react/jsx-runtime',
589
- '@tanstack/react-query',
590
- {optimize_deps_include}
591
- ],
592
- }},
593
- plugins: [
594
- react({{
595
- jsxRuntime: 'automatic',
596
- }}),
597
- ],
598
- preview: {{
599
- host: '0.0.0.0',
600
- port: {port},
601
- }},
602
- resolve: {{
603
- alias: {{
604
- // 🎯 IMPORTANT: Order matters! More specific aliases must come FIRST
605
- '@/autogenerated': resolve(__dirname),
606
- '@': resolve(__dirname, '../src'),
607
- 'set-cookie-parser': resolve(__dirname, '../src/utils/empty-module.js'),
608
- }},
609
- }},
610
- server: {{
611
- host: '0.0.0.0',
612
- port: {port},
613
- hmr: {{
614
- port: {hmr_port},
615
- }},
616
- {proxy_config}
617
- }},
618
- }});
619
- """
620
-
621
- TEMPLATE_VITE_FRONTEND_PROD = """{header}
622
- import {{ resolve }} from 'node:path';
623
- import react from '@vitejs/plugin-react';
624
- import {{ defineConfig }} from 'vite';
625
-
626
- export default defineConfig({{
627
- mode: 'production',
628
- base: '{base_path}',
629
- build: {{
630
- cssCodeSplit: false,
631
- minify: true,
632
- modulePreload: false,
633
- rollupOptions: {{
634
- output: {{
635
- entryFileNames: '[name].js',
636
- format: 'esm',
637
- manualChunks: undefined,
638
- }},
639
- }},
640
- target: 'esnext',
641
- }},
642
- define: {{
643
- global: 'globalThis',
644
- __DEV__: 'false',
645
- 'process.env.NODE_ENV': '"production"',
646
- }},
647
- esbuild: {{
648
- jsx: 'automatic',
649
- jsxImportSource: 'react',
650
- jsxDev: false,
651
- }},
652
- optimizeDeps: {{
653
- include: [
654
- 'react',
655
- 'react-dom',
656
- 'react-dom/client',
657
- 'react/jsx-runtime',
658
- '@tanstack/react-query',
659
- {optimize_deps_include}
660
- ],
661
- esbuildOptions: {{
662
- format: 'esm',
663
- target: 'esnext',
664
- jsx: 'automatic',
665
- jsxImportSource: 'react',
666
- jsxDev: false,
667
- }},
668
- }},
669
- plugins: [
670
- react({{
671
- jsxRuntime: 'automatic',
672
- jsxImportSource: 'react',
673
- }}),
674
- ],
675
- resolve: {{
676
- alias: {{
677
- // 🎯 IMPORTANT: Order matters! More specific aliases must come FIRST
678
- '@/autogenerated': resolve(__dirname),
679
- '@': resolve(__dirname, '../src'),
680
- 'set-cookie-parser': resolve(__dirname, '../src/utils/empty-module.js'),
681
- 'react/jsx-dev-runtime': 'react/jsx-runtime',
682
- }},
683
- conditions: ['browser', 'import', 'module', 'es2020', 'default'],
684
- mainFields: ['browser', 'module', 'jsnext:main', 'jsnext', 'main'],
685
- }},
686
- }});
687
- """
688
-
689
433
  # =============================================================================
690
434
  # Template Generation Functions
691
435
  # =============================================================================
@@ -708,30 +452,3 @@ def get_library_template(environment = 'production'):
708
452
  else:
709
453
  # Default to production for safety
710
454
  return TEMPLATE_VITE_LIBRARY_PROD
711
-
712
- def get_frontend_template(environment = 'production'):
713
- """
714
- Get the appropriate frontend template based on environment.
715
-
716
- Args:
717
- environment: 'development', 'production', or 'dev'/'prod' shortcuts
718
-
719
- Returns:
720
- Template string for the specified environment
721
- """
722
- env = environment.lower()
723
- if env in ['development', 'dev']:
724
- return TEMPLATE_VITE_FRONTEND_DEV
725
- elif env in ['production', 'prod']:
726
- return TEMPLATE_VITE_FRONTEND_PROD
727
- else:
728
- # Default to production for safety
729
- return TEMPLATE_VITE_FRONTEND_PROD
730
-
731
- def get_frontend_build_template(environment = 'production'):
732
- """
733
- Get the appropriate frontend build template based on environment.
734
-
735
- This is an alias for get_frontend_template since they serve the same purpose.
736
- """
737
- return get_frontend_template(environment)
@@ -400,10 +400,16 @@ def _generate_all_configs_for_resource(
400
400
  # Docker builds: Resolve from node_modules (packages must be published)
401
401
 
402
402
  # Docker tsconfig: NO path aliases to internal deps
403
- TSConfig.frontend(resource_path, write_file, internal_deps=None, is_docker=True)
403
+ TSConfig.frontend(
404
+ resource_path, write_file, internal_deps=None, is_docker=True,
405
+ framework=manifest.get('framework', 'react'),
406
+ )
404
407
 
405
408
  # Local tsconfig: CAN use path aliases to internal deps
406
- TSConfig.frontend(resource_path, write_file, internal_deps=internal_deps_map, is_docker=False)
409
+ TSConfig.frontend(
410
+ resource_path, write_file, internal_deps=internal_deps_map, is_docker=False,
411
+ framework=manifest.get('framework', 'react'),
412
+ )
407
413
  else:
408
414
  prisma_path = resource_config.get('prisma_client_path', './node_modules/.prisma/client')
409
415
  resource_features = manifest.get('featuresEnabled', [])
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tdk-landscape/tdk-cli-core",
3
- "version": "1.3.74",
3
+ "version": "1.3.76",
4
4
  "description": "Run your whole microservice landscape locally without Kubernetes. Scaffold services and run them with hot reload, built on Tilt.",
5
5
  "homepage": "https://tdk-landscape.github.io/tdk-website",
6
6
  "repository": {