@michijs/dev-server 0.2.2 → 0.2.4-beta.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.
package/README.md CHANGED
@@ -24,20 +24,29 @@ You have the following CLI commands:
24
24
  <tr>
25
25
  <th>CLI command</th>
26
26
  <th>Default environment</th>
27
+ <th>Description</th>
27
28
  </tr>
28
29
  </thead>
29
30
  <tbody>
30
31
  <tr>
31
32
  <td>start</td>
32
33
  <td>DEVELOPMENT</td>
34
+ <td>Allows to start a dev server as a webpage.</td>
33
35
  </tr>
34
36
  <tr>
35
37
  <td>build</td>
36
38
  <td>PRODUCTION</td>
39
+ <td>Allows to build the src code as a webpage.</td>
37
40
  </tr>
38
41
  <tr>
39
42
  <td>dist</td>
40
43
  <td>DISTRIBUTION</td>
44
+ <td>Allows to distribute the src code as a package. At the moment ESBuild does not support .d.ts files so we still use the Typescript compiler with the tsconfig provided by esbuildOptions field.</td>
45
+ </tr>
46
+ <tr>
47
+ <td>generate-icons</td>
48
+ <td>-</td>
49
+ <td>Allows to generate a full set of icons from a src icon.</td>
41
50
  </tr>
42
51
  </tbody>
43
52
  </table>
@@ -179,9 +188,6 @@ export default config;
179
188
  </tbody>
180
189
  </table>
181
190
 
182
- ## Distribution
183
- At the moment ESBuild does not support .d.ts files so we still use the Typescript compiler with the tsconfig provided by esbuildOptions field.
184
-
185
191
  ## License
186
192
  - [MIT](https://github.com/michijs/dev-server/blob/master/LICENSE.md)
187
193
 
@@ -1,16 +1,14 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.build = void 0;
4
- const config_1 = require("../config/config");
5
- const esbuild_1 = require("esbuild");
6
- function build(callback) {
1
+ import { config } from '../config/config.js';
2
+ import { build as esbuild } from 'esbuild';
3
+ export function build(callback) {
7
4
  return new Promise((resolve) => {
8
- (0, esbuild_1.build)(config_1.config.esbuildOptions).then(() => {
5
+ esbuild(config.esbuildOptions)
6
+ .then(() => {
9
7
  callback?.();
10
8
  resolve(true);
11
- }).catch(() => {
9
+ })
10
+ .catch(() => {
12
11
  return Promise.resolve();
13
12
  });
14
13
  });
15
14
  }
16
- exports.build = build;
@@ -1,17 +1,11 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.dist = void 0;
7
- const tsconfig_1 = require("../config/tsconfig");
8
- const config_1 = require("../config/config");
9
- const child_process_1 = require("child_process");
10
- const fs_1 = __importDefault(require("fs"));
11
- function dist(callback, watch = false) {
12
- if (tsconfig_1.tsconfig.compilerOptions.outDir && fs_1.default.existsSync(tsconfig_1.tsconfig.compilerOptions.outDir)) {
13
- fs_1.default.rmSync(tsconfig_1.tsconfig.compilerOptions.outDir, { recursive: true });
1
+ import { tsconfig } from '../config/tsconfig.js';
2
+ import { config } from '../config/config.js';
3
+ import { exec } from 'child_process';
4
+ import fs from 'fs';
5
+ export function dist(callback, watch = false) {
6
+ if (tsconfig.compilerOptions.outDir &&
7
+ fs.existsSync(tsconfig.compilerOptions.outDir)) {
8
+ fs.rmSync(tsconfig.compilerOptions.outDir, { recursive: true });
14
9
  }
15
- (0, child_process_1.exec)(`tsc ${watch ? '-w' : ''} --project ${config_1.config.esbuildOptions.tsconfig}`, callback);
10
+ exec(`tsc ${watch ? '-w' : ''} --project ${config.esbuildOptions.tsconfig}`, callback);
16
11
  }
17
- exports.dist = dist;
@@ -0,0 +1 @@
1
+ export declare function generateIcons(callback: () => void, src: string): Promise<void>;
@@ -0,0 +1,25 @@
1
+ import sharp from 'sharp';
2
+ import { getPath } from '../utils/getPath.js';
3
+ import { config } from '../config/config.js';
4
+ import { mkdirSync, existsSync } from 'fs';
5
+ import ico from 'sharp-ico';
6
+ export async function generateIcons(callback, src) {
7
+ const sizes = [24, 48, 72, 96, 128, 256, 512];
8
+ const image = sharp(src);
9
+ const destPath = getPath(`${config.public.path}/assets/generated`);
10
+ if (!existsSync(destPath))
11
+ mkdirSync(destPath, { recursive: true });
12
+ await Promise.all([
13
+ ...sizes.map((x) => {
14
+ return image
15
+ .resize(x, x)
16
+ .webp()
17
+ .toFile(getPath(`${destPath}/${src.split('/').at(-1)?.split('.')[0]}-${x}.webp`));
18
+ }),
19
+ ico.sharpsToIco([image], getPath(`${config.public.path}/favicon.ico`), {
20
+ sizes: [16],
21
+ resizeOptions: { width: 16, height: 16 },
22
+ }),
23
+ ]);
24
+ callback();
25
+ }
@@ -1,26 +1,20 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.start = void 0;
7
- const http_1 = __importDefault(require("http"));
8
- const fs_1 = __importDefault(require("fs"));
9
- const config_1 = require("../config/config");
10
- const coloredString_1 = __importDefault(require("../utils/coloredString"));
11
- const getPath_1 = require("../utils/getPath");
12
- const open_1 = __importDefault(require("open"));
13
- const esbuild_1 = require("esbuild");
14
- const node_watch_1 = __importDefault(require("node-watch"));
15
- const copy_1 = require("../utils/copy");
16
- const path_1 = require("path");
17
- const transformers_1 = require("../utils/transformers");
18
- const start = (callback) => {
19
- config_1.config.esbuildOptions.plugins?.push({
1
+ import http from 'http';
2
+ import fs from 'fs';
3
+ import { config, hostURL, localURL, connections } from '../config/config.js';
4
+ import coloredString from '../utils/coloredString.js';
5
+ import { getPath } from '../utils/getPath.js';
6
+ import open from 'open';
7
+ import { context } from 'esbuild';
8
+ import watch from 'node-watch';
9
+ import { copyFile } from '../utils/copy.js';
10
+ import { sep } from 'path';
11
+ import { transformers } from '../utils/transformers.js';
12
+ export const start = (callback) => {
13
+ config.esbuildOptions.plugins?.push({
20
14
  name: 'michijs-dev-server-watch-public-folder',
21
15
  setup(build) {
22
- if (config_1.config.public.path)
23
- (0, node_watch_1.default)(config_1.config.public.path, {
16
+ if (config.public.path)
17
+ watch.default(config.public.path, {
24
18
  encoding: 'utf-8',
25
19
  persistent: true,
26
20
  recursive: true,
@@ -28,31 +22,36 @@ const start = (callback) => {
28
22
  const updated = new Array();
29
23
  const removed = new Array();
30
24
  const added = new Array();
31
- const splittedPath = fileChangedPath.split(path_1.sep);
32
- const srcDir = splittedPath.slice(0, -1).join(path_1.sep);
25
+ const splittedPath = fileChangedPath.split(sep);
26
+ const srcDir = splittedPath.slice(0, -1).join(sep);
33
27
  const fileName = splittedPath.at(-1);
34
- const outDir = srcDir.replace(config_1.config.public.path, build.initialOptions.outdir);
35
- fs_1.default.rmSync((0, getPath_1.getPath)(`${outDir}/${transformers_1.transformers.find(x => x.fileRegex.test(fileName))?.pathTransformer?.(fileName) ?? fileName}`), { force: true, recursive: true });
28
+ const outDir = srcDir.replace(config.public.path, build.initialOptions.outdir);
29
+ fs.rmSync(getPath(`${outDir}/${transformers
30
+ .find((x) => x.fileRegex.test(fileName))
31
+ ?.pathTransformer?.(fileName) ?? fileName}`), { force: true, recursive: true });
36
32
  if (event === 'remove')
37
33
  removed.push(fileChangedPath);
38
34
  else {
39
35
  updated.push(fileChangedPath);
40
- (0, copy_1.copyFile)(srcDir, fileName, outDir);
36
+ copyFile(srcDir, fileName, outDir);
41
37
  }
42
38
  // Refresh browser
43
- config_1.connections.forEach(x => x.write(`event: change\ndata: ${JSON.stringify({
44
- added, removed, updated
39
+ connections.forEach((x) => x.write(`event: change\ndata: ${JSON.stringify({
40
+ added,
41
+ removed,
42
+ updated,
45
43
  })}\n\n`));
46
44
  });
47
- }
45
+ },
48
46
  });
49
- (0, esbuild_1.context)(config_1.config.esbuildOptions).then(async (buildContext) => {
47
+ context(config.esbuildOptions).then(async (buildContext) => {
50
48
  const { host: esbuildHost, port: esbuildPort } = await buildContext.serve({
51
- servedir: config_1.config.esbuildOptions.outdir,
49
+ servedir: config.esbuildOptions.outdir,
52
50
  });
53
- http_1.default.createServer(async (req, res) => {
51
+ http
52
+ .createServer(async (req, res) => {
54
53
  if (req.url === '/esbuild')
55
- config_1.connections.push(res);
54
+ connections.push(res);
56
55
  const esbuildProxyRequestOptions = {
57
56
  hostname: esbuildHost,
58
57
  port: esbuildPort,
@@ -61,12 +60,12 @@ const start = (callback) => {
61
60
  headers: req.headers,
62
61
  };
63
62
  // Forward each incoming request to esbuild
64
- const proxyReq = http_1.default.request(esbuildProxyRequestOptions, proxyRes => {
63
+ const proxyReq = http.request(esbuildProxyRequestOptions, (proxyRes) => {
65
64
  // If esbuild returns "not found", send a custom 404 page
66
65
  if (!proxyRes.statusCode || proxyRes.statusCode === 404) {
67
66
  res.writeHead(200, { 'Content-Type': 'text/html' });
68
67
  // TODO: Find a better way to do this
69
- res.end(fs_1.default.readFileSync((0, getPath_1.getPath)(`${config_1.config.esbuildOptions.outdir}/${config_1.config.public.indexName}`)));
68
+ res.end(fs.readFileSync(getPath(`${config.esbuildOptions.outdir}/${config.public.indexName}`)));
70
69
  return;
71
70
  }
72
71
  // Otherwise, forward the response from esbuild to the client
@@ -75,16 +74,16 @@ const start = (callback) => {
75
74
  });
76
75
  // Forward the body of the request to esbuild
77
76
  req.pipe(proxyReq, { end: true });
78
- }).listen(config_1.config.port);
77
+ })
78
+ .listen(config.port);
79
79
  console.log(`
80
80
  Server running at:
81
81
 
82
- > Network: ${(0, coloredString_1.default)(config_1.hostURL)}
83
- > Local: ${(0, coloredString_1.default)(config_1.localURL)}`);
82
+ > Network: ${coloredString(hostURL)}
83
+ > Local: ${coloredString(localURL)}`);
84
84
  callback();
85
85
  buildContext.watch();
86
- if (config_1.config.openBrowser)
87
- (0, open_1.default)(config_1.localURL);
86
+ if (config.openBrowser)
87
+ open(localURL);
88
88
  });
89
89
  };
90
- exports.start = start;
@@ -1,7 +1,4 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Timer = void 0;
4
- class Timer {
1
+ export class Timer {
5
2
  start;
6
3
  startTimer() {
7
4
  this.start = Date.now();
@@ -10,4 +7,3 @@ class Timer {
10
7
  return Date.now() - this.start;
11
8
  }
12
9
  }
13
- exports.Timer = Timer;
package/bin/cli.js CHANGED
@@ -1,72 +1,65 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
25
- var __importDefault = (this && this.__importDefault) || function (mod) {
26
- return (mod && mod.__esModule) ? mod : { "default": mod };
27
- };
28
- Object.defineProperty(exports, "__esModule", { value: true });
29
- exports.cli = void 0;
30
- const coloredString_1 = __importDefault(require("./utils/coloredString"));
31
- const yargs = __importStar(require("yargs"));
32
- const Timer_1 = require("./classes/Timer");
33
- async function cli() {
34
- const timer = new Timer_1.Timer();
1
+ import coloredString from './utils/coloredString.js';
2
+ import yargs from 'yargs';
3
+ import { Timer } from './classes/Timer.js';
4
+ import { hideBin } from 'yargs/helpers';
5
+ export async function cli() {
6
+ const timer = new Timer();
35
7
  const showReadyMessage = () => console.log(`
36
- ${(0, coloredString_1.default)(`Ready in ${timer.endTimer()}ms.`)}`);
8
+ ${coloredString(`Ready in ${timer.endTimer()}ms.`)}`);
37
9
  timer.startTimer();
38
- const args = await yargs
10
+ const args = await yargs(hideBin(process.argv))
39
11
  .option('start', {
40
12
  type: 'boolean',
41
- default: false
13
+ default: false,
14
+ description: 'Allows to start a dev server as a webpage.',
42
15
  })
43
16
  .option('build', {
44
17
  type: 'boolean',
45
- default: false
18
+ default: false,
19
+ description: 'Allows to build the src code as a webpage.',
46
20
  })
47
21
  .option('dist', {
48
22
  type: 'boolean',
49
- default: false
23
+ default: false,
24
+ description: 'Allows to distribute the src code as a package.',
25
+ })
26
+ .option('generate-icons', {
27
+ type: 'string',
28
+ description: 'Allows to generate a full set of icons from a src icon.',
29
+ })
30
+ .option('watch', {
31
+ type: 'boolean',
32
+ default: false,
33
+ alias: 'w',
50
34
  })
51
35
  .option('env', {
52
- type: 'string'
36
+ type: 'string',
37
+ })
38
+ .option('env', {
39
+ type: 'string',
53
40
  })
54
41
  .help()
55
- .alias('help', 'h')
56
- .argv;
57
- process.env.NODE_ENV = args.env || (args.build ? 'PRODUCTION' : args.dist ? 'DISTRIBUTION' : 'DEVELOPMENT');
58
- console.log((0, coloredString_1.default)(` Running in ${process.env.NODE_ENV} mode`));
42
+ .alias('help', 'h').argv;
43
+ process.env.NODE_ENV =
44
+ args.env ||
45
+ (args.build ? 'PRODUCTION' : args.dist ? 'DISTRIBUTION' : 'DEVELOPMENT');
46
+ const generateIcons = args.generateIcons === '' ? 'public/assets/icon.svg' : args.generateIcons;
47
+ if (generateIcons) {
48
+ const action = await import('./actions/generateIcons.js');
49
+ await action.generateIcons(showReadyMessage, generateIcons);
50
+ }
51
+ else
52
+ console.log(coloredString(` Running in ${process.env.NODE_ENV} mode`));
59
53
  if (args.start) {
60
- const action = await Promise.resolve().then(() => __importStar(require('./actions/start')));
54
+ const action = await import('./actions/start.js');
61
55
  action.start(showReadyMessage);
62
56
  }
63
57
  if (args.build) {
64
- const action = await Promise.resolve().then(() => __importStar(require('./actions/build')));
58
+ const action = await import('./actions/build.js');
65
59
  action.build(showReadyMessage);
66
60
  }
67
61
  if (args.dist) {
68
- const action = await Promise.resolve().then(() => __importStar(require('./actions/dist')));
69
- action.dist(showReadyMessage);
62
+ const action = await import('./actions/dist.js');
63
+ action.dist(showReadyMessage, args.watch);
70
64
  }
71
65
  }
72
- exports.cli = cli;
@@ -1,5 +1,5 @@
1
- /// <reference types="node" />
2
- import { Config } from '../types';
1
+ /// <reference types="node" resolution-mode="require"/>
2
+ import { Config } from '../types.js';
3
3
  import http from 'http';
4
4
  export declare const connections: (http.ServerResponse<http.IncomingMessage> & {
5
5
  req: http.IncomingMessage;
@@ -1,34 +1,33 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.localURL = exports.hostURL = exports.config = exports.connections = void 0;
7
- const fs_1 = __importDefault(require("fs"));
8
- const coloredString_1 = __importDefault(require("../utils/coloredString"));
9
- const copy_1 = require("../utils/copy");
10
- const getPath_1 = require("../utils/getPath");
11
- const Timer_1 = require("../classes/Timer");
12
- const getIPAddress_1 = require("./getIPAddress");
13
- const userConfig_1 = require("./userConfig");
14
- const transformers_1 = require("../utils/transformers");
1
+ import fs from 'fs';
2
+ import coloredString from '../utils/coloredString.js';
3
+ import { copy } from '../utils/copy.js';
4
+ import { getPath } from '../utils/getPath.js';
5
+ import { Timer } from '../classes/Timer.js';
6
+ import { getIPAddress } from './getIPAddress.js';
7
+ import { userConfig } from './userConfig.js';
8
+ import { resolve } from 'path';
9
+ import { jsAndTsRegex, jsonTransformer, notJsAndTsRegex, } from '../utils/transformers.js';
10
+ import { dirname } from 'path';
11
+ import { fileURLToPath } from 'url';
15
12
  const minify = process.env.NODE_ENV === 'PRODUCTION';
16
- const devServerListener = process.env.NODE_ENV === 'DEVELOPMENT' ? [(0, getPath_1.getPath)(`${__dirname}/public/client.js`)] : [];
17
- exports.connections = [];
13
+ const devServerListener = process.env.NODE_ENV === 'DEVELOPMENT'
14
+ ? [getPath(`${dirname(fileURLToPath(import.meta.url))}/public/client.js`)]
15
+ : [];
16
+ export const connections = [];
18
17
  const config = {
19
18
  port: 3000,
20
19
  openBrowser: process.env.NODE_ENV === 'DEVELOPMENT',
21
20
  showLinkedPackages: true,
22
- ...userConfig_1.userConfig,
21
+ ...userConfig,
23
22
  // protocol: 'http',
24
23
  public: {
25
24
  path: 'public',
26
25
  indexName: 'index.html',
27
26
  minify: minify,
28
- ...(userConfig_1.userConfig.public ?? {}),
27
+ ...(userConfig.public ?? {}),
29
28
  manifest: {
30
29
  name: 'manifest.json',
31
- ...(userConfig_1.userConfig.public?.manifest ?? {})
30
+ ...(userConfig.public?.manifest ?? {}),
32
31
  },
33
32
  },
34
33
  esbuildOptions: {
@@ -44,7 +43,7 @@ const config = {
44
43
  format: 'esm',
45
44
  target: 'esnext',
46
45
  logLevel: 'error',
47
- ...(userConfig_1.userConfig.esbuildOptions ?? {}),
46
+ ...(userConfig.esbuildOptions ?? {}),
48
47
  // Still not supported
49
48
  // bug .css.ts
50
49
  // plugins: [
@@ -67,72 +66,78 @@ const config = {
67
66
  // }
68
67
  // ],
69
68
  plugins: [
70
- ...(userConfig_1.userConfig.esbuildOptions?.plugins ?? []),
69
+ ...(userConfig.esbuildOptions?.plugins ?? []),
71
70
  {
72
71
  name: 'michijs-dev-server',
73
72
  setup(build) {
74
73
  // Clean outdir
75
74
  if (build.initialOptions.outdir) {
76
- if (fs_1.default.existsSync(build.initialOptions.outdir)) {
77
- fs_1.default.rmSync(build.initialOptions.outdir, { recursive: true });
75
+ if (fs.existsSync(build.initialOptions.outdir)) {
76
+ fs.rmSync(build.initialOptions.outdir, { recursive: true });
78
77
  }
79
- fs_1.default.mkdirSync(build.initialOptions.outdir, { recursive: true });
78
+ fs.mkdirSync(build.initialOptions.outdir, { recursive: true });
80
79
  }
81
80
  if (config.public.manifest?.options && config.public.manifest.name) {
82
- const transformedFile = transformers_1.jsonTransformer.transformer(JSON.stringify(config.public.manifest.options, null, 2));
83
- fs_1.default.writeFileSync((0, getPath_1.getPath)(`${build.initialOptions.outdir}/${config.public.manifest.name}`), transformedFile);
81
+ const transformedFile = jsonTransformer.transformer(JSON.stringify(config.public.manifest.options, null, 2));
82
+ fs.writeFileSync(getPath(`${build.initialOptions.outdir}/${config.public.manifest.name}`), transformedFile);
84
83
  }
85
84
  // Copy public path - Omit to copy service worker - will be transformed after
86
85
  if (config.public.path && build.initialOptions.outdir)
87
- (0, copy_1.copy)(config.public.path, build.initialOptions.outdir, [transformers_1.jsAndTsRegex]);
88
- const buildTimer = new Timer_1.Timer();
86
+ copy(config.public.path, build.initialOptions.outdir, [
87
+ jsAndTsRegex,
88
+ ]);
89
+ const buildTimer = new Timer();
89
90
  let firstLoad = true;
90
91
  build.onStart(() => buildTimer.startTimer());
91
92
  build.onEnd(() => {
92
93
  // first-load sw - Omit to copy any other non-js file
93
94
  if (firstLoad && config.public.path && build.initialOptions.outdir)
94
- (0, copy_1.copy)(config.public.path, build.initialOptions.outdir, [transformers_1.notJsAndTsRegex]);
95
- console.log((0, coloredString_1.default)(` Build finished in ${buildTimer.endTimer()}ms`));
95
+ copy(config.public.path, build.initialOptions.outdir, [
96
+ notJsAndTsRegex,
97
+ ]);
98
+ console.log(coloredString(` Build finished in ${buildTimer.endTimer()}ms`));
96
99
  firstLoad = false;
97
100
  });
98
- }
99
- }
101
+ },
102
+ },
100
103
  ],
101
104
  define: {
102
105
  // Intentionally added before process
103
106
  process: JSON.stringify({
104
107
  env: {
105
108
  NODE_ENV: process.env.NODE_ENV,
106
- ...(userConfig_1.userConfig.env ?? {})
107
- }
108
- })
109
+ ...(userConfig.env ?? {}),
110
+ },
111
+ }),
109
112
  },
110
- inject: [...devServerListener, ...(userConfig_1.userConfig.esbuildOptions?.inject ?? [])],
111
- ...(userConfig_1.userConfig.esbuildOptions?.define ?? {}),
112
- }
113
+ inject: [
114
+ ...devServerListener,
115
+ ...(userConfig.esbuildOptions?.inject ?? []),
116
+ ],
117
+ ...(userConfig.esbuildOptions?.define ?? {}),
118
+ },
113
119
  };
114
- exports.config = config;
115
- const hostURL = `http://${(0, getIPAddress_1.getIPAddress)()}:${config.port}`;
116
- exports.hostURL = hostURL;
120
+ const hostURL = `http://${getIPAddress()}:${config.port}`;
117
121
  const localURL = `http://localhost:${config.port}`;
118
- exports.localURL = localURL;
119
122
  // const hostURL = `${config.protocol}://${config.hostname}:${config.port}`;
120
123
  // const localURL = `${config.protocol}://localhost:${config.port}`;
121
- function findSymbolickLinkRealPath(path) {
122
- if (fs_1.default.lstatSync(path).isSymbolicLink()) {
123
- return findSymbolickLinkRealPath(fs_1.default.readlinkSync(path));
124
+ function findSymbolickLinkRealPath(packagePath) {
125
+ if (fs.lstatSync(packagePath).isSymbolicLink()) {
126
+ // Getting absolute path for the simbolic link
127
+ return resolve(fs.readlinkSync(packagePath));
124
128
  }
125
- return path;
129
+ return packagePath;
126
130
  }
127
131
  if (config.showLinkedPackages) {
128
- const packageJson = JSON.parse(fs_1.default.readFileSync('package.json', 'utf8'));
132
+ const packageJson = JSON.parse(fs.readFileSync('package.json', 'utf8'));
129
133
  const dependencies = Object.keys(packageJson.dependencies || {});
130
134
  const devDependencies = Object.keys(packageJson.devDependencies || {});
131
- dependencies.concat(devDependencies).forEach(packagePath => {
132
- const packagePathOnNodeModules = (0, getPath_1.getPath)(`node_modules/${packagePath}`);
133
- if (fs_1.default.lstatSync(packagePathOnNodeModules).isSymbolicLink()) {
135
+ dependencies.concat(devDependencies).forEach((packagePath) => {
136
+ const packagePathOnNodeModules = getPath(`node_modules/${packagePath}`);
137
+ if (fs.lstatSync(packagePathOnNodeModules).isSymbolicLink()) {
134
138
  const pathToWatch = findSymbolickLinkRealPath(packagePathOnNodeModules);
135
- console.log((0, coloredString_1.default)(` Linked package found at "${pathToWatch}"`));
139
+ console.log(coloredString(` Linked package found at "${pathToWatch}"`));
136
140
  }
137
141
  });
138
142
  }
143
+ export { config, hostURL, localURL };
@@ -1,9 +1,6 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getIPAddress = void 0;
4
- const os_1 = require("os");
5
- function getIPAddress() {
6
- const interfaces = (0, os_1.networkInterfaces)();
1
+ import { networkInterfaces } from 'os';
2
+ export function getIPAddress() {
3
+ const interfaces = networkInterfaces();
7
4
  for (const devName in interfaces) {
8
5
  const iface = interfaces[devName];
9
6
  if (iface)
@@ -15,4 +12,3 @@ function getIPAddress() {
15
12
  }
16
13
  return '0.0.0.0';
17
14
  }
18
- exports.getIPAddress = getIPAddress;
@@ -0,0 +1 @@
1
+ export {};
@@ -1 +1,2 @@
1
1
  new EventSource('/esbuild').addEventListener('change', () => location.reload());
2
+ export {};
@@ -1,16 +1,11 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.tsconfig = void 0;
7
- const config_1 = require("./config");
8
- const fs_1 = __importDefault(require("fs"));
1
+ import { config } from './config.js';
2
+ import fs from 'fs';
9
3
  let tsconfig;
10
- exports.tsconfig = tsconfig;
11
- if (config_1.config.esbuildOptions.tsconfig && fs_1.default.existsSync(config_1.config.esbuildOptions?.tsconfig)) {
12
- exports.tsconfig = tsconfig = JSON.parse(fs_1.default.readFileSync(config_1.config.esbuildOptions.tsconfig, 'utf-8'));
4
+ if (config.esbuildOptions.tsconfig &&
5
+ fs.existsSync(config.esbuildOptions?.tsconfig)) {
6
+ tsconfig = JSON.parse(fs.readFileSync(config.esbuildOptions.tsconfig, 'utf-8'));
13
7
  }
14
8
  else {
15
- throw `Unable to find tsconfig at ${config_1.config.esbuildOptions.tsconfig}`;
9
+ throw `Unable to find tsconfig at ${config.esbuildOptions.tsconfig}`;
16
10
  }
11
+ export { tsconfig };
@@ -1,2 +1,2 @@
1
- import { ServerConfig } from '../types';
1
+ import { ServerConfig } from '../types.js';
2
2
  export declare const userConfig: ServerConfig;