oc-server 3.1.0 → 3.1.1

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/dist/cli/cli.js CHANGED
@@ -52,15 +52,35 @@ function cli() {
52
52
  }
53
53
  process.exit(0);
54
54
  }
55
- let template;
56
- try {
57
- template = require(`${templateType}-compiler/dist/lib/hmr`);
55
+ function tryRequire(name) {
56
+ try {
57
+ return { success: true, value: require(name) };
58
+ }
59
+ catch (e) {
60
+ return { success: false, value: e };
61
+ }
58
62
  }
59
- catch (e) {
60
- console.error(`The template ${templateType} is not supported. Try updating to the last version`);
63
+ const result = tryRequire(`${templateType}-compiler/dist/lib/hmr`);
64
+ if (!result.success) {
65
+ const code = String(result.value.code);
66
+ if (code === 'ERR_REQUIRE_ESM') {
67
+ console.error('You are using an older version of node that does not support ESM on require. Please update to the latest 22.x or higher');
68
+ }
69
+ else if (code === 'MODULE_NOT_FOUND') {
70
+ const baseResult = tryRequire(`${templateType}-compiler`);
71
+ if (baseResult.success) {
72
+ console.error(`The template ${templateType} is not supported. Try updating to the last version`);
73
+ }
74
+ else {
75
+ console.error(`Could not find the template compiler library: ${templateType}-compiler in your project`);
76
+ }
77
+ }
78
+ else {
79
+ console.error(result.value);
80
+ }
61
81
  process.exit(1);
62
82
  }
63
83
  if (command === 'dev') {
64
- (0, server_1.createServer)({ template, port });
84
+ (0, server_1.createServer)({ template: result.value, port });
65
85
  }
66
86
  }
package/dist/cli/index.js CHANGED
File without changes
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "oc-server",
3
- "version": "3.1.0",
3
+ "version": "3.1.1",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",