@modern-js/server 2.15.1-alpha.0 → 2.17.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.
Files changed (98) hide show
  1. package/CHANGELOG.md +25 -0
  2. package/dist/cjs/constants.js +12 -28
  3. package/dist/cjs/dev-tools/dev-middleware/hmr-client/createSocketUrl.js +14 -32
  4. package/dist/cjs/dev-tools/dev-middleware/hmr-client/index.js +24 -42
  5. package/dist/cjs/dev-tools/dev-middleware/index.js +45 -50
  6. package/dist/cjs/dev-tools/dev-middleware/socketServer.js +48 -46
  7. package/dist/cjs/dev-tools/https/index.js +21 -38
  8. package/dist/cjs/dev-tools/mock/getMockData.js +33 -33
  9. package/dist/cjs/dev-tools/mock/index.js +67 -47
  10. package/dist/cjs/dev-tools/register/index.js +59 -70
  11. package/dist/cjs/dev-tools/watcher/dependencyTree.js +52 -55
  12. package/dist/cjs/dev-tools/watcher/index.js +52 -53
  13. package/dist/cjs/dev-tools/watcher/statsCache.js +37 -47
  14. package/dist/cjs/index.js +16 -28
  15. package/dist/cjs/server/devServer.js +163 -109
  16. package/dist/cjs/server/index.js +11 -29
  17. package/dist/cjs/types.js +4 -15
  18. package/dist/esm/constants.js +19 -20
  19. package/dist/esm/dev-tools/dev-middleware/hmr-client/createSocketUrl.js +43 -44
  20. package/dist/esm/dev-tools/dev-middleware/hmr-client/index.js +148 -157
  21. package/dist/esm/dev-tools/dev-middleware/index.js +307 -291
  22. package/dist/esm/dev-tools/dev-middleware/socketServer.js +216 -202
  23. package/dist/esm/dev-tools/https/index.js +189 -182
  24. package/dist/esm/dev-tools/mock/getMockData.js +297 -278
  25. package/dist/esm/dev-tools/mock/index.js +198 -192
  26. package/dist/esm/dev-tools/register/index.js +141 -141
  27. package/dist/esm/dev-tools/watcher/dependencyTree.js +153 -138
  28. package/dist/esm/dev-tools/watcher/index.js +187 -175
  29. package/dist/esm/dev-tools/watcher/statsCache.js +118 -116
  30. package/dist/esm/index.js +9 -8
  31. package/dist/esm/server/devServer.js +803 -766
  32. package/dist/esm/server/index.js +80 -76
  33. package/dist/esm/types.js +1 -1
  34. package/dist/esm-node/constants.js +4 -5
  35. package/dist/esm-node/dev-tools/dev-middleware/hmr-client/createSocketUrl.js +2 -11
  36. package/dist/esm-node/dev-tools/dev-middleware/hmr-client/index.js +125 -139
  37. package/dist/esm-node/dev-tools/dev-middleware/index.js +31 -17
  38. package/dist/esm-node/dev-tools/dev-middleware/socketServer.js +33 -12
  39. package/dist/esm-node/dev-tools/https/index.js +13 -15
  40. package/dist/esm-node/dev-tools/mock/getMockData.js +20 -12
  41. package/dist/esm-node/dev-tools/mock/index.js +7 -7
  42. package/dist/esm-node/dev-tools/register/index.js +38 -29
  43. package/dist/esm-node/dev-tools/watcher/dependencyTree.js +32 -21
  44. package/dist/esm-node/dev-tools/watcher/index.js +31 -18
  45. package/dist/esm-node/dev-tools/watcher/statsCache.js +18 -8
  46. package/dist/esm-node/index.js +2 -5
  47. package/dist/esm-node/server/devServer.js +87 -62
  48. package/dist/esm-node/server/index.js +1 -4
  49. package/dist/esm-node/types.js +1 -0
  50. package/package.json +13 -9
  51. package/dist/js/modern/constants.js +0 -19
  52. package/dist/js/modern/dev-tools/dev-middleware/hmr-client/createSocketUrl.js +0 -41
  53. package/dist/js/modern/dev-tools/dev-middleware/hmr-client/index.js +0 -143
  54. package/dist/js/modern/dev-tools/dev-middleware/index.js +0 -94
  55. package/dist/js/modern/dev-tools/dev-middleware/socket-server.js +0 -132
  56. package/dist/js/modern/dev-tools/https/index.js +0 -49
  57. package/dist/js/modern/dev-tools/mock/getMockData.js +0 -114
  58. package/dist/js/modern/dev-tools/mock/index.js +0 -54
  59. package/dist/js/modern/dev-tools/register/index.js +0 -111
  60. package/dist/js/modern/dev-tools/watcher/dependency-tree.js +0 -59
  61. package/dist/js/modern/dev-tools/watcher/index.js +0 -106
  62. package/dist/js/modern/dev-tools/watcher/stats-cache.js +0 -58
  63. package/dist/js/modern/index.js +0 -12
  64. package/dist/js/modern/server/dev-server.js +0 -293
  65. package/dist/js/modern/server/index.js +0 -16
  66. package/dist/js/modern/types.js +0 -0
  67. package/dist/js/node/constants.js +0 -42
  68. package/dist/js/node/dev-tools/dev-middleware/hmr-client/createSocketUrl.js +0 -65
  69. package/dist/js/node/dev-tools/dev-middleware/hmr-client/index.js +0 -152
  70. package/dist/js/node/dev-tools/dev-middleware/index.js +0 -119
  71. package/dist/js/node/dev-tools/dev-middleware/socket-server.js +0 -159
  72. package/dist/js/node/dev-tools/https/index.js +0 -72
  73. package/dist/js/node/dev-tools/mock/getMockData.js +0 -135
  74. package/dist/js/node/dev-tools/mock/index.js +0 -83
  75. package/dist/js/node/dev-tools/register/index.js +0 -138
  76. package/dist/js/node/dev-tools/watcher/dependency-tree.js +0 -89
  77. package/dist/js/node/dev-tools/watcher/index.js +0 -135
  78. package/dist/js/node/dev-tools/watcher/stats-cache.js +0 -87
  79. package/dist/js/node/index.js +0 -35
  80. package/dist/js/node/server/dev-server.js +0 -310
  81. package/dist/js/node/server/index.js +0 -39
  82. package/dist/js/node/types.js +0 -15
  83. package/dist/js/treeshaking/constants.js +0 -21
  84. package/dist/js/treeshaking/dev-tools/dev-middleware/hmr-client/createSocketUrl.js +0 -51
  85. package/dist/js/treeshaking/dev-tools/dev-middleware/hmr-client/index.js +0 -157
  86. package/dist/js/treeshaking/dev-tools/dev-middleware/index.js +0 -322
  87. package/dist/js/treeshaking/dev-tools/dev-middleware/socket-server.js +0 -209
  88. package/dist/js/treeshaking/dev-tools/https/index.js +0 -193
  89. package/dist/js/treeshaking/dev-tools/mock/getMockData.js +0 -327
  90. package/dist/js/treeshaking/dev-tools/mock/index.js +0 -191
  91. package/dist/js/treeshaking/dev-tools/register/index.js +0 -153
  92. package/dist/js/treeshaking/dev-tools/watcher/dependency-tree.js +0 -150
  93. package/dist/js/treeshaking/dev-tools/watcher/index.js +0 -200
  94. package/dist/js/treeshaking/dev-tools/watcher/stats-cache.js +0 -128
  95. package/dist/js/treeshaking/index.js +0 -9
  96. package/dist/js/treeshaking/server/dev-server.js +0 -799
  97. package/dist/js/treeshaking/server/index.js +0 -92
  98. package/dist/js/treeshaking/types.js +0 -1
@@ -1,29 +1,27 @@
1
1
  import { chalk, getPackageManager, logger } from "@modern-js/utils";
2
- const genHttpsOptions = async (userOptions, pwd) => {
2
+ export const genHttpsOptions = async (userOptions, pwd) => {
3
3
  const httpsOptions = typeof userOptions === "boolean" ? {} : userOptions;
4
4
  if (!httpsOptions.key || !httpsOptions.cert) {
5
5
  let devcertPath;
6
6
  try {
7
- devcertPath = require.resolve("devcert", { paths: [pwd, __dirname] });
7
+ devcertPath = require.resolve("devcert", {
8
+ paths: [
9
+ pwd,
10
+ __dirname
11
+ ]
12
+ });
8
13
  } catch (err) {
9
14
  const packageManager = await getPackageManager(pwd);
10
- const command = chalk.yellow.bold(
11
- `${packageManager} install devcert@1.2.2 -D`
12
- );
13
- logger.error(
14
- `You have enabled "dev.https" option, but the "devcert" package is not installed.`
15
- );
16
- logger.error(
17
- `Please run ${command} to install manually, otherwise the https can not work.`
18
- );
15
+ const command = chalk.yellow.bold(`${packageManager} install devcert@1.2.2 -D`);
16
+ logger.error(`You have enabled "dev.https" option, but the "devcert" package is not installed.`);
17
+ logger.error(`Please run ${command} to install manually, otherwise the https can not work.`);
19
18
  throw new Error('[https] "devcert" is not found.');
20
19
  }
21
20
  const devcert = require(devcertPath);
22
- const selfsign = await devcert.certificateFor(["localhost"]);
21
+ const selfsign = await devcert.certificateFor([
22
+ "localhost"
23
+ ]);
23
24
  return selfsign;
24
25
  }
25
26
  return httpsOptions;
26
27
  };
27
- export {
28
- genHttpsOptions
29
- };
@@ -1,6 +1,17 @@
1
1
  import { match } from "path-to-regexp";
2
- const VALID_METHODS = ["get", "post", "put", "delete", "patch"];
3
- const BODY_PARSED_METHODS = ["post", "put", "delete", "patch"];
2
+ const VALID_METHODS = [
3
+ "get",
4
+ "post",
5
+ "put",
6
+ "delete",
7
+ "patch"
8
+ ];
9
+ const BODY_PARSED_METHODS = [
10
+ "post",
11
+ "put",
12
+ "delete",
13
+ "patch"
14
+ ];
4
15
  const createFunctionDataHandler = (method, handler) => async (context, next) => {
5
16
  const { req, res } = context;
6
17
  return handler(req, res, next);
@@ -10,14 +21,15 @@ const createStaticDataHandler = (method, handler) => (context) => {
10
21
  res.setHeader("Content-Type", "application/json");
11
22
  res.end(JSON.stringify(handler));
12
23
  };
13
- const allowTypes = ["object", "function"];
14
- var getMockData_default = (mockConfig) => Object.keys(mockConfig).reduce((acc, key) => {
24
+ const allowTypes = [
25
+ "object",
26
+ "function"
27
+ ];
28
+ export default (mockConfig) => Object.keys(mockConfig).reduce((acc, key) => {
15
29
  const handler = mockConfig[key];
16
30
  const type = typeof handler;
17
31
  if (!allowTypes.includes(type)) {
18
- throw new Error(
19
- `mock value of ${key} should be object or function, but got ${type}`
20
- );
32
+ throw new Error(`mock value of ${key} should be object or function, but got ${type}`);
21
33
  }
22
34
  const meta = parseKey(key);
23
35
  if (type === "object") {
@@ -48,7 +60,7 @@ const parseKey = (key) => {
48
60
  path: key
49
61
  };
50
62
  };
51
- const getMatched = (context, mockApiList) => {
63
+ export const getMatched = (context, mockApiList) => {
52
64
  const { path: targetPathname, method: targetMethod } = context;
53
65
  const matched = mockApiList.find((mockApi) => {
54
66
  const { method, path: pathname } = mockApi;
@@ -62,7 +74,3 @@ const getMatched = (context, mockApiList) => {
62
74
  });
63
75
  return matched;
64
76
  };
65
- export {
66
- getMockData_default as default,
67
- getMatched
68
- };
@@ -2,8 +2,11 @@ import path from "path";
2
2
  import { compatRequire, fs } from "@modern-js/utils";
3
3
  import { AGGRED_DIR } from "@modern-js/prod-server";
4
4
  import getMockData, { getMatched } from "./getMockData";
5
- const createMockHandler = ({ pwd }) => {
6
- const exts = [".ts", ".js"];
5
+ export const createMockHandler = ({ pwd }) => {
6
+ const exts = [
7
+ ".ts",
8
+ ".js"
9
+ ];
7
10
  let filepath = "";
8
11
  for (const ext of exts) {
9
12
  const maybeMatch = path.join(pwd, `${AGGRED_DIR.mock}/index${ext}`);
@@ -17,7 +20,7 @@ const createMockHandler = ({ pwd }) => {
17
20
  }
18
21
  const mod = compatRequire(filepath, false);
19
22
  const { default: mockModule = mod, config } = mod;
20
- if ((config == null ? void 0 : config.enable) === false) {
23
+ if ((config === null || config === void 0 ? void 0 : config.enable) === false) {
21
24
  return null;
22
25
  }
23
26
  if (!mockModule) {
@@ -28,7 +31,7 @@ const createMockHandler = ({ pwd }) => {
28
31
  return null;
29
32
  }
30
33
  return async (context, next) => {
31
- if (typeof (config == null ? void 0 : config.enable) === "function") {
34
+ if (typeof (config === null || config === void 0 ? void 0 : config.enable) === "function") {
32
35
  const enableMock = config.enable(context.req, context.res);
33
36
  if (!enableMock) {
34
37
  return next();
@@ -43,6 +46,3 @@ const createMockHandler = ({ pwd }) => {
43
46
  return matched.handler(context, next);
44
47
  };
45
48
  };
46
- export {
47
- createMockHandler
48
- };
@@ -12,17 +12,26 @@ const checkDep = (depName, paths) => {
12
12
  }
13
13
  return Boolean(packagePath);
14
14
  };
15
- const enableRegister = (projectRoot, config) => {
16
- var _a, _b, _c;
17
- const registerDirs = ["./api", "./server", "./config/mock", "./shared"];
15
+ export const enableRegister = (projectRoot, config) => {
16
+ const registerDirs = [
17
+ "./api",
18
+ "./server",
19
+ "./config/mock",
20
+ "./shared"
21
+ ];
18
22
  const TS_CONFIG_FILENAME = `tsconfig.json`;
19
23
  const tsconfigPath = path.resolve(projectRoot, TS_CONFIG_FILENAME);
20
24
  const isTsProject = fs.existsSync(tsconfigPath);
21
- const existTsNode = checkDep("ts-node", [projectRoot]);
22
- const existTsConfigPaths = checkDep("tsconfig-paths", [projectRoot]);
25
+ const existTsNode = checkDep("ts-node", [
26
+ projectRoot
27
+ ]);
28
+ const existTsConfigPaths = checkDep("tsconfig-paths", [
29
+ projectRoot
30
+ ]);
23
31
  if (isTsProject && existTsNode && existTsConfigPaths) {
32
+ var _config_output_distPath;
24
33
  debug("use ts-node");
25
- const distPath = ((_a = config.output.distPath) == null ? void 0 : _a.root) || "dist";
34
+ const distPath = ((_config_output_distPath = config.output.distPath) === null || _config_output_distPath === void 0 ? void 0 : _config_output_distPath.root) || "dist";
26
35
  const tsNode = require("ts-node");
27
36
  const tsConfigPaths = require("tsconfig-paths");
28
37
  const { alias } = config.source;
@@ -37,7 +46,9 @@ const enableRegister = (projectRoot, config) => {
37
46
  tsPath = path.relative(absoluteBaseUrl, tsPath);
38
47
  }
39
48
  if (typeof tsPath === "string") {
40
- tsPath = [tsPath];
49
+ tsPath = [
50
+ tsPath
51
+ ];
41
52
  }
42
53
  return {
43
54
  ...o,
@@ -54,25 +65,25 @@ const enableRegister = (projectRoot, config) => {
54
65
  // for env.d.ts, https://www.npmjs.com/package/ts-node#missing-types
55
66
  files: true,
56
67
  transpileOnly: true,
57
- ignore: ["(?:^|/)node_modules/", `(?:^|/)${distPath}/`]
68
+ ignore: [
69
+ "(?:^|/)node_modules/",
70
+ `(?:^|/)${distPath}/`
71
+ ]
58
72
  });
59
73
  } else {
74
+ var _config_tools, _config_server;
60
75
  debug("use @babel/register");
61
- const babelConfig = resolveBabelConfig(
62
- projectRoot,
63
- {
64
- ...config.source,
65
- babelConfig: (_b = config.tools) == null ? void 0 : _b.babel,
66
- server: {
67
- compiler: (_c = config.server) == null ? void 0 : _c.compiler
68
- }
69
- },
70
- {
71
- tsconfigPath,
72
- syntax: "es6+",
73
- type: "commonjs"
76
+ const babelConfig = resolveBabelConfig(projectRoot, {
77
+ ...config.source,
78
+ babelConfig: (_config_tools = config.tools) === null || _config_tools === void 0 ? void 0 : _config_tools.babel,
79
+ server: {
80
+ compiler: (_config_server = config.server) === null || _config_server === void 0 ? void 0 : _config_server.compiler
74
81
  }
75
- );
82
+ }, {
83
+ tsconfigPath,
84
+ syntax: "es6+",
85
+ type: "commonjs"
86
+ });
76
87
  return require("@babel/register")({
77
88
  ...babelConfig,
78
89
  only: [
@@ -80,18 +91,16 @@ const enableRegister = (projectRoot, config) => {
80
91
  if (filePath.includes(`node_modules${path.sep}.modern-js`)) {
81
92
  return true;
82
93
  }
83
- return registerDirs.some(
84
- (registerDir) => filePath.startsWith(path.join(projectRoot, registerDir))
85
- );
94
+ return registerDirs.some((registerDir) => filePath.startsWith(path.join(projectRoot, registerDir)));
86
95
  }
87
96
  ],
88
- extensions: [".js", ".ts"],
97
+ extensions: [
98
+ ".js",
99
+ ".ts"
100
+ ],
89
101
  babelrc: false,
90
102
  configFile: false,
91
103
  root: projectRoot
92
104
  });
93
105
  }
94
106
  };
95
- export {
96
- enableRegister
97
- };
@@ -1,5 +1,18 @@
1
+ function _define_property(obj, key, value) {
2
+ if (key in obj) {
3
+ Object.defineProperty(obj, key, {
4
+ value,
5
+ enumerable: true,
6
+ configurable: true,
7
+ writable: true
8
+ });
9
+ } else {
10
+ obj[key] = value;
11
+ }
12
+ return obj;
13
+ }
1
14
  import minimatch from "minimatch";
2
- const defaultIgnores = [
15
+ export const defaultIgnores = [
3
16
  "**/bower_components/**",
4
17
  "**/coverage/**",
5
18
  "**/node_modules/**",
@@ -7,19 +20,15 @@ const defaultIgnores = [
7
20
  "**/*.d.ts",
8
21
  "**/*.log"
9
22
  ];
10
- class DependencyTree {
11
- constructor() {
12
- this.tree = /* @__PURE__ */ new Map();
13
- this.ignore = [...defaultIgnores];
14
- }
23
+ export class DependencyTree {
15
24
  getNode(path) {
16
25
  return this.tree.get(path);
17
26
  }
18
27
  /**
19
- * update dependency tree
20
- *
21
- * @param cache
22
- */
28
+ * update dependency tree
29
+ *
30
+ * @param cache
31
+ */
23
32
  update(cache) {
24
33
  this.tree.clear();
25
34
  Object.keys(cache).forEach((path) => {
@@ -53,16 +62,18 @@ class DependencyTree {
53
62
  }
54
63
  }
55
64
  shouldIgnore(path) {
56
- return !path || Boolean(
57
- this.ignore.find(
58
- (rule) => minimatch.match([path], rule, {
59
- dot: true
60
- }).length > 0
61
- )
62
- );
65
+ return !path || Boolean(this.ignore.find((rule) => minimatch.match([
66
+ path
67
+ ], rule, {
68
+ dot: true
69
+ }).length > 0));
70
+ }
71
+ constructor() {
72
+ _define_property(this, "tree", void 0);
73
+ _define_property(this, "ignore", void 0);
74
+ this.tree = /* @__PURE__ */ new Map();
75
+ this.ignore = [
76
+ ...defaultIgnores
77
+ ];
63
78
  }
64
79
  }
65
- export {
66
- DependencyTree,
67
- defaultIgnores
68
- };
@@ -1,13 +1,26 @@
1
+ function _define_property(obj, key, value) {
2
+ if (key in obj) {
3
+ Object.defineProperty(obj, key, {
4
+ value,
5
+ enumerable: true,
6
+ configurable: true,
7
+ writable: true
8
+ });
9
+ } else {
10
+ obj[key] = value;
11
+ }
12
+ return obj;
13
+ }
1
14
  import path from "path";
2
15
  import { fs, chokidar } from "@modern-js/utils";
3
16
  import { DependencyTree } from "./dependencyTree";
4
17
  import { StatsCache } from "./statsCache";
5
- const defaultWatchOptions = {
18
+ export const defaultWatchOptions = {
6
19
  // 初始化的时候不触发 add、addDir 事件
7
20
  ignoreInitial: true,
8
21
  ignored: /api\/typings\/.*/
9
22
  };
10
- const getWatchedFiles = (watcher) => {
23
+ export const getWatchedFiles = (watcher) => {
11
24
  const watched = watcher.getWatched();
12
25
  const files = [];
13
26
  Object.keys(watched).forEach((dir) => {
@@ -17,7 +30,7 @@ const getWatchedFiles = (watcher) => {
17
30
  });
18
31
  return files;
19
32
  };
20
- const mergeWatchOptions = (options) => {
33
+ export const mergeWatchOptions = (options) => {
21
34
  const watchOptions = {
22
35
  ...options
23
36
  };
@@ -25,7 +38,9 @@ const mergeWatchOptions = (options) => {
25
38
  const { ignored } = watchOptions;
26
39
  const finalIgnored = ignored ? [
27
40
  defaultWatchOptions.ignored,
28
- ...Array.isArray(ignored) ? ignored : [ignored]
41
+ ...Array.isArray(ignored) ? ignored : [
42
+ ignored
43
+ ]
29
44
  ] : ignored;
30
45
  if (finalIgnored) {
31
46
  watchOptions.ignored = finalIgnored;
@@ -38,9 +53,6 @@ const mergeWatchOptions = (options) => {
38
53
  return finalWatchOptions;
39
54
  };
40
55
  class Watcher {
41
- constructor() {
42
- this.dependencyTree = null;
43
- }
44
56
  listen(files, options, callback) {
45
57
  const watched = files.filter(Boolean);
46
58
  const filenames = watched.map((filename) => filename.replace(/\\/g, "/"));
@@ -57,7 +69,9 @@ class Watcher {
57
69
  });
58
70
  watcher.on("add", (changed) => {
59
71
  if (!cache.has(changed)) {
60
- cache.add([changed]);
72
+ cache.add([
73
+ changed
74
+ ]);
61
75
  callback(changed, "add");
62
76
  }
63
77
  });
@@ -71,12 +85,12 @@ class Watcher {
71
85
  this.dependencyTree = new DependencyTree();
72
86
  }
73
87
  updateDepTree() {
74
- var _a;
75
- (_a = this.dependencyTree) == null ? void 0 : _a.update(require.cache);
88
+ var _this_dependencyTree;
89
+ (_this_dependencyTree = this.dependencyTree) === null || _this_dependencyTree === void 0 ? void 0 : _this_dependencyTree.update(require.cache);
76
90
  }
77
91
  cleanDepCache(filepath) {
78
- var _a;
79
- const node = (_a = this.dependencyTree) == null ? void 0 : _a.getNode(filepath);
92
+ var _this_dependencyTree;
93
+ const node = (_this_dependencyTree = this.dependencyTree) === null || _this_dependencyTree === void 0 ? void 0 : _this_dependencyTree.getNode(filepath);
80
94
  if (node && require.cache[filepath]) {
81
95
  delete require.cache[filepath];
82
96
  for (const parentNode of node.parent.values()) {
@@ -87,10 +101,9 @@ class Watcher {
87
101
  close() {
88
102
  return this.watcher.close();
89
103
  }
104
+ constructor() {
105
+ _define_property(this, "dependencyTree", null);
106
+ _define_property(this, "watcher", void 0);
107
+ }
90
108
  }
91
- export {
92
- Watcher as default,
93
- defaultWatchOptions,
94
- getWatchedFiles,
95
- mergeWatchOptions
96
- };
109
+ export { Watcher as default };
@@ -1,10 +1,19 @@
1
+ function _define_property(obj, key, value) {
2
+ if (key in obj) {
3
+ Object.defineProperty(obj, key, {
4
+ value,
5
+ enumerable: true,
6
+ configurable: true,
7
+ writable: true
8
+ });
9
+ } else {
10
+ obj[key] = value;
11
+ }
12
+ return obj;
13
+ }
1
14
  import fs from "fs";
2
15
  import crypto from "crypto";
3
- class StatsCache {
4
- constructor() {
5
- this.cachedHash = {};
6
- this.cachedSize = {};
7
- }
16
+ export class StatsCache {
8
17
  add(files) {
9
18
  const { cachedHash, cachedSize } = this;
10
19
  for (const filename of files) {
@@ -52,7 +61,8 @@ class StatsCache {
52
61
  hash(stats, filename) {
53
62
  return crypto.createHash("md5").update(fs.readFileSync(filename)).digest("hex");
54
63
  }
64
+ constructor() {
65
+ _define_property(this, "cachedHash", {});
66
+ _define_property(this, "cachedSize", {});
67
+ }
55
68
  }
56
- export {
57
- StatsCache
58
- };
@@ -1,12 +1,9 @@
1
1
  import { DevServer as Server } from "./server";
2
- var src_default = (options) => {
2
+ export { Server };
3
+ export default (options) => {
3
4
  if (options == null) {
4
5
  throw new Error("can not start server without options");
5
6
  }
6
7
  const server = new Server(options);
7
8
  return server.init();
8
9
  };
9
- export {
10
- Server,
11
- src_default as default
12
- };