@zengenti/contensis-react-base 4.0.1-beta.4 → 4.0.1-beta.5

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/cjs/build.js ADDED
@@ -0,0 +1,219 @@
1
+ #!/usr/bin/env node
2
+ 'use strict';
3
+
4
+ var cac = require('cac');
5
+ var child_process = require('child_process');
6
+ var path = require('path');
7
+ var fs = require('fs');
8
+ var dotenv = require('dotenv');
9
+ var nodemon = require('nodemon');
10
+ var webpack = require('webpack');
11
+ var WebpackDevServer = require('webpack-dev-server');
12
+
13
+ function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
14
+
15
+ var path__default = /*#__PURE__*/_interopDefault(path);
16
+ var fs__default = /*#__PURE__*/_interopDefault(fs);
17
+ var dotenv__default = /*#__PURE__*/_interopDefault(dotenv);
18
+ var nodemon__default = /*#__PURE__*/_interopDefault(nodemon);
19
+ var webpack__default = /*#__PURE__*/_interopDefault(webpack);
20
+ var WebpackDevServer__default = /*#__PURE__*/_interopDefault(WebpackDevServer);
21
+
22
+ const projectRoot = process.cwd();
23
+ const DEVSERVER_RUNTIME_GLOBALS = path__default.default.resolve(__dirname, 'dev-server-globals.js');
24
+ function runDev(args) {
25
+ const configPath = args.config;
26
+ const devHost = args.devHost || 'localhost';
27
+ const devPort = args.devPort || '3000';
28
+ const devListen = args.devListen || '0.0.0.0';
29
+ const openBrowser = args.open !== false;
30
+
31
+ // --inspect-brk takes precedence over --inspect.
32
+ // A bare flag (no port value) resolves to true in cac — treat that as the default port.
33
+ const resolveInspectPort = val => val === true || val === undefined ? '9229' : String(val);
34
+ const inspectNodeArg = args.inspectBrk !== undefined ? `--inspect-brk=${resolveInspectPort(args.inspectBrk)}` : `--inspect=${resolveInspectPort(args.inspect)}`;
35
+
36
+ // Validate --config option
37
+ if (!configPath) {
38
+ console.error('[crb] ❌ Error: --config option is required');
39
+ console.log('Usage: crb dev --config <path-to-webpack-config> [--dev-host <host>] [--dev-port <port>] [--dev-listen <host>] [--inspect[=port]] [--inspect-brk[=port]]');
40
+ process.exit(1);
41
+ }
42
+ console.info('[crb] 🚀 Starting SSR dev server pipeline');
43
+ const resolvedConfigPath = path__default.default.resolve(projectRoot, configPath);
44
+
45
+ // Check config file exists
46
+ if (!fs__default.default.existsSync(resolvedConfigPath)) {
47
+ console.error(`[crb] ❌ Error: Config file not found: ${resolvedConfigPath}`);
48
+ process.exit(1);
49
+ }
50
+
51
+ // Set default host and port
52
+ process.env.DEV_HOST = devHost;
53
+ process.env.DEV_PORT = devPort;
54
+
55
+ // Load .env file
56
+ const envFilePath = path__default.default.resolve(projectRoot, args.envFile || '.env');
57
+ try {
58
+ dotenv__default.default.config({
59
+ path: envFilePath
60
+ });
61
+ } catch (e) {
62
+ const msg = e instanceof Error ? e.message : String(e);
63
+ console.error(`[crb] ❌ Error: Failed to load env file (${envFilePath}): ${msg}`);
64
+ process.exit(1);
65
+ }
66
+
67
+ // Validate required environment variables
68
+ const REQUIRED_ENV = ['ALIAS', 'PROJECT', 'ACCESS_TOKEN'];
69
+ const missingEnv = REQUIRED_ENV.filter(k => !process.env[k] || !process.env[k].trim());
70
+ if (missingEnv.length) {
71
+ console.error(`[crb] ❌ Error: Cannot start dev server. Missing required env vars: ${missingEnv.join(', ')}. ` + `Set them in a .env file at the project root or export them in your shell.`);
72
+ process.exit(1);
73
+ }
74
+
75
+ // Load project webpack config
76
+ let webpackConfig;
77
+ try {
78
+ webpackConfig = require(resolvedConfigPath);
79
+ } catch (e) {
80
+ const msg = e instanceof Error ? e.message : String(e);
81
+ console.error(`[crb] ❌ Error: Failed to load webpack config: ${msg}`);
82
+ process.exit(1);
83
+ }
84
+
85
+ // Validate webpack config is an array (dual-target mode)
86
+ if (!Array.isArray(webpackConfig)) {
87
+ console.error(`[crb] ❌ Error: webpack config must be an array [clientConfig, serverConfig]. ` + `The config appears to be a single object (CSR/ANALYZE mode). ` + `Use the unified webpack.config.js for SSR dev mode.`);
88
+ process.exit(1);
89
+ }
90
+ const [clientConfig, serverConfig] = webpackConfig;
91
+
92
+ // State flags for orchestration
93
+ let clientReady = false;
94
+ let serverReady = false;
95
+ let nodemonStarted = false;
96
+ let browserOpened = false;
97
+
98
+ // Nodemon reference for cleanup
99
+ let nodemonInstance = null;
100
+
101
+ // Dev server options
102
+ const devServerOptions = {
103
+ host: devListen,
104
+ port: parseInt(devPort, 10),
105
+ headers: {
106
+ 'Access-Control-Allow-Origin': '*'
107
+ },
108
+ hot: true,
109
+ historyApiFallback: true,
110
+ devMiddleware: {
111
+ index: 'index_csr.html',
112
+ writeToDisk: true
113
+ }
114
+ // TODO: Add proxy config from bundle-info.js (DEVSERVER_PROXIES)
115
+ // to proxy API calls and reverse proxy paths to CMS/IIS
116
+ };
117
+
118
+ // Create dual webpack compilers (single config each → single Compiler, not MultiCompiler)
119
+ const clientCompiler = webpack__default.default(clientConfig);
120
+ const nodeServerCompiler = webpack__default.default(serverConfig);
121
+
122
+ // Start nodemon when both compilers are ready
123
+ function startNodemon() {
124
+ if (nodemonStarted) return;
125
+ nodemonStarted = true;
126
+ console.info('[crb] 🎯 Starting nodemon...');
127
+ nodemonInstance = nodemon__default.default({
128
+ script: 'dist/server-dev.js',
129
+ ext: 'js json',
130
+ watch: ['dist/server-dev.js'],
131
+ nodeArgs: [inspectNodeArg, '-r', DEVSERVER_RUNTIME_GLOBALS]
132
+ }).on('start', () => {
133
+ console.info('[nodemon] started. Now starting local web server at port 3001, with hot-reload enabled.');
134
+ if (openBrowser && !browserOpened) {
135
+ browserOpened = true;
136
+ try {
137
+ const cmd = process.platform === 'win32' ? 'start' : process.platform === 'darwin' ? 'open' : 'xdg-open';
138
+ child_process.execSync(`${cmd} http://${process.env.DEV_HOST}:3001/`, {
139
+ windowsHide: true
140
+ });
141
+ } catch {
142
+ console.info(`Please open http://${process.env.DEV_HOST}:3001/ in your browser`);
143
+ }
144
+ }
145
+ }).on('crash', () => {
146
+ console.error('[nodemon] crashed');
147
+ });
148
+ }
149
+
150
+ // Server afterEmit -> start nodemon when both compilers are ready
151
+ nodeServerCompiler.hooks.afterEmit.tap('serverAfterEmitPlugin', () => {
152
+ if (serverReady) return;
153
+ serverReady = true;
154
+ if (clientReady) {
155
+ startNodemon();
156
+ }
157
+ });
158
+
159
+ // Start server compiler watch immediately
160
+ console.info('[crb] 📦 Starting server compiler...');
161
+ nodeServerCompiler.watch({}, (err, stats) => {
162
+ if (err) {
163
+ return console.error(err);
164
+ }
165
+ const statString = stats.toString();
166
+ process.stdout.write(statString + '\n');
167
+ });
168
+
169
+ // Client afterEmit -> start nodemon if server is already ready
170
+ clientCompiler.hooks.afterEmit.tap('clientAfterEmitPlugin', () => {
171
+ if (clientReady) return;
172
+ clientReady = true;
173
+ if (serverReady) {
174
+ startNodemon();
175
+ }
176
+ });
177
+
178
+ // Start webpack dev server
179
+ const devServer = new WebpackDevServer__default.default(devServerOptions, clientCompiler);
180
+ devServer.startCallback(err => {
181
+ if (err) {
182
+ console.error('[webpack] devServer listening failed');
183
+ return console.error(err);
184
+ }
185
+ console.info(`[webpack] devServer listening on port ${devPort}`);
186
+ });
187
+
188
+ // Cleanup on SIGTERM/SIGINT
189
+ function cleanup() {
190
+ console.info('[crb] 🛑 Shutting down...');
191
+ if (nodemonInstance) {
192
+ nodemonInstance.emit('quit');
193
+ }
194
+ devServer.stopCallback(() => {
195
+ console.info('[webpack] devServer stopped');
196
+ clientCompiler.close(() => {
197
+ console.info('[webpack] client compiler closed');
198
+ nodeServerCompiler.close(() => {
199
+ console.info('[webpack] server compiler closed');
200
+ process.exit(0);
201
+ });
202
+ });
203
+ });
204
+ }
205
+ process.on('SIGTERM', cleanup);
206
+ process.on('SIGINT', cleanup);
207
+ }
208
+
209
+ const cli = cac.cac('crb');
210
+
211
+ // Dev subcommand
212
+ cli.command('dev', 'Start the SSR dev server pipeline').option('--config <path>', 'Path to webpack config file (required)').option('--env-file <path>', 'Path to .env file (default: .env)').option('--dev-host <host>', 'webpack publicPath / HMR host (default: localhost)').option('--dev-port <port>', 'webpack-dev-server listen port (default: 3000)').option('--dev-listen <host>', 'webpack-dev-server listen host (default: 0.0.0.0)').option('--open', 'Open the browser when the SSR server starts. Use --no-open to disable. (default: true)').option('--inspect [port]', 'Enable the V8 inspector on the SSR server. Optionally specify a port (default: 9229)').option('--inspect-brk [port]', 'Enable the V8 inspector and break before the script starts — useful for debugging server startup. Optionally specify a port (default: 9229). Takes precedence over --inspect.').action(runDev);
213
+ cli.help();
214
+ cli.parse();
215
+ if (!cli.matchedCommand) {
216
+ cli.outputHelp();
217
+ process.exit(1);
218
+ }
219
+ //# sourceMappingURL=build.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"build.js","sources":["../src/build/dev-server.ts","../src/build/cli.ts"],"sourcesContent":["import { execSync } from 'child_process';\nimport path from 'path';\nimport fs from 'fs';\nimport dotenv from 'dotenv';\n// @ts-ignore — nodemon has no type definitions\nimport nodemon from 'nodemon';\nimport webpack from 'webpack';\nimport WebpackDevServer from 'webpack-dev-server';\nconst projectRoot = process.cwd();\nconst DEVSERVER_RUNTIME_GLOBALS = path.resolve(__dirname, 'dev-server-globals.js');\n\ninterface DevOptions {\n config?: string;\n envFile?: string;\n devHost?: string;\n devPort?: string;\n devListen?: string;\n open?: boolean;\n inspect?: boolean | string;\n inspectBrk?: boolean | string;\n}\n\nexport function runDev(args: DevOptions): void {\n const configPath = args.config;\n const devHost = args.devHost || 'localhost';\n const devPort = args.devPort || '3000';\n const devListen = args.devListen || '0.0.0.0';\n const openBrowser = args.open !== false;\n\n // --inspect-brk takes precedence over --inspect.\n // A bare flag (no port value) resolves to true in cac — treat that as the default port.\n const resolveInspectPort = (val: boolean | string | undefined) =>\n val === true || val === undefined ? '9229' : String(val);\n const inspectNodeArg =\n args.inspectBrk !== undefined\n ? `--inspect-brk=${resolveInspectPort(args.inspectBrk)}`\n : `--inspect=${resolveInspectPort(args.inspect)}`;\n\n // Validate --config option\n if (!configPath) {\n console.error('[crb] ❌ Error: --config option is required');\n console.log(\n 'Usage: crb dev --config <path-to-webpack-config> [--dev-host <host>] [--dev-port <port>] [--dev-listen <host>] [--inspect[=port]] [--inspect-brk[=port]]'\n );\n process.exit(1);\n }\n\n console.info('[crb] 🚀 Starting SSR dev server pipeline');\n\n const resolvedConfigPath = path.resolve(projectRoot, configPath);\n\n // Check config file exists\n if (!fs.existsSync(resolvedConfigPath)) {\n console.error(\n `[crb] ❌ Error: Config file not found: ${resolvedConfigPath}`\n );\n process.exit(1);\n }\n\n // Set default host and port\n process.env.DEV_HOST = devHost;\n process.env.DEV_PORT = devPort;\n\n // Load .env file\n const envFilePath = path.resolve(projectRoot, args.envFile || '.env');\n try {\n dotenv.config({ path: envFilePath });\n } catch (e: unknown) {\n const msg = e instanceof Error ? e.message : String(e);\n console.error(\n `[crb] ❌ Error: Failed to load env file (${envFilePath}): ${msg}`\n );\n process.exit(1);\n }\n\n // Validate required environment variables\n const REQUIRED_ENV: string[] = ['ALIAS', 'PROJECT', 'ACCESS_TOKEN'];\n const missingEnv = REQUIRED_ENV.filter(\n (k) => !process.env[k] || !process.env[k].trim()\n );\n if (missingEnv.length) {\n console.error(\n `[crb] ❌ Error: Cannot start dev server. Missing required env vars: ${missingEnv.join(', ')}. ` +\n `Set them in a .env file at the project root or export them in your shell.`\n );\n process.exit(1);\n }\n\n // Load project webpack config\n let webpackConfig: unknown;\n try {\n webpackConfig = require(resolvedConfigPath);\n } catch (e: unknown) {\n const msg = e instanceof Error ? e.message : String(e);\n console.error(\n `[crb] ❌ Error: Failed to load webpack config: ${msg}`\n );\n process.exit(1);\n }\n\n // Validate webpack config is an array (dual-target mode)\n if (!Array.isArray(webpackConfig)) {\n console.error(\n `[crb] ❌ Error: webpack config must be an array [clientConfig, serverConfig]. ` +\n `The config appears to be a single object (CSR/ANALYZE mode). ` +\n `Use the unified webpack.config.js for SSR dev mode.`\n );\n process.exit(1);\n }\n\n const [clientConfig, serverConfig] = webpackConfig as [webpack.Configuration, webpack.Configuration];\n\n // State flags for orchestration\n let clientReady = false;\n let serverReady = false;\n let nodemonStarted = false;\n let browserOpened = false;\n\n // Nodemon reference for cleanup\n let nodemonInstance: ReturnType<typeof nodemon> | null = null;\n\n // Dev server options\n const devServerOptions = {\n host: devListen,\n port: parseInt(devPort, 10),\n headers: { 'Access-Control-Allow-Origin': '*' },\n hot: true,\n historyApiFallback: true,\n devMiddleware: {\n index: 'index_csr.html',\n writeToDisk: true,\n },\n // TODO: Add proxy config from bundle-info.js (DEVSERVER_PROXIES)\n // to proxy API calls and reverse proxy paths to CMS/IIS\n };\n\n // Create dual webpack compilers (single config each → single Compiler, not MultiCompiler)\n const clientCompiler = webpack(clientConfig);\n const nodeServerCompiler = webpack(serverConfig);\n\n // Start nodemon when both compilers are ready\n function startNodemon(): void {\n if (nodemonStarted) return;\n nodemonStarted = true;\n\n console.info('[crb] 🎯 Starting nodemon...');\n nodemonInstance = nodemon({\n script: 'dist/server-dev.js',\n ext: 'js json',\n watch: ['dist/server-dev.js'],\n nodeArgs: [\n inspectNodeArg,\n '-r',\n DEVSERVER_RUNTIME_GLOBALS,\n ],\n })\n .on('start', () => {\n console.info(\n '[nodemon] started. Now starting local web server at port 3001, with hot-reload enabled.'\n );\n if (openBrowser && !browserOpened) {\n browserOpened = true;\n try {\n const cmd =\n process.platform === 'win32'\n ? 'start'\n : process.platform === 'darwin'\n ? 'open'\n : 'xdg-open';\n execSync(`${cmd} http://${process.env.DEV_HOST}:3001/`, {\n windowsHide: true,\n });\n } catch {\n console.info(\n `Please open http://${process.env.DEV_HOST}:3001/ in your browser`\n );\n }\n }\n })\n .on('crash', () => {\n console.error('[nodemon] crashed');\n });\n }\n\n // Server afterEmit -> start nodemon when both compilers are ready\n nodeServerCompiler.hooks.afterEmit.tap('serverAfterEmitPlugin', () => {\n if (serverReady) return;\n serverReady = true;\n\n if (clientReady) {\n startNodemon();\n }\n });\n\n // Start server compiler watch immediately\n console.info('[crb] 📦 Starting server compiler...');\n nodeServerCompiler.watch({}, (err, stats) => {\n if (err) {\n return console.error(err);\n }\n const statString = stats!.toString();\n process.stdout.write(statString + '\\n');\n });\n\n // Client afterEmit -> start nodemon if server is already ready\n clientCompiler.hooks.afterEmit.tap('clientAfterEmitPlugin', () => {\n if (clientReady) return;\n clientReady = true;\n\n if (serverReady) {\n startNodemon();\n }\n });\n\n // Start webpack dev server\n const devServer = new WebpackDevServer(devServerOptions, clientCompiler);\n\n devServer.startCallback((err) => {\n if (err) {\n console.error('[webpack] devServer listening failed');\n return console.error(err);\n }\n console.info(`[webpack] devServer listening on port ${devPort}`);\n });\n\n // Cleanup on SIGTERM/SIGINT\n function cleanup(): void {\n console.info('[crb] 🛑 Shutting down...');\n if (nodemonInstance) {\n nodemonInstance.emit('quit');\n }\n devServer.stopCallback(() => {\n console.info('[webpack] devServer stopped');\n clientCompiler.close(() => {\n console.info('[webpack] client compiler closed');\n nodeServerCompiler.close(() => {\n console.info('[webpack] server compiler closed');\n process.exit(0);\n });\n });\n });\n }\n\n process.on('SIGTERM', cleanup);\n process.on('SIGINT', cleanup);\n}\n","#!/usr/bin/env node\n\nimport { cac } from 'cac';\nimport { runDev } from './dev-server';\n\nconst cli = cac('crb');\n\n// Dev subcommand\ncli\n .command('dev', 'Start the SSR dev server pipeline')\n .option('--config <path>', 'Path to webpack config file (required)')\n .option('--env-file <path>', 'Path to .env file (default: .env)')\n .option(\n '--dev-host <host>',\n 'webpack publicPath / HMR host (default: localhost)'\n )\n .option('--dev-port <port>', 'webpack-dev-server listen port (default: 3000)')\n .option(\n '--dev-listen <host>',\n 'webpack-dev-server listen host (default: 0.0.0.0)'\n )\n .option(\n '--open',\n 'Open the browser when the SSR server starts. Use --no-open to disable. (default: true)'\n )\n .option(\n '--inspect [port]',\n 'Enable the V8 inspector on the SSR server. Optionally specify a port (default: 9229)'\n )\n .option(\n '--inspect-brk [port]',\n 'Enable the V8 inspector and break before the script starts — useful for debugging server startup. Optionally specify a port (default: 9229). Takes precedence over --inspect.'\n )\n .action(runDev);\n\ncli.help();\n\ncli.parse();\nif (!cli.matchedCommand) {\n cli.outputHelp();\n process.exit(1);\n}\n"],"names":["projectRoot","process","cwd","DEVSERVER_RUNTIME_GLOBALS","path","resolve","__dirname","runDev","args","configPath","config","devHost","devPort","devListen","openBrowser","open","resolveInspectPort","val","undefined","String","inspectNodeArg","inspectBrk","inspect","console","error","log","exit","info","resolvedConfigPath","fs","existsSync","env","DEV_HOST","DEV_PORT","envFilePath","envFile","dotenv","e","msg","Error","message","REQUIRED_ENV","missingEnv","filter","k","trim","length","join","webpackConfig","require","Array","isArray","clientConfig","serverConfig","clientReady","serverReady","nodemonStarted","browserOpened","nodemonInstance","devServerOptions","host","port","parseInt","headers","hot","historyApiFallback","devMiddleware","index","writeToDisk","clientCompiler","webpack","nodeServerCompiler","startNodemon","nodemon","script","ext","watch","nodeArgs","on","cmd","platform","execSync","windowsHide","hooks","afterEmit","tap","err","stats","statString","toString","stdout","write","devServer","WebpackDevServer","startCallback","cleanup","emit","stopCallback","close","cli","cac","command","option","action","help","parse","matchedCommand","outputHelp"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAQA,MAAMA,WAAW,GAAGC,OAAO,CAACC,GAAG,EAAE;AACjC,MAAMC,yBAAyB,GAAGC,qBAAI,CAACC,OAAO,CAACC,SAAS,EAAE,uBAAuB,CAAC;AAa3E,SAASC,MAAMA,CAACC,IAAgB,EAAQ;AAC7C,EAAA,MAAMC,UAAU,GAAGD,IAAI,CAACE,MAAM;AAC9B,EAAA,MAAMC,OAAO,GAAGH,IAAI,CAACG,OAAO,IAAI,WAAW;AAC3C,EAAA,MAAMC,OAAO,GAAGJ,IAAI,CAACI,OAAO,IAAI,MAAM;AACtC,EAAA,MAAMC,SAAS,GAAGL,IAAI,CAACK,SAAS,IAAI,SAAS;AAC7C,EAAA,MAAMC,WAAW,GAAGN,IAAI,CAACO,IAAI,KAAK,KAAK;;AAEvC;AACA;AACA,EAAA,MAAMC,kBAAkB,GAAIC,GAAiC,IAC3DA,GA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B3E,QAAAA,OAAO,CAACI,IAAI,CAAC,kCAAkC,CAAC;QAChD4C,kBAAkB,CAAC2B,KAAK,CAAC,MAAM;AAC7B3E,UAAAA,OAAO,CAACI,IAAI,CAAC,kCAAkC,CAAC;AAChD1B,UAAAA,OAAO,CAACyB,IAAI,CAAC,CAAC,CAAC;AACjB,QAAA,CAAC,CAAC;AACJ,MAAA,CAAC,CAAC;AACJ,IAAA,CAAC,CAAC;AACJ,EAAA;AAEAzB,EAAAA,OAAO,CAAC6E,EAAE,CAAC,SAAS,EAAEiB,OAAO,CAAC;AAC9B9F,EAAAA,OAAO,CAAC6E,EAAE,CAAC,QAAQ,EAAEiB,OAAO,CAAC;AAC/B;;AChPA,MAAMI,GAAG,GAAGC,OAAG,CAAC,KAAK,CAAC;;AAEtB;AACAD,GAAG,CACAE,OAAO,CAAC,KAAK,EAAE,mCAAmC,CAAC,CACnDC,MAAM,CAAC,iBAAiB,EAAE,wCAAwC,CAAC,CACnEA,MAAM,CAAC,mBAAmB,EAAE,mCAAmC,CAAC,CAChEA,MAAM,CACL,mBAAmB,EACnB,oDACF,CAAC,CACAA,MAAM,CAAC,mBAAmB,EAAE,gDAAgD,CAAC,CAC7EA,MAAM,CACL,qBAAqB,EACrB,mDACF,CAAC,CACAA,MAAM,CACL,QAAQ,EACR,wFACF,CAAC,CACAA,MAAM,CACL,kBAAkB,EAClB,sFACF,CAAC,CACAA,MAAM,CACL,sBAAsB,EACtB,+KACF,CAAC,CACAC,MAAM,CAAChG,MAAM,CAAC;AAEjB4F,GAAG,CAACK,IAAI,EAAE;AAEVL,GAAG,CAACM,KAAK,EAAE;AACX,IAAI,CAACN,GAAG,CAACO,cAAc,EAAE;EACvBP,GAAG,CAACQ,UAAU,EAAE;AAChB1G,EAAAA,OAAO,CAACyB,IAAI,CAAC,CAAC,CAAC;AACjB;;"}
@@ -0,0 +1,21 @@
1
+ 'use strict';
2
+
3
+ var path = require('path');
4
+
5
+ function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
6
+
7
+ var path__default = /*#__PURE__*/_interopDefault(path);
8
+
9
+ /**
10
+ * This file is emitted as a standalone `cjs/dev-server-globals.js` by rollup.
11
+ * It is loaded by nodemon via the `-r` flag in the SSR server child process.
12
+ * It resolves the consumer's `webpack/define-config` at runtime (using
13
+ * `process.cwd()` = consumer project root) and injects the development
14
+ * defines as global variables.
15
+ */
16
+ const defineConfigPath = path__default.default.resolve(process.cwd(), 'webpack', 'define-config');
17
+ const defineConfig = require(defineConfigPath).development;
18
+ Object.entries(defineConfig).forEach(([key, value]) => {
19
+ global[key] = value;
20
+ });
21
+ //# sourceMappingURL=dev-server-globals.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dev-server-globals.js","sources":["../src/build/dev-server-runtime-globals.ts"],"sourcesContent":["/**\n * This file is emitted as a standalone `cjs/dev-server-globals.js` by rollup.\n * It is loaded by nodemon via the `-r` flag in the SSR server child process.\n * It resolves the consumer's `webpack/define-config` at runtime (using\n * `process.cwd()` = consumer project root) and injects the development\n * defines as global variables.\n */\nimport path from 'path';\n\nconst defineConfigPath = path.resolve(process.cwd(), 'webpack', 'define-config');\n\nconst defineConfig = require(defineConfigPath).development as Record<string, string>;\n\nObject.entries(defineConfig).forEach(([key, value]) => {\n global[key] = value;\n});\n"],"names":["defineConfigPath","path","resolve","process","cwd","defineConfig","require","development","Object","entries","forEach","key","value","global"],"mappings":";;;;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AAGA,MAAMA,gBAAgB,GAAGC,qBAAI,CAACC,OAAO,CAACC,OAAO,CAACC,GAAG,EAAE,EAAE,SAAS,EAAE,eAAe,CAAC;AAEhF,MAAMC,YAAY,GAAGC,OAAO,CAACN,gBAAgB,CAAC,CAACO,WAAqC;AAEpFC,MAAM,CAACC,OAAO,CAACJ,YAAY,CAAC,CAACK,OAAO,CAAC,CAAC,CAACC,GAAG,EAAEC,KAAK,CAAC,KAAK;AACrDC,EAAAA,MAAM,CAACF,GAAG,CAAC,GAAGC,KAAK;AACrB,CAAC,CAAC;;"}
package/esm/build.js ADDED
@@ -0,0 +1,208 @@
1
+ #!/usr/bin/env node
2
+ import { cac } from 'cac';
3
+ import { execSync } from 'child_process';
4
+ import path from 'path';
5
+ import fs from 'fs';
6
+ import dotenv from 'dotenv';
7
+ import nodemon from 'nodemon';
8
+ import webpack from 'webpack';
9
+ import WebpackDevServer from 'webpack-dev-server';
10
+
11
+ const projectRoot = process.cwd();
12
+ const DEVSERVER_RUNTIME_GLOBALS = path.resolve(__dirname, 'dev-server-globals.js');
13
+ function runDev(args) {
14
+ const configPath = args.config;
15
+ const devHost = args.devHost || 'localhost';
16
+ const devPort = args.devPort || '3000';
17
+ const devListen = args.devListen || '0.0.0.0';
18
+ const openBrowser = args.open !== false;
19
+
20
+ // --inspect-brk takes precedence over --inspect.
21
+ // A bare flag (no port value) resolves to true in cac — treat that as the default port.
22
+ const resolveInspectPort = val => val === true || val === undefined ? '9229' : String(val);
23
+ const inspectNodeArg = args.inspectBrk !== undefined ? `--inspect-brk=${resolveInspectPort(args.inspectBrk)}` : `--inspect=${resolveInspectPort(args.inspect)}`;
24
+
25
+ // Validate --config option
26
+ if (!configPath) {
27
+ console.error('[crb] ❌ Error: --config option is required');
28
+ console.log('Usage: crb dev --config <path-to-webpack-config> [--dev-host <host>] [--dev-port <port>] [--dev-listen <host>] [--inspect[=port]] [--inspect-brk[=port]]');
29
+ process.exit(1);
30
+ }
31
+ console.info('[crb] 🚀 Starting SSR dev server pipeline');
32
+ const resolvedConfigPath = path.resolve(projectRoot, configPath);
33
+
34
+ // Check config file exists
35
+ if (!fs.existsSync(resolvedConfigPath)) {
36
+ console.error(`[crb] ❌ Error: Config file not found: ${resolvedConfigPath}`);
37
+ process.exit(1);
38
+ }
39
+
40
+ // Set default host and port
41
+ process.env.DEV_HOST = devHost;
42
+ process.env.DEV_PORT = devPort;
43
+
44
+ // Load .env file
45
+ const envFilePath = path.resolve(projectRoot, args.envFile || '.env');
46
+ try {
47
+ dotenv.config({
48
+ path: envFilePath
49
+ });
50
+ } catch (e) {
51
+ const msg = e instanceof Error ? e.message : String(e);
52
+ console.error(`[crb] ❌ Error: Failed to load env file (${envFilePath}): ${msg}`);
53
+ process.exit(1);
54
+ }
55
+
56
+ // Validate required environment variables
57
+ const REQUIRED_ENV = ['ALIAS', 'PROJECT', 'ACCESS_TOKEN'];
58
+ const missingEnv = REQUIRED_ENV.filter(k => !process.env[k] || !process.env[k].trim());
59
+ if (missingEnv.length) {
60
+ console.error(`[crb] ❌ Error: Cannot start dev server. Missing required env vars: ${missingEnv.join(', ')}. ` + `Set them in a .env file at the project root or export them in your shell.`);
61
+ process.exit(1);
62
+ }
63
+
64
+ // Load project webpack config
65
+ let webpackConfig;
66
+ try {
67
+ webpackConfig = require(resolvedConfigPath);
68
+ } catch (e) {
69
+ const msg = e instanceof Error ? e.message : String(e);
70
+ console.error(`[crb] ❌ Error: Failed to load webpack config: ${msg}`);
71
+ process.exit(1);
72
+ }
73
+
74
+ // Validate webpack config is an array (dual-target mode)
75
+ if (!Array.isArray(webpackConfig)) {
76
+ console.error(`[crb] ❌ Error: webpack config must be an array [clientConfig, serverConfig]. ` + `The config appears to be a single object (CSR/ANALYZE mode). ` + `Use the unified webpack.config.js for SSR dev mode.`);
77
+ process.exit(1);
78
+ }
79
+ const [clientConfig, serverConfig] = webpackConfig;
80
+
81
+ // State flags for orchestration
82
+ let clientReady = false;
83
+ let serverReady = false;
84
+ let nodemonStarted = false;
85
+ let browserOpened = false;
86
+
87
+ // Nodemon reference for cleanup
88
+ let nodemonInstance = null;
89
+
90
+ // Dev server options
91
+ const devServerOptions = {
92
+ host: devListen,
93
+ port: parseInt(devPort, 10),
94
+ headers: {
95
+ 'Access-Control-Allow-Origin': '*'
96
+ },
97
+ hot: true,
98
+ historyApiFallback: true,
99
+ devMiddleware: {
100
+ index: 'index_csr.html',
101
+ writeToDisk: true
102
+ }
103
+ // TODO: Add proxy config from bundle-info.js (DEVSERVER_PROXIES)
104
+ // to proxy API calls and reverse proxy paths to CMS/IIS
105
+ };
106
+
107
+ // Create dual webpack compilers (single config each → single Compiler, not MultiCompiler)
108
+ const clientCompiler = webpack(clientConfig);
109
+ const nodeServerCompiler = webpack(serverConfig);
110
+
111
+ // Start nodemon when both compilers are ready
112
+ function startNodemon() {
113
+ if (nodemonStarted) return;
114
+ nodemonStarted = true;
115
+ console.info('[crb] 🎯 Starting nodemon...');
116
+ nodemonInstance = nodemon({
117
+ script: 'dist/server-dev.js',
118
+ ext: 'js json',
119
+ watch: ['dist/server-dev.js'],
120
+ nodeArgs: [inspectNodeArg, '-r', DEVSERVER_RUNTIME_GLOBALS]
121
+ }).on('start', () => {
122
+ console.info('[nodemon] started. Now starting local web server at port 3001, with hot-reload enabled.');
123
+ if (openBrowser && !browserOpened) {
124
+ browserOpened = true;
125
+ try {
126
+ const cmd = process.platform === 'win32' ? 'start' : process.platform === 'darwin' ? 'open' : 'xdg-open';
127
+ execSync(`${cmd} http://${process.env.DEV_HOST}:3001/`, {
128
+ windowsHide: true
129
+ });
130
+ } catch {
131
+ console.info(`Please open http://${process.env.DEV_HOST}:3001/ in your browser`);
132
+ }
133
+ }
134
+ }).on('crash', () => {
135
+ console.error('[nodemon] crashed');
136
+ });
137
+ }
138
+
139
+ // Server afterEmit -> start nodemon when both compilers are ready
140
+ nodeServerCompiler.hooks.afterEmit.tap('serverAfterEmitPlugin', () => {
141
+ if (serverReady) return;
142
+ serverReady = true;
143
+ if (clientReady) {
144
+ startNodemon();
145
+ }
146
+ });
147
+
148
+ // Start server compiler watch immediately
149
+ console.info('[crb] 📦 Starting server compiler...');
150
+ nodeServerCompiler.watch({}, (err, stats) => {
151
+ if (err) {
152
+ return console.error(err);
153
+ }
154
+ const statString = stats.toString();
155
+ process.stdout.write(statString + '\n');
156
+ });
157
+
158
+ // Client afterEmit -> start nodemon if server is already ready
159
+ clientCompiler.hooks.afterEmit.tap('clientAfterEmitPlugin', () => {
160
+ if (clientReady) return;
161
+ clientReady = true;
162
+ if (serverReady) {
163
+ startNodemon();
164
+ }
165
+ });
166
+
167
+ // Start webpack dev server
168
+ const devServer = new WebpackDevServer(devServerOptions, clientCompiler);
169
+ devServer.startCallback(err => {
170
+ if (err) {
171
+ console.error('[webpack] devServer listening failed');
172
+ return console.error(err);
173
+ }
174
+ console.info(`[webpack] devServer listening on port ${devPort}`);
175
+ });
176
+
177
+ // Cleanup on SIGTERM/SIGINT
178
+ function cleanup() {
179
+ console.info('[crb] 🛑 Shutting down...');
180
+ if (nodemonInstance) {
181
+ nodemonInstance.emit('quit');
182
+ }
183
+ devServer.stopCallback(() => {
184
+ console.info('[webpack] devServer stopped');
185
+ clientCompiler.close(() => {
186
+ console.info('[webpack] client compiler closed');
187
+ nodeServerCompiler.close(() => {
188
+ console.info('[webpack] server compiler closed');
189
+ process.exit(0);
190
+ });
191
+ });
192
+ });
193
+ }
194
+ process.on('SIGTERM', cleanup);
195
+ process.on('SIGINT', cleanup);
196
+ }
197
+
198
+ const cli = cac('crb');
199
+
200
+ // Dev subcommand
201
+ cli.command('dev', 'Start the SSR dev server pipeline').option('--config <path>', 'Path to webpack config file (required)').option('--env-file <path>', 'Path to .env file (default: .env)').option('--dev-host <host>', 'webpack publicPath / HMR host (default: localhost)').option('--dev-port <port>', 'webpack-dev-server listen port (default: 3000)').option('--dev-listen <host>', 'webpack-dev-server listen host (default: 0.0.0.0)').option('--open', 'Open the browser when the SSR server starts. Use --no-open to disable. (default: true)').option('--inspect [port]', 'Enable the V8 inspector on the SSR server. Optionally specify a port (default: 9229)').option('--inspect-brk [port]', 'Enable the V8 inspector and break before the script starts — useful for debugging server startup. Optionally specify a port (default: 9229). Takes precedence over --inspect.').action(runDev);
202
+ cli.help();
203
+ cli.parse();
204
+ if (!cli.matchedCommand) {
205
+ cli.outputHelp();
206
+ process.exit(1);
207
+ }
208
+ //# sourceMappingURL=build.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"build.js","sources":["../src/build/dev-server.ts","../src/build/cli.ts"],"sourcesContent":["import { execSync } from 'child_process';\nimport path from 'path';\nimport fs from 'fs';\nimport dotenv from 'dotenv';\n// @ts-ignore — nodemon has no type definitions\nimport nodemon from 'nodemon';\nimport webpack from 'webpack';\nimport WebpackDevServer from 'webpack-dev-server';\nconst projectRoot = process.cwd();\nconst DEVSERVER_RUNTIME_GLOBALS = path.resolve(__dirname, 'dev-server-globals.js');\n\ninterface DevOptions {\n config?: string;\n envFile?: string;\n devHost?: string;\n devPort?: string;\n devListen?: string;\n open?: boolean;\n inspect?: boolean | string;\n inspectBrk?: boolean | string;\n}\n\nexport function runDev(args: DevOptions): void {\n const configPath = args.config;\n const devHost = args.devHost || 'localhost';\n const devPort = args.devPort || '3000';\n const devListen = args.devListen || '0.0.0.0';\n const openBrowser = args.open !== false;\n\n // --inspect-brk takes precedence over --inspect.\n // A bare flag (no port value) resolves to true in cac — treat that as the default port.\n const resolveInspectPort = (val: boolean | string | undefined) =>\n val === true || val === undefined ? '9229' : String(val);\n const inspectNodeArg =\n args.inspectBrk !== undefined\n ? `--inspect-brk=${resolveInspectPort(args.inspectBrk)}`\n : `--inspect=${resolveInspectPort(args.inspect)}`;\n\n // Validate --config option\n if (!configPath) {\n console.error('[crb] ❌ Error: --config option is required');\n console.log(\n 'Usage: crb dev --config <path-to-webpack-config> [--dev-host <host>] [--dev-port <port>] [--dev-listen <host>] [--inspect[=port]] [--inspect-brk[=port]]'\n );\n process.exit(1);\n }\n\n console.info('[crb] 🚀 Starting SSR dev server pipeline');\n\n const resolvedConfigPath = path.resolve(projectRoot, configPath);\n\n // Check config file exists\n if (!fs.existsSync(resolvedConfigPath)) {\n console.error(\n `[crb] ❌ Error: Config file not found: ${resolvedConfigPath}`\n );\n process.exit(1);\n }\n\n // Set default host and port\n process.env.DEV_HOST = devHost;\n process.env.DEV_PORT = devPort;\n\n // Load .env file\n const envFilePath = path.resolve(projectRoot, args.envFile || '.env');\n try {\n dotenv.config({ path: envFilePath });\n } catch (e: unknown) {\n const msg = e instanceof Error ? e.message : String(e);\n console.error(\n `[crb] ❌ Error: Failed to load env file (${envFilePath}): ${msg}`\n );\n process.exit(1);\n }\n\n // Validate required environment variables\n const REQUIRED_ENV: string[] = ['ALIAS', 'PROJECT', 'ACCESS_TOKEN'];\n const missingEnv = REQUIRED_ENV.filter(\n (k) => !process.env[k] || !process.env[k].trim()\n );\n if (missingEnv.length) {\n console.error(\n `[crb] ❌ Error: Cannot start dev server. Missing required env vars: ${missingEnv.join(', ')}. ` +\n `Set them in a .env file at the project root or export them in your shell.`\n );\n process.exit(1);\n }\n\n // Load project webpack config\n let webpackConfig: unknown;\n try {\n webpackConfig = require(resolvedConfigPath);\n } catch (e: unknown) {\n const msg = e instanceof Error ? e.message : String(e);\n console.error(\n `[crb] ❌ Error: Failed to load webpack config: ${msg}`\n );\n process.exit(1);\n }\n\n // Validate webpack config is an array (dual-target mode)\n if (!Array.isArray(webpackConfig)) {\n console.error(\n `[crb] ❌ Error: webpack config must be an array [clientConfig, serverConfig]. ` +\n `The config appears to be a single object (CSR/ANALYZE mode). ` +\n `Use the unified webpack.config.js for SSR dev mode.`\n );\n process.exit(1);\n }\n\n const [clientConfig, serverConfig] = webpackConfig as [webpack.Configuration, webpack.Configuration];\n\n // State flags for orchestration\n let clientReady = false;\n let serverReady = false;\n let nodemonStarted = false;\n let browserOpened = false;\n\n // Nodemon reference for cleanup\n let nodemonInstance: ReturnType<typeof nodemon> | null = null;\n\n // Dev server options\n const devServerOptions = {\n host: devListen,\n port: parseInt(devPort, 10),\n headers: { 'Access-Control-Allow-Origin': '*' },\n hot: true,\n historyApiFallback: true,\n devMiddleware: {\n index: 'index_csr.html',\n writeToDisk: true,\n },\n // TODO: Add proxy config from bundle-info.js (DEVSERVER_PROXIES)\n // to proxy API calls and reverse proxy paths to CMS/IIS\n };\n\n // Create dual webpack compilers (single config each → single Compiler, not MultiCompiler)\n const clientCompiler = webpack(clientConfig);\n const nodeServerCompiler = webpack(serverConfig);\n\n // Start nodemon when both compilers are ready\n function startNodemon(): void {\n if (nodemonStarted) return;\n nodemonStarted = true;\n\n console.info('[crb] 🎯 Starting nodemon...');\n nodemonInstance = nodemon({\n script: 'dist/server-dev.js',\n ext: 'js json',\n watch: ['dist/server-dev.js'],\n nodeArgs: [\n inspectNodeArg,\n '-r',\n DEVSERVER_RUNTIME_GLOBALS,\n ],\n })\n .on('start', () => {\n console.info(\n '[nodemon] started. Now starting local web server at port 3001, with hot-reload enabled.'\n );\n if (openBrowser && !browserOpened) {\n browserOpened = true;\n try {\n const cmd =\n process.platform === 'win32'\n ? 'start'\n : process.platform === 'darwin'\n ? 'open'\n : 'xdg-open';\n execSync(`${cmd} http://${process.env.DEV_HOST}:3001/`, {\n windowsHide: true,\n });\n } catch {\n console.info(\n `Please open http://${process.env.DEV_HOST}:3001/ in your browser`\n );\n }\n }\n })\n .on('crash', () => {\n console.error('[nodemon] crashed');\n });\n }\n\n // Server afterEmit -> start nodemon when both compilers are ready\n nodeServerCompiler.hooks.afterEmit.tap('serverAfterEmitPlugin', () => {\n if (serverReady) return;\n serverReady = true;\n\n if (clientReady) {\n startNodemon();\n }\n });\n\n // Start server compiler watch immediately\n console.info('[crb] 📦 Starting server compiler...');\n nodeServerCompiler.watch({}, (err, stats) => {\n if (err) {\n return console.error(err);\n }\n const statString = stats!.toString();\n process.stdout.write(statString + '\\n');\n });\n\n // Client afterEmit -> start nodemon if server is already ready\n clientCompiler.hooks.afterEmit.tap('clientAfterEmitPlugin', () => {\n if (clientReady) return;\n clientReady = true;\n\n if (serverReady) {\n startNodemon();\n }\n });\n\n // Start webpack dev server\n const devServer = new WebpackDevServer(devServerOptions, clientCompiler);\n\n devServer.startCallback((err) => {\n if (err) {\n console.error('[webpack] devServer listening failed');\n return console.error(err);\n }\n console.info(`[webpack] devServer listening on port ${devPort}`);\n });\n\n // Cleanup on SIGTERM/SIGINT\n function cleanup(): void {\n console.info('[crb] 🛑 Shutting down...');\n if (nodemonInstance) {\n nodemonInstance.emit('quit');\n }\n devServer.stopCallback(() => {\n console.info('[webpack] devServer stopped');\n clientCompiler.close(() => {\n console.info('[webpack] client compiler closed');\n nodeServerCompiler.close(() => {\n console.info('[webpack] server compiler closed');\n process.exit(0);\n });\n });\n });\n }\n\n process.on('SIGTERM', cleanup);\n process.on('SIGINT', cleanup);\n}\n","#!/usr/bin/env node\n\nimport { cac } from 'cac';\nimport { runDev } from './dev-server';\n\nconst cli = cac('crb');\n\n// Dev subcommand\ncli\n .command('dev', 'Start the SSR dev server pipeline')\n .option('--config <path>', 'Path to webpack config file (required)')\n .option('--env-file <path>', 'Path to .env file (default: .env)')\n .option(\n '--dev-host <host>',\n 'webpack publicPath / HMR host (default: localhost)'\n )\n .option('--dev-port <port>', 'webpack-dev-server listen port (default: 3000)')\n .option(\n '--dev-listen <host>',\n 'webpack-dev-server listen host (default: 0.0.0.0)'\n )\n .option(\n '--open',\n 'Open the browser when the SSR server starts. Use --no-open to disable. (default: true)'\n )\n .option(\n '--inspect [port]',\n 'Enable the V8 inspector on the SSR server. Optionally specify a port (default: 9229)'\n )\n .option(\n '--inspect-brk [port]',\n 'Enable the V8 inspector and break before the script starts — useful for debugging server startup. Optionally specify a port (default: 9229). Takes precedence over --inspect.'\n )\n .action(runDev);\n\ncli.help();\n\ncli.parse();\nif (!cli.matchedCommand) {\n cli.outputHelp();\n process.exit(1);\n}\n"],"names":["projectRoot","process","cwd","DEVSERVER_RUNTIME_GLOBALS","path","resolve","__dirname","runDev","args","configPath","config","devHost","devPort","devListen","openBrowser","open","resolveInspectPort","val","undefined","String","inspectNodeArg","inspectBrk","inspect","console","error","log","exit","info","resolvedConfigPath","fs","existsSync","env","DEV_HOST","DEV_PORT","envFilePath","envFile","dotenv","e","msg","Error","message","REQUIRED_ENV","missingEnv","filter","k","trim","length","join","webpackConfig","require","Array","isArray","clientConfig","serverConfig","clientReady","serverReady","nodemonStarted","browserOpened","nodemonInstance","devServerOptions","host","port","parseInt","headers","hot","historyApiFallback","devMiddleware","index","writeToDisk","clientCompiler","webpack","nodeServerCompiler","startNodemon","nodemon","script","ext","watch","nodeArgs","on","cmd","platform","execSync","windowsHide","hooks","afterEmit","tap","err","stats","statString","toString","stdout","write","devServer","WebpackDevServer","startCallback","cleanup","emit","stopCallback","close","cli","cac","command","option","action","help","parse","matchedCommand","outputHelp"],"mappings":";;;;;;;;;;AAQA,MAAMA,WAAW,GAAGC,OAAO,CAACC,GAAG,EAAE;AACjC,MAAMC,yBAAyB,GAAGC,IAAI,CAACC,OAAO,CAACC,SAAS,EAAE,uBAAuB,CAAC;AAa3E,SAASC,MAAMA,CAACC,IAAgB,EAAQ;AAC7C,EAAA,MAAMC,UAAU,GAAGD,IAAI,CAACE,MAAM;AAC9B,EAAA,MAAMC,OAAO,GAAGH,IAAI,CAACG,OAAO,IAAI,WAAW;AAC3C,EAAA,MAAMC,OAAO,GAAGJ,IAAI,CAACI,OAAO,IAAI,MAAM;AACtC,EAAA,MAAMC,SAAS,GAAGL,IAAI,CAACK,SAAS,IAAI,SAAS;AAC7C,EAAA,MAAMC,WAAW,GAAGN,IAAI,CAACO,IAAI,KAAK,KAAK;;AAEvC;AACA;AACA,EAAA,MAAMC,kBAAkB,GAAIC,GAAiC,IAC3DA,GAAG,KAAK,IAAI,IAAIA,GAAG,KAAKC,SAAS,GAAG,MAAM,GAAGC,MAAM,CAACF,GAAG,CAAC;EAC1D,MAAMG,cAAc,GAClBZ,IAAI,CAACa,UAAU,KAAKH,SAAS,GACzB,CAAA,cAAA,EAAiBF,kBAAkB,CAACR,IAAI,CAACa,UAAU,CAAC,CAAA,CAAE,GACtD,CAAA,UAAA,EAAaL,kBAAkB,CAACR,IAAI,CAACc,OAAO,CAAC,CAAA,CAAE;;AAErD;EACA,IAAI,CAACb,UAAU,EAAE;AACfc,IAAAA,OAAO,CAACC,KAAK,CAAC,4CAA4C,CAAC;AAC3DD,IAAAA,OAAO,CAACE,GAAG,CACT,0JACF,CAAC;AACDxB,IAAAA,OAAO,CAACyB,IAAI,C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AC;;AAEtB;AACAD,GAAG,CACAE,OAAO,CAAC,KAAK,EAAE,mCAAmC,CAAC,CACnDC,MAAM,CAAC,iBAAiB,EAAE,wCAAwC,CAAC,CACnEA,MAAM,CAAC,mBAAmB,EAAE,mCAAmC,CAAC,CAChEA,MAAM,CACL,mBAAmB,EACnB,oDACF,CAAC,CACAA,MAAM,CAAC,mBAAmB,EAAE,gDAAgD,CAAC,CAC7EA,MAAM,CACL,qBAAqB,EACrB,mDACF,CAAC,CACAA,MAAM,CACL,QAAQ,EACR,wFACF,CAAC,CACAA,MAAM,CACL,kBAAkB,EAClB,sFACF,CAAC,CACAA,MAAM,CACL,sBAAsB,EACtB,+KACF,CAAC,CACAC,MAAM,CAAChG,MAAM,CAAC;AAEjB4F,GAAG,CAACK,IAAI,EAAE;AAEVL,GAAG,CAACM,KAAK,EAAE;AACX,IAAI,CAACN,GAAG,CAACO,cAAc,EAAE;EACvBP,GAAG,CAACQ,UAAU,EAAE;AAChB1G,EAAAA,OAAO,CAACyB,IAAI,CAAC,CAAC,CAAC;AACjB"}
@@ -0,0 +1,15 @@
1
+ import path from 'path';
2
+
3
+ /**
4
+ * This file is emitted as a standalone `cjs/dev-server-globals.js` by rollup.
5
+ * It is loaded by nodemon via the `-r` flag in the SSR server child process.
6
+ * It resolves the consumer's `webpack/define-config` at runtime (using
7
+ * `process.cwd()` = consumer project root) and injects the development
8
+ * defines as global variables.
9
+ */
10
+ const defineConfigPath = path.resolve(process.cwd(), 'webpack', 'define-config');
11
+ const defineConfig = require(defineConfigPath).development;
12
+ Object.entries(defineConfig).forEach(([key, value]) => {
13
+ global[key] = value;
14
+ });
15
+ //# sourceMappingURL=dev-server-globals.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dev-server-globals.js","sources":["../src/build/dev-server-runtime-globals.ts"],"sourcesContent":["/**\n * This file is emitted as a standalone `cjs/dev-server-globals.js` by rollup.\n * It is loaded by nodemon via the `-r` flag in the SSR server child process.\n * It resolves the consumer's `webpack/define-config` at runtime (using\n * `process.cwd()` = consumer project root) and injects the development\n * defines as global variables.\n */\nimport path from 'path';\n\nconst defineConfigPath = path.resolve(process.cwd(), 'webpack', 'define-config');\n\nconst defineConfig = require(defineConfigPath).development as Record<string, string>;\n\nObject.entries(defineConfig).forEach(([key, value]) => {\n global[key] = value;\n});\n"],"names":["defineConfigPath","path","resolve","process","cwd","defineConfig","require","development","Object","entries","forEach","key","value","global"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AAGA,MAAMA,gBAAgB,GAAGC,IAAI,CAACC,OAAO,CAACC,OAAO,CAACC,GAAG,EAAE,EAAE,SAAS,EAAE,eAAe,CAAC;AAEhF,MAAMC,YAAY,GAAGC,OAAO,CAACN,gBAAgB,CAAC,CAACO,WAAqC;AAEpFC,MAAM,CAACC,OAAO,CAACJ,YAAY,CAAC,CAACK,OAAO,CAAC,CAAC,CAACC,GAAG,EAAEC,KAAK,CAAC,KAAK;AACrDC,EAAAA,MAAM,CAACF,GAAG,CAAC,GAAGC,KAAK;AACrB,CAAC,CAAC"}
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env node
2
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,12 @@
1
+ interface DevOptions {
2
+ config?: string;
3
+ envFile?: string;
4
+ devHost?: string;
5
+ devPort?: string;
6
+ devListen?: string;
7
+ open?: boolean;
8
+ inspect?: boolean | string;
9
+ inspectBrk?: boolean | string;
10
+ }
11
+ export declare function runDev(args: DevOptions): void;
12
+ export {};
@@ -1,5 +1,6 @@
1
1
  import { Express } from 'express';
2
- export declare const assetProxy: any;
3
- export declare const deliveryProxy: any;
2
+ import httpProxy from 'http-proxy';
3
+ export declare const assetProxy: httpProxy<import("http").IncomingMessage, import("http").ServerResponse<import("http").IncomingMessage>>;
4
+ export declare const deliveryProxy: httpProxy<import("http").IncomingMessage, import("http").ServerResponse<import("http").IncomingMessage>>;
4
5
  declare const reverseProxies: (app: Express, reverseProxyPaths?: string[]) => void;
5
6
  export default reverseProxies;
package/package.json CHANGED
@@ -1,12 +1,15 @@
1
1
  {
2
2
  "name": "@zengenti/contensis-react-base",
3
- "version": "4.0.1-beta.4",
3
+ "version": "4.0.1-beta.5",
4
4
  "repository": "https://github.com/zengenti/contensis-react-base",
5
5
  "license": "ISC",
6
6
  "description": "Turbocharge your React web apps with Contensis. This package handles all dependencies for creating full featured web apps in React with Contensis and Site View. Routing is driven by Site View, Redux is used for global state management and server-side rendering (SSR) is handled for you. Also taking care of intricate hosting issues such as cache invalidation and supporting authenticated content where required.",
7
7
  "main": "cjs/contensis-react-base.js",
8
8
  "module": "esm/contensis-react-base.js",
9
9
  "types": "models",
10
+ "bin": {
11
+ "crb": "./cjs/build.js"
12
+ },
10
13
  "scripts": {
11
14
  "start": "npm run roll:watch",
12
15
  "build": "npm run clean:lib && tspc && npm run roll:lib",
@@ -45,9 +48,12 @@
45
48
  "@types/query-string": "^5.1.0",
46
49
  "@types/react": "^18.3.23",
47
50
  "@types/react-dom": "^18.3.7",
51
+ "@types/webpack": "^5.28.0",
52
+ "@types/webpack-dev-server": "^4.7.0",
48
53
  "@types/webpack-env": "^1.18.8",
49
54
  "babel-plugin-module-resolver": "^5.0.2",
50
55
  "babel-plugin-styled-components": "^2.1.4",
56
+ "cac": "^6.7.14",
51
57
  "cross-env": "^7.0.3",
52
58
  "eslint": "^9.32.0",
53
59
  "eslint-config-prettier": "^10.1.8",