wirejs-scripts 3.0.1 → 3.0.3

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/bin.js CHANGED
@@ -12,6 +12,7 @@ import { rimraf } from 'rimraf';
12
12
  import { JSDOM } from 'jsdom';
13
13
  import { useJSDOM } from 'wirejs-dom/v2';
14
14
  import { requiresContext, Context, CookieJar } from 'wirejs-resources';
15
+ import { prebuildApi } from 'wirejs-resources/internal';
15
16
 
16
17
  const CWD = process.cwd();
17
18
  const webpackConfig = webpackConfigure(process.env, process.argv);
@@ -89,6 +90,7 @@ async function callApiMethod(api, call, context) {
89
90
  }, context);
90
91
  }
91
92
  } catch (error) {
93
+ console.log(error);
92
94
  return { error: error.message };
93
95
  }
94
96
  }
@@ -275,10 +277,10 @@ async function trySSRPath(req, res) {
275
277
 
276
278
  try {
277
279
  useJSDOM(JSDOM);
278
- global.self = global.window;
279
- await import(`${srcPath}?cache-id=${new Date().getTime()}`);
280
+ const self = {};
281
+ const moduleData = await fs.promises.readFile(srcPath);
282
+ eval(`${moduleData}`);
280
283
  const module = self.exports;
281
- console.log({module});
282
284
  if (typeof module.generate === 'function') {
283
285
  const doc = await module.generate(context);
284
286
  const doctype = doc.parentNode.doctype?.name || '';
@@ -295,7 +297,7 @@ async function trySSRPath(req, res) {
295
297
  doc.parentNode.body.appendChild(script);
296
298
  }
297
299
 
298
- res.setHeader('Content-type', 'text/html; charset=utf-8')
300
+ res.setHeader('Content-type', 'text/html; charset=utf-8');
299
301
  res.end([
300
302
  doctype ? `<!doctype ${doctype}>\n` : '',
301
303
  doc.outerHTML
@@ -368,11 +370,16 @@ async function compile(watch = false) {
368
370
  ...webpackConfig,
369
371
  mode: 'development',
370
372
  watch: true
371
- }, () => {}).run(() => {});
373
+ }, () => {
374
+ console.log();
375
+ console.log('Compiled: http://localhost:3000/');
376
+ }).run(() => {});
372
377
 
373
378
  logger.log('Starting server...');
374
379
  const server = http.createServer(handleRequest);
375
- server.listen(3000);
380
+ server.listen(3000).on('listening', () => {
381
+ console.log('Started listening on http://localhost:3000/')
382
+ });
376
383
  } else {
377
384
  logger.log('instantiating webpack compiler');
378
385
  compiler = webpack(webpackConfig);
@@ -434,8 +441,13 @@ const engine = {
434
441
  // explicit exit forces lingering child processes to die.
435
442
  logger.log('stopping')
436
443
  process.exit();
437
- }
444
+ },
438
445
 
446
+ async ['prebuild-api']() {
447
+ logger.log("prebuilding api...");
448
+ await prebuildApi();
449
+ logger.log("api prebuild finished");
450
+ },
439
451
  };
440
452
 
441
453
  if (typeof engine[action] === 'function') {
@@ -23,10 +23,6 @@ marked.setOptions({
23
23
  }
24
24
  });
25
25
 
26
- const BUILD_ID = (new Date()).getTime();
27
-
28
- fs.writeFileSync('./src/build_id.json', JSON.stringify(BUILD_ID.toString()));
29
-
30
26
  function distPath({ subpathOut = '', subpathIn = '', extensionOut } = {}) {
31
27
  return function ({ context, absoluteFilename }) {
32
28
  const prefixIn = path.resolve(context, subpathIn);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "wirejs-scripts",
3
- "version": "3.0.1",
3
+ "version": "3.0.3",
4
4
  "description": "Basic build and start commands for wirejs apps",
5
5
  "type": "module",
6
6
  "bin": {
@@ -25,15 +25,12 @@
25
25
  "css-loader": "^5.2.0",
26
26
  "file-loader": "^6.2.0",
27
27
  "glob": "^7.2.0",
28
- "highlight.js": "^11.1.0",
29
28
  "jsdom": "^25.0.1",
30
29
  "marked": "^2.0.1",
31
30
  "raw-loader": "^4.0.2",
32
31
  "rimraf": "^6.0.1",
33
32
  "style-loader": "^2.0.0",
34
33
  "webpack": "^5.97.1",
35
- "webpack-cli": "^6.0.1",
36
- "webpack-dev-server": "^5.2.0",
37
34
  "wirejs-dom": "^1.0.34"
38
35
  }
39
36
  }