@nizza/devkit 0.1.0-alpha.0

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 (131) hide show
  1. package/README.md +7 -0
  2. package/dist/package.json +13 -0
  3. package/dist/src/executors/deploy/executor.d.ts +11 -0
  4. package/dist/src/executors/deploy/executor.d.ts.map +1 -0
  5. package/dist/src/executors/deploy/executor.js +27 -0
  6. package/dist/src/executors/deploy/helpers.d.ts +4 -0
  7. package/dist/src/executors/deploy/helpers.d.ts.map +1 -0
  8. package/dist/src/executors/deploy/helpers.js +40 -0
  9. package/dist/src/executors/deploy/schema.json +41 -0
  10. package/dist/src/executors/environments/executor.d.ts +16 -0
  11. package/dist/src/executors/environments/executor.d.ts.map +1 -0
  12. package/dist/src/executors/environments/executor.js +59 -0
  13. package/dist/src/executors/environments/helpers.d.ts +21 -0
  14. package/dist/src/executors/environments/helpers.d.ts.map +1 -0
  15. package/dist/src/executors/environments/helpers.js +63 -0
  16. package/dist/src/executors/environments/schema.json +9 -0
  17. package/dist/src/executors/publish/executor.d.ts +12 -0
  18. package/dist/src/executors/publish/executor.d.ts.map +1 -0
  19. package/dist/src/executors/publish/executor.js +57 -0
  20. package/dist/src/executors/publish/helpers.d.ts +19 -0
  21. package/dist/src/executors/publish/helpers.d.ts.map +1 -0
  22. package/dist/src/executors/publish/helpers.js +52 -0
  23. package/dist/src/executors/publish/schema.json +19 -0
  24. package/dist/src/executors/shared/index.d.ts +3 -0
  25. package/dist/src/executors/shared/index.d.ts.map +1 -0
  26. package/dist/src/executors/shared/index.js +7 -0
  27. package/dist/src/executors/shared/types.d.ts +4 -0
  28. package/dist/src/executors/shared/types.d.ts.map +1 -0
  29. package/dist/src/executors/shared/types.js +4 -0
  30. package/dist/src/executors/shared/utils.d.ts +34 -0
  31. package/dist/src/executors/shared/utils.d.ts.map +1 -0
  32. package/dist/src/executors/shared/utils.js +74 -0
  33. package/dist/src/executors/update-executors-file/executor.d.ts +12 -0
  34. package/dist/src/executors/update-executors-file/executor.d.ts.map +1 -0
  35. package/dist/src/executors/update-executors-file/executor.js +46 -0
  36. package/dist/src/executors/update-executors-file/helpers.d.ts +24 -0
  37. package/dist/src/executors/update-executors-file/helpers.d.ts.map +1 -0
  38. package/dist/src/executors/update-executors-file/helpers.js +70 -0
  39. package/dist/src/executors/update-executors-file/schema.json +9 -0
  40. package/dist/src/executors/update-executors-file/types.d.ts +14 -0
  41. package/dist/src/executors/update-executors-file/types.d.ts.map +1 -0
  42. package/dist/src/executors/update-executors-file/types.js +4 -0
  43. package/dist/src/executors/vtex-link/constants.d.ts +4 -0
  44. package/dist/src/executors/vtex-link/constants.d.ts.map +1 -0
  45. package/dist/src/executors/vtex-link/constants.js +24 -0
  46. package/dist/src/executors/vtex-link/executor.d.ts +5 -0
  47. package/dist/src/executors/vtex-link/executor.d.ts.map +1 -0
  48. package/dist/src/executors/vtex-link/executor.js +35 -0
  49. package/dist/src/executors/vtex-link/helpers.d.ts +77 -0
  50. package/dist/src/executors/vtex-link/helpers.d.ts.map +1 -0
  51. package/dist/src/executors/vtex-link/helpers.js +187 -0
  52. package/dist/src/executors/vtex-link/schema.json +25 -0
  53. package/dist/src/executors/vtex-link/types.d.ts +12 -0
  54. package/dist/src/executors/vtex-link/types.d.ts.map +1 -0
  55. package/dist/src/executors/vtex-link/types.js +4 -0
  56. package/dist/src/index.d.ts +2 -0
  57. package/dist/src/index.d.ts.map +1 -0
  58. package/dist/src/index.js +6 -0
  59. package/dist/src/logger.d.ts +34 -0
  60. package/dist/src/logger.d.ts.map +1 -0
  61. package/dist/src/logger.js +106 -0
  62. package/dist/src/scripts/changeset-pre-mode.d.ts +2 -0
  63. package/dist/src/scripts/changeset-pre-mode.d.ts.map +1 -0
  64. package/dist/src/scripts/changeset-pre-mode.js +41 -0
  65. package/dist/src/shared/index.d.ts +2 -0
  66. package/dist/src/shared/index.d.ts.map +1 -0
  67. package/dist/src/shared/index.js +6 -0
  68. package/dist/src/shared/utils.d.ts +11 -0
  69. package/dist/src/shared/utils.d.ts.map +1 -0
  70. package/dist/src/shared/utils.js +22 -0
  71. package/dist/src/vite/config-builder/configs/app.d.ts +4 -0
  72. package/dist/src/vite/config-builder/configs/app.d.ts.map +1 -0
  73. package/dist/src/vite/config-builder/configs/app.js +19 -0
  74. package/dist/src/vite/config-builder/configs/base.d.ts +4 -0
  75. package/dist/src/vite/config-builder/configs/base.d.ts.map +1 -0
  76. package/dist/src/vite/config-builder/configs/base.js +55 -0
  77. package/dist/src/vite/config-builder/configs/index.d.ts +7 -0
  78. package/dist/src/vite/config-builder/configs/index.d.ts.map +1 -0
  79. package/dist/src/vite/config-builder/configs/index.js +28 -0
  80. package/dist/src/vite/config-builder/configs/lib.d.ts +4 -0
  81. package/dist/src/vite/config-builder/configs/lib.d.ts.map +1 -0
  82. package/dist/src/vite/config-builder/configs/lib.js +57 -0
  83. package/dist/src/vite/config-builder/configs/script.d.ts +4 -0
  84. package/dist/src/vite/config-builder/configs/script.d.ts.map +1 -0
  85. package/dist/src/vite/config-builder/configs/script.js +42 -0
  86. package/dist/src/vite/config-builder/index.d.ts +3 -0
  87. package/dist/src/vite/config-builder/index.d.ts.map +1 -0
  88. package/dist/src/vite/config-builder/index.js +7 -0
  89. package/dist/src/vite/config-builder/main.d.ts +10 -0
  90. package/dist/src/vite/config-builder/main.d.ts.map +1 -0
  91. package/dist/src/vite/config-builder/main.js +37 -0
  92. package/dist/src/vite/config-builder/plugins.d.ts +30 -0
  93. package/dist/src/vite/config-builder/plugins.d.ts.map +1 -0
  94. package/dist/src/vite/config-builder/plugins.js +88 -0
  95. package/dist/src/vite/config-builder/shared/index.d.ts +3 -0
  96. package/dist/src/vite/config-builder/shared/index.d.ts.map +1 -0
  97. package/dist/src/vite/config-builder/shared/index.js +7 -0
  98. package/dist/src/vite/config-builder/shared/types.d.ts +155 -0
  99. package/dist/src/vite/config-builder/shared/types.d.ts.map +1 -0
  100. package/dist/src/vite/config-builder/shared/types.js +58 -0
  101. package/dist/src/vite/config-builder/shared/utils/helpers.d.ts +81 -0
  102. package/dist/src/vite/config-builder/shared/utils/helpers.d.ts.map +1 -0
  103. package/dist/src/vite/config-builder/shared/utils/helpers.js +61 -0
  104. package/dist/src/vite/config-builder/shared/utils/index.d.ts +4 -0
  105. package/dist/src/vite/config-builder/shared/utils/index.d.ts.map +1 -0
  106. package/dist/src/vite/config-builder/shared/utils/index.js +8 -0
  107. package/dist/src/vite/config-builder/shared/utils/projectConfig.d.ts +60 -0
  108. package/dist/src/vite/config-builder/shared/utils/projectConfig.d.ts.map +1 -0
  109. package/dist/src/vite/config-builder/shared/utils/projectConfig.js +85 -0
  110. package/dist/src/vite/config-builder/shared/utils/viteCommand.d.ts +24 -0
  111. package/dist/src/vite/config-builder/shared/utils/viteCommand.d.ts.map +1 -0
  112. package/dist/src/vite/config-builder/shared/utils/viteCommand.js +54 -0
  113. package/dist/src/vite/index.d.ts +3 -0
  114. package/dist/src/vite/index.d.ts.map +1 -0
  115. package/dist/src/vite/index.js +7 -0
  116. package/dist/src/vite/plugins/index.d.ts +3 -0
  117. package/dist/src/vite/plugins/index.d.ts.map +1 -0
  118. package/dist/src/vite/plugins/index.js +7 -0
  119. package/dist/src/vite/plugins/shadow-dom-inject-css/index.d.ts +8 -0
  120. package/dist/src/vite/plugins/shadow-dom-inject-css/index.d.ts.map +1 -0
  121. package/dist/src/vite/plugins/shadow-dom-inject-css/index.js +44 -0
  122. package/dist/src/vite/plugins/third-party-css-inject/index.d.ts +4 -0
  123. package/dist/src/vite/plugins/third-party-css-inject/index.d.ts.map +1 -0
  124. package/dist/src/vite/plugins/third-party-css-inject/index.js +13 -0
  125. package/dist/src/vite/plugins/third-party-css-inject/main.d.ts +17 -0
  126. package/dist/src/vite/plugins/third-party-css-inject/main.d.ts.map +1 -0
  127. package/dist/src/vite/plugins/third-party-css-inject/main.js +48 -0
  128. package/dist/src/vite/plugins/third-party-css-inject/utils.d.ts +5 -0
  129. package/dist/src/vite/plugins/third-party-css-inject/utils.d.ts.map +1 -0
  130. package/dist/src/vite/plugins/third-party-css-inject/utils.js +112 -0
  131. package/package.json +12 -0
@@ -0,0 +1,88 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ function _export(target, all) {
6
+ for(var name in all)Object.defineProperty(target, name, {
7
+ enumerable: true,
8
+ get: all[name]
9
+ });
10
+ }
11
+ _export(exports, {
12
+ basePlugins: function() {
13
+ return basePlugins;
14
+ },
15
+ bundleAnalysisPlugin: function() {
16
+ return bundleAnalysisPlugin;
17
+ },
18
+ dtsPlugin: function() {
19
+ return dtsPlugin;
20
+ },
21
+ injectCssByJsPlugin: function() {
22
+ return injectCssByJsPlugin;
23
+ },
24
+ injectCssIntoShadowDomPlugin: function() {
25
+ return injectCssIntoShadowDomPlugin;
26
+ }
27
+ });
28
+ const _interop_require_default = require("@swc/helpers/_/_interop_require_default");
29
+ const _viteplugincommonjs = require("@originjs/vite-plugin-commonjs");
30
+ const _plugingraphql = /*#__PURE__*/ _interop_require_default._(require("@rollup/plugin-graphql"));
31
+ const _pluginreactswc = /*#__PURE__*/ _interop_require_default._(require("@vitejs/plugin-react-swc"));
32
+ const _path = require("path");
33
+ const _rolluppluginvisualizer = require("rollup-plugin-visualizer");
34
+ const _viteplugincssinjectedbyjs = /*#__PURE__*/ _interop_require_default._(require("vite-plugin-css-injected-by-js"));
35
+ const _viteplugindts = /*#__PURE__*/ _interop_require_default._(require("vite-plugin-dts"));
36
+ const _vitetsconfigpaths = /*#__PURE__*/ _interop_require_default._(require("vite-tsconfig-paths"));
37
+ const _plugins = require("../plugins");
38
+ const _shared = require("./shared");
39
+ const basePlugins = {
40
+ generate: ({ projectConfig })=>{
41
+ const projects = (0, _shared.getNxTsConfigPaths)();
42
+ return [
43
+ // tsconfigPaths({
44
+ // projects: tsConfigPaths.map(x => resolve(process.cwd(), x)),
45
+ // }),
46
+ (0, _vitetsconfigpaths.default)({
47
+ projects
48
+ }),
49
+ (0, _viteplugincommonjs.viteCommonjs)(),
50
+ (0, _plugingraphql.default)(),
51
+ (0, _pluginreactswc.default)({
52
+ tsDecorators: true
53
+ })
54
+ ];
55
+ }
56
+ };
57
+ const dtsPlugin = {
58
+ generate: ({ projectConfig })=>[
59
+ (0, _viteplugindts.default)({
60
+ tsconfigPath: (0, _path.resolve)(projectConfig.path, 'tsconfig.lib.json'),
61
+ outDir: (0, _path.resolve)(projectConfig.path, 'dist'),
62
+ entryRoot: (0, _path.resolve)(projectConfig.path, 'src')
63
+ })
64
+ ],
65
+ condition: ({ projectConfig, viteCmd })=>viteCmd.stage !== _shared.Stage.LOCAL && projectConfig.dts == null ? true : !!projectConfig.dts
66
+ };
67
+ const bundleAnalysisPlugin = {
68
+ generate: ({ projectConfig })=>[
69
+ (0, _rolluppluginvisualizer.visualizer)({
70
+ emitFile: true,
71
+ projectRoot: (0, _path.resolve)(projectConfig.path, 'dist'),
72
+ filename: 'bundle-analysis.html'
73
+ })
74
+ ],
75
+ condition: ({ viteCmd })=>viteCmd.flags?.[_shared.Flag.ANALYZE] === 'true'
76
+ };
77
+ const injectCssByJsPlugin = {
78
+ generate: (_)=>[
79
+ (0, _viteplugincssinjectedbyjs.default)()
80
+ ],
81
+ condition: ({ projectConfig })=>!projectConfig.shadowDom
82
+ };
83
+ const injectCssIntoShadowDomPlugin = {
84
+ generate: (_)=>[
85
+ (0, _plugins.injectCssIntoShadowDom)()
86
+ ],
87
+ condition: ({ projectConfig })=>projectConfig.shadowDom
88
+ };
@@ -0,0 +1,3 @@
1
+ export * from './types';
2
+ export * from './utils';
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/vite/config-builder/shared/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAC;AACxB,cAAc,SAAS,CAAC"}
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ const _export_star = require("@swc/helpers/_/_export_star");
6
+ _export_star._(require("./types"), exports);
7
+ _export_star._(require("./utils"), exports);
@@ -0,0 +1,155 @@
1
+ import type { ConfigEnv, LibraryOptions, UserConfig } from 'vite';
2
+ import { LogLevel } from '../../../logger';
3
+ export declare enum ViteMode {
4
+ PROD = "production",
5
+ DEV = "development"
6
+ }
7
+ /**
8
+ * Project stages, it coincides with the target configurations of the project.json of NX.
9
+ * @readonly
10
+ * @enum {string}
11
+ */
12
+ export declare enum Stage {
13
+ PROD = "prod",
14
+ DEV = "dev",
15
+ STAGING = "staging",
16
+ LOCAL = "local"
17
+ }
18
+ export declare enum ProjectType {
19
+ APP = "app",
20
+ LIB = "lib",
21
+ SCRIPT = "script"
22
+ }
23
+ export declare enum Flag {
24
+ SOURCEMAP = "source-maps",
25
+ ANALYZE = "analyze",
26
+ VERBOSE = "verbose",
27
+ VERBOSE_ALIAS = "v"
28
+ }
29
+ export declare enum Target {
30
+ BUILD = "build",
31
+ PREVIEW = "preview",
32
+ SERVE = "serve"
33
+ }
34
+ /**
35
+ * Vite Environment.
36
+ *
37
+ * @property {ViteMode} mode - Vite mode.
38
+ */
39
+ export type ViteEnv = ConfigEnv & {
40
+ mode: ViteMode;
41
+ };
42
+ /**
43
+ * Externalizing libraries.
44
+ *
45
+ * @property {boolean} default - React externalizes and other common dependencies,
46
+ * this only applies to libraries.
47
+ * @property {boolean} glob - Glob expression or list of glob expressions to exclude
48
+ * dependencies from the package.json.
49
+ */
50
+ export type ExternalizeLibs = {
51
+ default: boolean;
52
+ glob: string | string[];
53
+ };
54
+ export type ResolveEnvs = {
55
+ default: boolean;
56
+ local: boolean;
57
+ };
58
+ /**
59
+ * Project configuration.
60
+ *
61
+ * @property {ProjectType} type - Type of the project.
62
+ * @property {string} path - Path of the project.
63
+ * @property {string} entry - Path of the file entry point.
64
+ * @property {string} name - Name of the project, it is also used to define the name of the library.
65
+ * @property {string} port - Server port.
66
+ * @property {boolean} debug - Print data purification data.
67
+ * @property {boolean} dts - Control if the .d.ts files are generated, by default it is True.
68
+ * @property {Partial<ResolveEnvs>} resolveEnvs - Flag for resolving environment.
69
+ * @property {boolean} shadowDom - If component is render into shadow dom.
70
+ * @property {Partial<ExternalizeLibs>} externalizeLibs - Configuration for externalizing libraries.
71
+ * @property {LibraryOptions['fileName']} fileName - Output file name for library.
72
+ * @property {string} fileName - Prefix for chunk file name.
73
+ * @property {ViteEnv} viteEnv - Vite environment configuration.
74
+ * @property {UserConfig} overrides - Overrides for vite configuration.
75
+ */
76
+ export interface ProjectConfig {
77
+ type: ProjectType;
78
+ path: string;
79
+ entry?: string;
80
+ name?: string;
81
+ port?: number;
82
+ logLevel?: LogLevel;
83
+ dts?: boolean;
84
+ resolveEnvs?: Partial<ResolveEnvs>;
85
+ shadowDom?: boolean;
86
+ externalizeLibs?: Partial<ExternalizeLibs>;
87
+ fileName?: LibraryOptions['fileName'];
88
+ chunkPrefix?: string;
89
+ viteEnv: ViteEnv;
90
+ overrides?: UserConfig;
91
+ }
92
+ export interface ProjectConfigInitialized extends ProjectConfig {
93
+ name: string;
94
+ fileName: string;
95
+ chunkPrefix: string;
96
+ logLevel: LogLevel;
97
+ overrides: UserConfig;
98
+ shadowDom: boolean;
99
+ resolveEnvs: ResolveEnvs;
100
+ externalizeLibs: ExternalizeLibs;
101
+ }
102
+ /**
103
+ * Vite command details.
104
+ * @interface
105
+ * @property {Stage} stage - Stage of the project.
106
+ * @property {string} target - Command name.
107
+ * @property {Record<string, any>} flags - Flags for customize command.
108
+ */
109
+ export interface ViteCommand {
110
+ stage: Stage;
111
+ target: string;
112
+ flags: Record<string, any>;
113
+ }
114
+ /**
115
+ * Common project configuration.
116
+ *
117
+ * @property {string} envPrefix - Prefix in lowercase for environment variables and output files.
118
+ * @property {boolean} externalizeLibGlob - Glob expression or list of glob expressions to exclude
119
+ * dependencies from the package.json.
120
+ */
121
+ export interface CommonProjectConfig {
122
+ envPrefix: string;
123
+ externalizeLibGlob?: string | string[];
124
+ }
125
+ /**
126
+ * Config builder context.
127
+ *
128
+ * @property {CommonProjectConfig} commonConfig - Common configuration for the project.
129
+ * @property {ProjectConfigInitialized} projectConfig - Initialized project configuration.
130
+ * @property {ViteCommandDetail} viteCmd - Vite command details.
131
+ */
132
+ export interface Context {
133
+ commonConfig: CommonProjectConfig;
134
+ projectConfig: ProjectConfigInitialized;
135
+ viteCmd: ViteCommand;
136
+ localPkgJson: Record<string, any>;
137
+ }
138
+ /**
139
+ * Interface for plugin configuration.
140
+ */
141
+ export interface PluginConfig {
142
+ /**
143
+ * Generates plugin(s) based on the provided configuration.
144
+ * @param {Context} ctx - The main configuration object.
145
+ * @returns {any[]} An array of plugins.
146
+ */
147
+ generate: (ctx: Context) => any[];
148
+ /**
149
+ * Condition to determine if the plugin(s) should be included.
150
+ * @param {Context} ctx - The main configuration object.
151
+ * @returns {boolean} True if the plugin(s) should be included; false otherwise.
152
+ */
153
+ condition?: (ctx: Context) => boolean;
154
+ }
155
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../../src/vite/config-builder/shared/types.ts"],"names":[],"mappings":"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"}
@@ -0,0 +1,58 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ function _export(target, all) {
6
+ for(var name in all)Object.defineProperty(target, name, {
7
+ enumerable: true,
8
+ get: all[name]
9
+ });
10
+ }
11
+ _export(exports, {
12
+ Flag: function() {
13
+ return Flag;
14
+ },
15
+ ProjectType: function() {
16
+ return ProjectType;
17
+ },
18
+ Stage: function() {
19
+ return Stage;
20
+ },
21
+ Target: function() {
22
+ return Target;
23
+ },
24
+ ViteMode: function() {
25
+ return ViteMode;
26
+ }
27
+ });
28
+ var ViteMode;
29
+ (function(ViteMode) {
30
+ ViteMode["PROD"] = "production";
31
+ ViteMode["DEV"] = "development";
32
+ })(ViteMode || (ViteMode = {}));
33
+ var Stage;
34
+ (function(Stage) {
35
+ Stage["PROD"] = "prod";
36
+ Stage["DEV"] = "dev";
37
+ Stage["STAGING"] = "staging";
38
+ Stage["LOCAL"] = "local";
39
+ })(Stage || (Stage = {}));
40
+ var ProjectType;
41
+ (function(ProjectType) {
42
+ ProjectType["APP"] = "app";
43
+ ProjectType["LIB"] = "lib";
44
+ ProjectType["SCRIPT"] = "script";
45
+ })(ProjectType || (ProjectType = {}));
46
+ var Flag;
47
+ (function(Flag) {
48
+ Flag["SOURCEMAP"] = "source-maps";
49
+ Flag["ANALYZE"] = "analyze";
50
+ Flag["VERBOSE"] = "verbose";
51
+ Flag["VERBOSE_ALIAS"] = "v";
52
+ })(Flag || (Flag = {}));
53
+ var Target;
54
+ (function(Target) {
55
+ Target["BUILD"] = "build";
56
+ Target["PREVIEW"] = "preview";
57
+ Target["SERVE"] = "serve";
58
+ })(Target || (Target = {}));
@@ -0,0 +1,81 @@
1
+ import type { PreRenderedChunk } from 'rollup';
2
+ import type { PluginOption } from 'vite';
3
+ import type { Context, PluginConfig } from '../types';
4
+ /**
5
+ * Generates a short ID string.
6
+ *
7
+ * @param {number} length - The length of the ID to generate.
8
+ * @returns {string} - The generated ID.
9
+ *
10
+ * @example
11
+ * const id = shortId(10); // Outputs: "Aj3_Dk7_2j"
12
+ */
13
+ export declare const shortId: (length: number) => string;
14
+ /**
15
+ * Deeply merges two objects, combining their properties.
16
+ *
17
+ * @param {Record<string, any>} v1 - The first object.
18
+ * @param {Record<string, any>} v2 - The second object.
19
+ * @returns {Record<string, any>} - The merged object.
20
+ *
21
+ * @example
22
+ * const obj1 = { a: 1, b: { c: 2 } };
23
+ * const obj2 = { b: { d: 3 } };
24
+ * const merged = deepMerge(obj1, obj2); // Outputs: { a: 1, b: { c: 2, d: 3 } }
25
+ */
26
+ export declare function deepMerge(v1: Record<string, any>, v2: Record<string, any>): Record<string, any>;
27
+ /**
28
+ * Generates a name for js files.
29
+ *
30
+ * @param {string} [prefix] - An optional prefix for the chunk name.
31
+ * @returns - A function that takes an item and generates a chunk name.
32
+ *
33
+ * @example
34
+ * const generateChunkName = chunkName('prefix');
35
+ * const name = generateChunkName({ name: 'example' }); // Outputs: "prefix-example-Aj3_Dk7_2j.js"
36
+ */
37
+ export declare const chunkName: (prefix?: string) => (x: PreRenderedChunk) => string;
38
+ /**
39
+ * Returns the given object if the condition is true, otherwise returns null.
40
+ *
41
+ * @param {any} condition - The condition to evaluate.
42
+ * @param {Record<string, any>} obj - The object to return if the condition is true.
43
+ * @returns {Record<string, any> | null} - The object or null based on the condition.
44
+ *
45
+ * @example
46
+ * const obj = { a: 1 };
47
+ * const result = when(true, obj); // Outputs: { a: 1 }
48
+ * const result2 = when(false, obj); // Outputs: {}
49
+ */
50
+ export declare const when: (condition: any, obj: Record<string, any>) => Record<string, any>;
51
+ /**
52
+ * Filters and generates plugin configurations based on conditions and the provided context.
53
+ *
54
+ * @param {Context} ctx - The main configuration object.
55
+ * @returns {any[]} - An array of generated plugin configurations.
56
+ */
57
+ export declare const getPlugins: (ctx: Context, ...pluginConfigs: PluginConfig[]) => PluginOption[];
58
+ /**
59
+ * Gets the paths to the tsconfig files for all relevant projects.
60
+ *
61
+ * @returns {string[]} - An array containing paths to tsconfig files for both app and lib projects.
62
+ *
63
+ * @example
64
+ * const projects = {
65
+ * 'my-app': {
66
+ * type: 'app',
67
+ * data: { root: 'apps/my-app' }
68
+ * },
69
+ * 'my-lib': {
70
+ * type: 'lib',
71
+ * data: { root: 'libs/my-lib' }
72
+ * }
73
+ * };
74
+ *
75
+ * const tsConfigPaths = getTsConfigPaths(projects);
76
+ * console.log(tsConfigPaths);
77
+ * // Output:
78
+ * // ['apps/my-app/tsconfig.app.json', 'libs/my-lib/tsconfig.lib.json']
79
+ */
80
+ export declare const getNxTsConfigPaths: () => string[];
81
+ //# sourceMappingURL=helpers.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"helpers.d.ts","sourceRoot":"","sources":["../../../../../../src/vite/config-builder/shared/utils/helpers.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,QAAQ,CAAC;AAC/C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,MAAM,CAAC;AACzC,OAAO,KAAK,EAAE,OAAO,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAItD;;;;;;;;GAQG;AACH,eAAO,MAAM,OAAO,WAAY,MAAM,WAAmB,CAAC;AAE1D;;;;;;;;;;;GAWG;AACH,wBAAgB,SAAS,CACvB,EAAE,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EACvB,EAAE,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GACtB,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAarB;AAED;;;;;;;;;GASG;AACH,eAAO,MAAM,SAAS,YAAa,MAAM,SAAS,gBAAgB,WAIjE,CAAC;AAEF;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,IAAI,cACJ,GAAG,OACT,OAAO,MAAM,EAAE,GAAG,CAAC,KACvB,OAAO,MAAM,EAAE,GAAG,CAA2B,CAAC;AAEjD;;;;;GAKG;AACH,eAAO,MAAM,UAAU,QAChB,OAAO,oBACM,YAAY,EAAE,KAC/B,YAAY,EAKmB,CAAC;AAEnC;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,eAAO,MAAM,kBAAkB,QAAO,MAAM,EAU3C,CAAC"}
@@ -0,0 +1,61 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ function _export(target, all) {
6
+ for(var name in all)Object.defineProperty(target, name, {
7
+ enumerable: true,
8
+ get: all[name]
9
+ });
10
+ }
11
+ _export(exports, {
12
+ chunkName: function() {
13
+ return chunkName;
14
+ },
15
+ deepMerge: function() {
16
+ return deepMerge;
17
+ },
18
+ getNxTsConfigPaths: function() {
19
+ return getNxTsConfigPaths;
20
+ },
21
+ getPlugins: function() {
22
+ return getPlugins;
23
+ },
24
+ shortId: function() {
25
+ return shortId;
26
+ },
27
+ when: function() {
28
+ return when;
29
+ }
30
+ });
31
+ const _interop_require_wildcard = require("@swc/helpers/_/_interop_require_wildcard");
32
+ const _devkit = require("@nx/devkit");
33
+ const _nanoid = require("nanoid");
34
+ const _path = require("path");
35
+ const _ramda = /*#__PURE__*/ _interop_require_wildcard._(require("ramda"));
36
+ const shortId = (length)=>(0, _nanoid.nanoid)(length);
37
+ function deepMerge(v1, v2) {
38
+ if (Array.isArray(v1) && Array.isArray(v2)) {
39
+ return _ramda.uniq(_ramda.concat(v1, v2));
40
+ } else if (typeof v1 === 'object' && typeof v2 === 'object' && !_ramda.isNil(v1) && !_ramda.isNil(v2)) {
41
+ return _ramda.mergeWith(deepMerge, v1, v2);
42
+ } else {
43
+ return v2;
44
+ }
45
+ }
46
+ const chunkName = (prefix)=>(x)=>{
47
+ const nameWithoutUnderscore = x.name.replace(/_/g, '');
48
+ const pre = prefix ? `${prefix}-` : '';
49
+ return `${pre}${nameWithoutUnderscore}-${shortId(8)}.js`;
50
+ };
51
+ const when = (condition, obj)=>condition ? obj : {};
52
+ const getPlugins = (ctx, ...pluginConfigs)=>pluginConfigs// Filters the plugins based on conditions
53
+ .filter((p)=>!p.condition || p.condition(ctx))// Generates the configuration of each plugin and flattens the resulting array
54
+ .flatMap((p)=>p.generate(ctx));
55
+ const getNxTsConfigPaths = ()=>{
56
+ const isValid = (p)=>p.data.root.startsWith('apps/') || p.data.root.startsWith('libs/');
57
+ const getTsConfigPath = (p)=>(0, _path.resolve)(p.data.root, `tsconfig.${p.type === 'app' ? 'app' : 'lib'}.json`);
58
+ const graph = (0, _devkit.readCachedProjectGraph)();
59
+ const projects = graph.nodes;
60
+ return Object.values(projects).filter(isValid).map(getTsConfigPath);
61
+ };
@@ -0,0 +1,4 @@
1
+ export * from './helpers';
2
+ export * from './projectConfig';
3
+ export * from './viteCommand';
4
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../src/vite/config-builder/shared/utils/index.ts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAC;AAC1B,cAAc,iBAAiB,CAAC;AAChC,cAAc,eAAe,CAAC"}
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ const _export_star = require("@swc/helpers/_/_export_star");
6
+ _export_star._(require("./helpers"), exports);
7
+ _export_star._(require("./projectConfig"), exports);
8
+ _export_star._(require("./viteCommand"), exports);
@@ -0,0 +1,60 @@
1
+ import { type UserConfig } from 'vite';
2
+ import { type CommonProjectConfig, type ProjectConfig, type ProjectConfigInitialized } from '../types';
3
+ /**
4
+ * Initializes the project configuration with default values.
5
+ *
6
+ * @example
7
+ * const config = { type: ProjectType.APP, path: '/path/to/project', viteEnv: { mode: ViteMode.DEV } };
8
+ * const initializedConfig = initializeConfig(config);
9
+ */
10
+ export declare const initializeConfig: (ccfg: CommonProjectConfig, pcfg: ProjectConfig, localPkgJson: Record<string, any>) => {
11
+ viteCmd: import("../types").ViteCommand;
12
+ cfg: ProjectConfigInitialized;
13
+ };
14
+ /**
15
+ * Handles merging configurations and logs any errors.
16
+ *
17
+ * @param {UserConfig} defaultConfig - The default configuration.
18
+ * @param {UserConfig} overrides - The overrides configuration.
19
+ * @returns {UserConfig} - The merged configuration.
20
+ */
21
+ export declare const mergeConfigs: (defaultConfig: UserConfig, overrides: UserConfig) => UserConfig;
22
+ /**
23
+ * Resolves glob patterns to actual package names found in package.json dependencies.
24
+ * This function is used to determine which packages should be treated as external
25
+ * in a Rollup or Vite build configuration.
26
+ *
27
+ * @param {string} path - The base path where package.json is located.
28
+ * @param {string | string[]} globs - A glob pattern or an array of glob patterns to match dependencies against.
29
+ * @returns {string[]} An array of package names that match the given glob patterns.
30
+ *
31
+ * @example
32
+ * // Example of using `getExternalDependencies` to find all dependencies starting with "my-lib" and "lodash"
33
+ * const projectPath = '/path/to/project';
34
+ * const globs = ['my-lib*', 'lodash'];
35
+ * const externalDependencies = getExternalDependencies(projectPath, globs);
36
+ * console.log(externalDependencies);
37
+ * // Output might be: ['my-lib/utils', 'my-lib/core', 'lodash']
38
+ */
39
+ export declare const getExternalDependencies: (path: string, globs?: string | string[]) => string[];
40
+ /**
41
+ * Generates a string of initials based on the input string,
42
+ * following certain rules:
43
+ * 1. A word is considered as a sequence of characters
44
+ * separated by hyphens.
45
+ * 2. If the string contains '@', any characters before
46
+ * and including the next '/' are ignored.
47
+ * 3. The first character of each word is taken to form
48
+ * the initials.
49
+ *
50
+ * @param {string} input - The input string from which to generate the initials.
51
+ * @returns {string} The initials formed by taking the first character
52
+ * of each word, after applying the specified rules.
53
+ *
54
+ * @example
55
+ * getInitials("player-script"); // returns "ps"
56
+ * getInitials("ssv-admin"); // returns "sa"
57
+ * getInitials("@nizza/customize-live"); // returns "cl"
58
+ */
59
+ export declare function getInitials(input: string): string;
60
+ //# sourceMappingURL=projectConfig.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"projectConfig.d.ts","sourceRoot":"","sources":["../../../../../../src/vite/config-builder/shared/utils/projectConfig.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,UAAU,EAAE,MAAM,MAAM,CAAC;AAGvC,OAAO,EAEL,KAAK,mBAAmB,EAExB,KAAK,aAAa,EAClB,KAAK,wBAAwB,EAC9B,MAAM,UAAU,CAAC;AAIlB;;;;;;GAMG;AACH,eAAO,MAAM,gBAAgB,SACrB,mBAAmB,QACnB,aAAa,gBACL,OAAO,MAAM,EAAE,GAAG,CAAC;;;CAsClC,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,YAAY,kBACR,UAAU,aACd,UAAU,KACpB,UAOF,CAAC;AAEF;;;;;;;;;;;;;;;;GAgBG;AACH,eAAO,MAAM,uBAAuB,SAC5B,MAAM,UACL,MAAM,GAAG,MAAM,EAAE,KACvB,MAAM,EAQR,CAAC;AAEF;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,WAAW,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAKjD"}
@@ -0,0 +1,85 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ function _export(target, all) {
6
+ for(var name in all)Object.defineProperty(target, name, {
7
+ enumerable: true,
8
+ get: all[name]
9
+ });
10
+ }
11
+ _export(exports, {
12
+ getExternalDependencies: function() {
13
+ return getExternalDependencies;
14
+ },
15
+ getInitials: function() {
16
+ return getInitials;
17
+ },
18
+ initializeConfig: function() {
19
+ return initializeConfig;
20
+ },
21
+ mergeConfigs: function() {
22
+ return mergeConfigs;
23
+ }
24
+ });
25
+ const _interop_require_wildcard = require("@swc/helpers/_/_interop_require_wildcard");
26
+ const _minimatch = require("minimatch");
27
+ const _logger = /*#__PURE__*/ _interop_require_wildcard._(require("../../../../logger"));
28
+ const _shared = require("../../../../shared");
29
+ const _types = require("../types");
30
+ const _helpers = require("./helpers");
31
+ const _viteCommand = require("./viteCommand");
32
+ const initializeConfig = (ccfg, pcfg, localPkgJson)=>{
33
+ const { envPrefix } = ccfg;
34
+ const localPkgName = localPkgJson['name'];
35
+ const { name = localPkgName, overrides = {}, shadowDom = false, chunkPrefix = getInitials(localPkgName), resolveEnvs = {
36
+ default: true,
37
+ local: true
38
+ }, fileName = `${envPrefix}-${chunkPrefix}-index`, externalizeLibs = {
39
+ default: true,
40
+ glob: []
41
+ } } = pcfg;
42
+ const viteCmd = (0, _viteCommand.getViteCommand)(pcfg.viteEnv.mode);
43
+ const isVerbose = Object.keys(viteCmd.flags).some((x)=>[
44
+ _types.Flag.VERBOSE,
45
+ _types.Flag.VERBOSE_ALIAS
46
+ ].includes(x));
47
+ const logLevel = isVerbose ? _logger.LogLevel.DEBUG : pcfg.logLevel ?? _logger.LogLevel.INFO;
48
+ (0, _logger.setLogLevel)(logLevel);
49
+ return {
50
+ viteCmd,
51
+ cfg: {
52
+ ...pcfg,
53
+ name,
54
+ fileName,
55
+ logLevel,
56
+ overrides,
57
+ chunkPrefix,
58
+ shadowDom,
59
+ resolveEnvs,
60
+ externalizeLibs: externalizeLibs
61
+ }
62
+ };
63
+ };
64
+ const mergeConfigs = (defaultConfig, overrides)=>{
65
+ try {
66
+ return (0, _helpers.deepMerge)(defaultConfig, overrides);
67
+ } catch (err) {
68
+ _logger.default.error('Error merging vite configs: ', err);
69
+ return defaultConfig;
70
+ }
71
+ };
72
+ const getExternalDependencies = (path, globs = [])=>{
73
+ const pkgJson = (0, _shared.getPkgJson)(path); // Assumes getLocalPkgJson is a function that reads and parses package.json
74
+ const dependencies = Object.keys(pkgJson.dependencies || {});
75
+ const globPatterns = Array.isArray(globs) ? globs : [
76
+ globs
77
+ ];
78
+ return dependencies.filter((dep)=>globPatterns.some((pattern)=>(0, _minimatch.minimatch)(dep, pattern)));
79
+ };
80
+ function getInitials(input) {
81
+ const cleanedInput = input.includes('@') ? input.split('/')[1] : input;
82
+ const words = cleanedInput?.split('-');
83
+ const initials = words?.map((word)=>word.charAt(0)).join('');
84
+ return initials ?? '';
85
+ }
@@ -0,0 +1,24 @@
1
+ import { ViteMode, type ViteCommand } from '../types';
2
+ /**
3
+ * Retrieves the Vite command details.
4
+ *
5
+ * @param {ViteMode} mode - The Vite mode.
6
+ * @returns {ViteCommand} - The command details.
7
+ *
8
+ * @example
9
+ * const command = getViteCommand(ViteMode.PROD);
10
+ * // Outputs: { stage: Stage.PROD, target: 'build', flags: {} }
11
+ */
12
+ export declare function getViteCommand(mode: ViteMode): ViteCommand;
13
+ /**
14
+ * Parses the command string to extract flags.
15
+ *
16
+ * @param {string | undefined} commandString - The command string.
17
+ * @returns {Record<string, string>} - The flags extracted from the command string.
18
+ *
19
+ * @example
20
+ * const flags = getViteCmdFlags('nx run core:build --source-maps');
21
+ * // Outputs: { 'source-maps: 'true' }
22
+ */
23
+ export declare function getViteCmdFlags(commandString: string | undefined): Record<string, string>;
24
+ //# sourceMappingURL=viteCommand.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"viteCommand.d.ts","sourceRoot":"","sources":["../../../../../../src/vite/config-builder/shared/utils/viteCommand.ts"],"names":[],"mappings":"AAGA,OAAO,EAAiB,QAAQ,EAAE,KAAK,WAAW,EAAE,MAAM,UAAU,CAAC;AAErE;;;;;;;;;GASG;AACH,wBAAgB,cAAc,CAAC,IAAI,EAAE,QAAQ,GAAG,WAAW,CAgC1D;AAED;;;;;;;;;GASG;AACH,wBAAgB,eAAe,CAC7B,aAAa,EAAE,MAAM,GAAG,SAAS,GAChC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAOxB"}