slicejs-cli 2.9.2 → 2.9.4

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/client.js CHANGED
@@ -137,9 +137,15 @@ sliceClient
137
137
  const buildCommand = sliceClient.command("build")
138
138
  .description("Build Slice.js project for production")
139
139
  .action(async (options) => {
140
- await runWithVersionCheck(async () => {
141
- await build(options);
142
- });
140
+ const prevEnv = process.env.NODE_ENV;
141
+ process.env.NODE_ENV = 'production';
142
+ try {
143
+ await runWithVersionCheck(async () => {
144
+ await build(options);
145
+ });
146
+ } finally {
147
+ process.env.NODE_ENV = prevEnv;
148
+ }
143
149
  });
144
150
 
145
151
  buildCommand
@@ -168,35 +174,43 @@ buildCommand
168
174
  // DEV COMMAND (DEVELOPMENT)
169
175
  sliceClient
170
176
  .command("dev")
171
- .description("Start development server")
177
+ .description("Start development server with hot reload enabled by default")
172
178
  .option("-p, --port <port>", "Port for development server", 3000)
173
- .option("-w, --watch", "Enable watch mode for file changes")
179
+ .option("--no-hmr", "Disable hot module reload (enabled by default)")
174
180
  .action(async (options) => {
175
- await runWithVersionCheck(async () => {
176
- await startServer({
177
- mode: 'development',
178
- port: parseInt(options.port),
179
- watch: options.watch,
180
- bundled: false
181
+ const prevEnv = process.env.NODE_ENV;
182
+ process.env.NODE_ENV = 'development';
183
+ try {
184
+ await runWithVersionCheck(async () => {
185
+ await startServer({
186
+ mode: 'development',
187
+ port: parseInt(options.port),
188
+ watch: options.hmr
189
+ });
181
190
  });
182
- });
191
+ } finally {
192
+ process.env.NODE_ENV = prevEnv;
193
+ }
183
194
  });
184
195
 
185
196
  // START COMMAND - PRODUCTION MODE
186
197
  sliceClient
187
198
  .command("start")
188
- .description("Start production server")
199
+ .description("Serve production files from dist/ (requires prior slice build)")
189
200
  .option("-p, --port <port>", "Port for server", 3000)
190
- .option("-w, --watch", "Enable watch mode for file changes")
191
201
  .action(async (options) => {
192
- await runWithVersionCheck(async () => {
193
- await startServer({
194
- mode: 'production',
195
- port: parseInt(options.port),
196
- watch: options.watch,
197
- bundled: false
202
+ const prevEnv = process.env.NODE_ENV;
203
+ process.env.NODE_ENV = 'production';
204
+ try {
205
+ await runWithVersionCheck(async () => {
206
+ await startServer({
207
+ mode: 'production',
208
+ port: parseInt(options.port)
209
+ });
198
210
  });
199
- });
211
+ } finally {
212
+ process.env.NODE_ENV = prevEnv;
213
+ }
200
214
  });
201
215
 
202
216
  // COMPONENT COMMAND GROUP - For local component management
@@ -88,18 +88,22 @@ function startNodeServer(port, mode) {
88
88
  const args = [apiIndexPath];
89
89
  if (mode === 'production') {
90
90
  args.push('--production');
91
- } else if (mode === 'bundled') {
92
- args.push('--bundled');
93
91
  } else {
94
92
  args.push('--development');
95
93
  }
96
94
 
95
+ // Ensure the spawned server process receives NODE_ENV consistent with the
96
+ // requested mode. This guarantees code that only checks process.env.NODE_ENV
97
+ // (instead of CLI flags) will behave as expected.
98
+ const serverEnv = {
99
+ ...process.env,
100
+ PORT: port,
101
+ NODE_ENV: mode === 'production' ? 'production' : (process.env.NODE_ENV || 'development')
102
+ };
103
+
97
104
  const serverProcess = spawn('node', args, {
98
105
  stdio: ['inherit', 'pipe', 'pipe'],
99
- env: {
100
- ...process.env,
101
- PORT: port
102
- }
106
+ env: serverEnv
103
107
  });
104
108
 
105
109
  let serverStarted = false;
@@ -210,7 +214,7 @@ export default async function startServer(options = {}) {
210
214
  }
211
215
  Print.info('Production mode: serving optimized files from /dist');
212
216
  } else {
213
- Print.info('Development mode: serving files from /src with hot reload');
217
+ Print.info('Development mode: serving files from /src (HMR enabled)');
214
218
  }
215
219
 
216
220
  Print.newLine();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "slicejs-cli",
3
- "version": "2.9.2",
3
+ "version": "2.9.4",
4
4
  "description": "Command client for developing web applications with Slice.js framework",
5
5
  "main": "client.js",
6
6
  "bin": {
@@ -29,6 +29,8 @@
29
29
  "preferGlobal": false,
30
30
  "license": "ISC",
31
31
  "dependencies": {
32
+ "@babel/parser": "^7.28.5",
33
+ "@babel/traverse": "^7.28.5",
32
34
  "chalk": "^5.6.2",
33
35
  "chokidar": "^3.6.0",
34
36
  "clean-css": "^5.3.3",
@@ -39,8 +41,6 @@
39
41
  "inquirer": "^12.4.2",
40
42
  "ora": "^8.2.0",
41
43
  "slicejs-web-framework": "latest",
42
- "terser": "^5.43.1",
43
- "@babel/parser": "^7.28.5",
44
- "@babel/traverse": "^7.28.5"
44
+ "terser": "^5.43.1"
45
45
  }
46
46
  }