@modern-js/app-tools 2.0.3-alpha.0 → 2.2.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 (64) hide show
  1. package/CHANGELOG.md +107 -0
  2. package/dist/js/modern/analyze/constants.js +1 -1
  3. package/dist/js/modern/analyze/generateCode.js +4 -12
  4. package/dist/js/modern/analyze/index.js +28 -7
  5. package/dist/js/modern/analyze/nestedRoutes.js +5 -1
  6. package/dist/js/modern/analyze/templates.js +15 -17
  7. package/dist/js/modern/analyze/utils.js +2 -19
  8. package/dist/js/modern/builder/index.js +5 -6
  9. package/dist/js/modern/commands/dev.js +1 -23
  10. package/dist/js/modern/config/default.js +3 -1
  11. package/dist/js/modern/hooks.js +0 -2
  12. package/dist/js/modern/index.js +8 -0
  13. package/dist/js/modern/initialize/index.js +7 -7
  14. package/dist/js/modern/locale/en.js +3 -1
  15. package/dist/js/modern/locale/zh.js +3 -1
  16. package/dist/js/modern/utils/generateWatchFiles.js +55 -0
  17. package/dist/js/modern/utils/{getSpecifiedEntries.js → getSelectedEntries.js} +9 -8
  18. package/dist/js/node/analyze/constants.js +1 -1
  19. package/dist/js/node/analyze/generateCode.js +3 -7
  20. package/dist/js/node/analyze/index.js +19 -5
  21. package/dist/js/node/analyze/nestedRoutes.js +5 -1
  22. package/dist/js/node/analyze/templates.js +15 -17
  23. package/dist/js/node/analyze/utils.js +1 -18
  24. package/dist/js/node/builder/index.js +5 -6
  25. package/dist/js/node/commands/dev.js +1 -23
  26. package/dist/js/node/config/default.js +3 -1
  27. package/dist/js/node/hooks.js +0 -2
  28. package/dist/js/node/index.js +8 -0
  29. package/dist/js/node/initialize/index.js +7 -7
  30. package/dist/js/node/locale/en.js +3 -1
  31. package/dist/js/node/locale/zh.js +3 -1
  32. package/dist/js/node/utils/{createFileWatcher.js → generateWatchFiles.js} +12 -66
  33. package/dist/js/node/utils/{getSpecifiedEntries.js → getSelectedEntries.js} +12 -11
  34. package/dist/js/treeshaking/analyze/constants.js +1 -1
  35. package/dist/js/treeshaking/analyze/generateCode.js +5 -8
  36. package/dist/js/treeshaking/analyze/index.js +29 -14
  37. package/dist/js/treeshaking/analyze/nestedRoutes.js +12 -3
  38. package/dist/js/treeshaking/analyze/templates.js +10 -9
  39. package/dist/js/treeshaking/analyze/utils.js +2 -11
  40. package/dist/js/treeshaking/builder/index.js +6 -7
  41. package/dist/js/treeshaking/commands/dev.js +13 -31
  42. package/dist/js/treeshaking/config/default.js +3 -1
  43. package/dist/js/treeshaking/hooks.js +0 -2
  44. package/dist/js/treeshaking/index.js +14 -0
  45. package/dist/js/treeshaking/initialize/index.js +19 -42
  46. package/dist/js/treeshaking/locale/en.js +3 -1
  47. package/dist/js/treeshaking/locale/zh.js +3 -1
  48. package/dist/js/treeshaking/utils/{createFileWatcher.js → generateWatchFiles.js} +16 -85
  49. package/dist/js/treeshaking/utils/{getSpecifiedEntries.js → getSelectedEntries.js} +8 -7
  50. package/dist/types/analyze/constants.d.ts +1 -1
  51. package/dist/types/analyze/templates.d.ts +2 -8
  52. package/dist/types/analyze/utils.d.ts +0 -1
  53. package/dist/types/locale/en.d.ts +2 -0
  54. package/dist/types/locale/index.d.ts +4 -0
  55. package/dist/types/locale/zh.d.ts +2 -0
  56. package/dist/types/types/config/dev.d.ts +1 -1
  57. package/dist/types/types/hooks.d.ts +0 -5
  58. package/dist/types/utils/generateWatchFiles.d.ts +3 -0
  59. package/dist/types/utils/getSelectedEntries.d.ts +6 -0
  60. package/lib/types.d.ts +6 -2
  61. package/package.json +24 -24
  62. package/dist/js/modern/utils/createFileWatcher.js +0 -115
  63. package/dist/types/utils/createFileWatcher.d.ts +0 -4
  64. package/dist/types/utils/getSpecifiedEntries.d.ts +0 -2
@@ -147,10 +147,8 @@ var __generator = this && this.__generator || function(thisArg, body) {
147
147
  };
148
148
  }
149
149
  };
150
- import crypto from "crypto";
151
- import fs from "fs";
152
150
  import path from "path";
153
- import { isDev, chokidar, createDebugger, isTest, getServerConfig } from "@modern-js/utils";
151
+ import { fs, getServerConfig } from "@modern-js/utils";
154
152
  var getPackageConfig = function(appDirectory, packageJsonConfig) {
155
153
  var PACKAGE_JSON_CONFIG_NAME = "modernConfig";
156
154
  var json = JSON.parse(fs.readFileSync(path.resolve(appDirectory, "./package.json"), "utf8"));
@@ -181,29 +179,17 @@ var addServerConfigToDeps = function() {
181
179
  return _ref.apply(this, arguments);
182
180
  };
183
181
  }();
184
- var debug = createDebugger("watch-files");
185
- var md5 = function(data) {
186
- return crypto.createHash("md5").update(data).digest("hex");
187
- };
188
- var hashMap = /* @__PURE__ */ new Map();
189
- var createFileWatcher = function() {
190
- var _ref = _asyncToGenerator(function(appContext, configDir, hooksRunner) {
191
- var appDirectory, configFile, extraFiles, configPath, dependencies, watched, watcher;
182
+ function generateWatchFiles(appContext, configDir) {
183
+ return _generateWatchFiles.apply(this, arguments);
184
+ }
185
+ function _generateWatchFiles() {
186
+ _generateWatchFiles = _asyncToGenerator(function(appContext, configDir) {
187
+ var appDirectory, configFile, configPath, dependencies;
192
188
  return __generator(this, function(_state) {
193
189
  switch(_state.label){
194
190
  case 0:
195
- if (!(isDev() || isTest())) return [
196
- 3,
197
- 3
198
- ];
199
191
  appDirectory = appContext.appDirectory, configFile = appContext.configFile;
200
- return [
201
- 4,
202
- hooksRunner.watchFiles()
203
- ];
204
- case 1:
205
- extraFiles = _state.sent();
206
- configPath = path.join(appDirectory, configDir);
192
+ configPath = path.join(appDirectory, configDir || "");
207
193
  dependencies = getPackageConfig(appContext.appDirectory, appContext.packageName) ? [
208
194
  path.resolve(appDirectory, "./package.json")
209
195
  ] : [];
@@ -211,73 +197,18 @@ var createFileWatcher = function() {
211
197
  4,
212
198
  addServerConfigToDeps(dependencies, appContext.appDirectory, appContext.serverConfigFile)
213
199
  ];
214
- case 2:
200
+ case 1:
215
201
  _state.sent();
216
- watched = [
217
- "".concat(configPath, "/html")
218
- ].concat(_toConsumableArray(extraFiles), _toConsumableArray(dependencies), [
219
- configFile
220
- ]).filter(Boolean);
221
- debug("watched: %o", watched);
222
- watcher = chokidar.watch(watched, {
223
- cwd: appDirectory,
224
- ignoreInitial: true,
225
- ignorePermissionErrors: true,
226
- ignored: [
227
- /node_modules/,
228
- "**/__test__/**",
229
- "**/*.test.(js|jsx|ts|tsx)",
230
- "**/*.spec.(js|jsx|ts|tsx)",
231
- "**/*.stories.(js|jsx|ts|tsx)"
232
- ]
233
- });
234
- watcher.on("change", function(changed) {
235
- var lastHash = hashMap.get(changed);
236
- var currentHash = md5(fs.readFileSync(path.join(appDirectory, changed), "utf8"));
237
- if (currentHash !== lastHash) {
238
- debug("file change: %s", changed);
239
- hashMap.set(changed, currentHash);
240
- hooksRunner.fileChange({
241
- filename: changed,
242
- eventType: "change"
243
- });
244
- }
245
- });
246
- watcher.on("add", function(name) {
247
- debug("add file: %s", name);
248
- var currentHash = md5(fs.readFileSync(path.join(appDirectory, name), "utf8"));
249
- hashMap.set(name, currentHash);
250
- hooksRunner.fileChange({
251
- filename: name,
252
- eventType: "add"
253
- });
254
- });
255
- watcher.on("unlink", function(name) {
256
- debug("remove file: %s", name);
257
- if (hashMap.has(name)) {
258
- hashMap.delete(name);
259
- }
260
- hooksRunner.fileChange({
261
- filename: name,
262
- eventType: "unlink"
263
- });
264
- });
265
- watcher.on("error", function(err) {
266
- throw err;
267
- });
268
202
  return [
269
203
  2,
270
- watcher
271
- ];
272
- case 3:
273
- return [
274
- 2
204
+ [
205
+ "".concat(configPath, "/html"),
206
+ configFile || "./config"
207
+ ].concat(_toConsumableArray(dependencies))
275
208
  ];
276
209
  }
277
210
  });
278
211
  });
279
- return function createFileWatcher(appContext, configDir, hooksRunner) {
280
- return _ref.apply(this, arguments);
281
- };
282
- }();
283
- export { addServerConfigToDeps, createFileWatcher };
212
+ return _generateWatchFiles.apply(this, arguments);
213
+ }
214
+ export { addServerConfigToDeps, generateWatchFiles };
@@ -122,8 +122,9 @@ var __generator = this && this.__generator || function(thisArg, body) {
122
122
  };
123
123
  }
124
124
  };
125
- import { inquirer } from "@modern-js/utils";
126
- var getSpecifiedEntries = function() {
125
+ import { chalk, inquirer } from "@modern-js/utils";
126
+ import { i18n, localeKeys } from "../locale";
127
+ var getSelectedEntries = function() {
127
128
  var _ref = _asyncToGenerator(function(entry, entrypoints) {
128
129
  var entryNames, selected;
129
130
  return __generator(this, function(_state) {
@@ -149,10 +150,10 @@ var getSpecifiedEntries = function() {
149
150
  type: "checkbox",
150
151
  name: "selected",
151
152
  choices: entryNames,
152
- message: "请选择需要构建的入口",
153
+ message: i18n.t(localeKeys.command.dev.selectEntry),
153
154
  validate: function validate(answer) {
154
155
  if (answer.length < 1) {
155
- return "You must choose at least one topping.";
156
+ return i18n.t(localeKeys.command.dev.requireEntry);
156
157
  }
157
158
  return true;
158
159
  }
@@ -168,7 +169,7 @@ var getSpecifiedEntries = function() {
168
169
  case 2:
169
170
  entry.forEach(function(name) {
170
171
  if (!entryNames.includes(name)) {
171
- throw new Error("can not found entry ".concat(name, ", compiler entry should in ").concat(entryNames.join(", ")));
172
+ throw new Error("Can not found entry ".concat(chalk.yellow(name), ", the entry should be one of ").concat(chalk.yellow(entryNames.join(", "))));
172
173
  }
173
174
  });
174
175
  return [
@@ -178,8 +179,8 @@ var getSpecifiedEntries = function() {
178
179
  }
179
180
  });
180
181
  });
181
- return function getSpecifiedEntries(entry, entrypoints) {
182
+ return function getSelectedEntries(entry, entrypoints) {
182
183
  return _ref.apply(this, arguments);
183
184
  };
184
185
  }();
185
- export { getSpecifiedEntries };
186
+ export { getSelectedEntries };
@@ -25,6 +25,6 @@ export declare const NESTED_ROUTE: {
25
25
  ERROR_FILE: string;
26
26
  LOADER_FILE: string;
27
27
  };
28
- export declare const APP_CONFIG_NAME = "appConfig";
28
+ export declare const APP_CONFIG_NAME = "config";
29
29
  export declare const APP_INIT_EXPORTED = "init";
30
30
  export declare const APP_INIT_IMPORTED = "appInit";
@@ -26,26 +26,20 @@ export declare const html: (partials: {
26
26
  body: string[];
27
27
  }) => string;
28
28
  export declare const routesForServer: ({
29
- routes,
30
- internalDirectory,
31
- entryName
29
+ routes
32
30
  }: {
33
31
  routes: (NestedRoute | PageRoute)[];
34
- internalDirectory: string;
35
- entryName: string;
36
32
  }) => string;
37
33
  export declare const fileSystemRoutes: ({
38
34
  routes,
39
35
  ssrMode,
40
36
  nestedRoutesEntry,
41
37
  entryName,
42
- internalDirectory,
43
- internalDirAlias
38
+ internalDirectory
44
39
  }: {
45
40
  routes: RouteLegacy[] | (NestedRoute | PageRoute)[];
46
41
  ssrMode: 'string' | 'stream' | false;
47
42
  nestedRoutesEntry?: string | undefined;
48
43
  entryName: string;
49
44
  internalDirectory: string;
50
- internalDirAlias: string;
51
45
  }) => Promise<string>;
@@ -15,7 +15,6 @@ export declare const getDefaultImports: ({
15
15
  internalDirectory: string;
16
16
  }) => ImportStatement[];
17
17
  export declare const isPageComponentFile: (filePath: string) => boolean;
18
- export declare const isNestedRouteComponent: (nestedRouteEntries: string[], absoluteFilePath: string) => boolean;
19
18
  export declare const replaceWithAlias: (base: string, filePath: string, alias: string) => string;
20
19
  export declare const parseModule: ({
21
20
  source,
@@ -8,6 +8,8 @@ export declare const EN_LOCALE: {
8
8
  describe: string;
9
9
  entry: string;
10
10
  apiOnly: string;
11
+ selectEntry: string;
12
+ requireEntry: string;
11
13
  };
12
14
  build: {
13
15
  describe: string;
@@ -10,6 +10,8 @@ declare const localeKeys: {
10
10
  describe: string;
11
11
  entry: string;
12
12
  apiOnly: string;
13
+ selectEntry: string;
14
+ requireEntry: string;
13
15
  };
14
16
  build: {
15
17
  describe: string;
@@ -44,6 +46,8 @@ declare const localeKeys: {
44
46
  describe: string;
45
47
  entry: string;
46
48
  apiOnly: string;
49
+ selectEntry: string;
50
+ requireEntry: string;
47
51
  };
48
52
  build: {
49
53
  describe: string;
@@ -8,6 +8,8 @@ export declare const ZH_LOCALE: {
8
8
  describe: string;
9
9
  entry: string;
10
10
  apiOnly: string;
11
+ selectEntry: string;
12
+ requireEntry: string;
11
13
  };
12
14
  build: {
13
15
  describe: string;
@@ -1,7 +1,7 @@
1
1
  import type { BuilderConfig } from '@modern-js/builder-webpack-provider';
2
2
  type BuilderDevConfig = Required<BuilderConfig>['dev'];
3
3
  export type DevProxyOptions = string | Record<string, string>;
4
- export interface DevUserConfig extends Omit<BuilderDevConfig, 'port'> {
4
+ export interface DevUserConfig extends BuilderDevConfig {
5
5
  /**
6
6
  * The configuration of `dev.proxy` is provided by `proxy` plugin.
7
7
  * Please use `yarn new` or `pnpm new` to enable the corresponding capability.
@@ -76,11 +76,6 @@ export type AppToolsHooks = {
76
76
  }, unknown>;
77
77
  beforeDeploy: AsyncWorkflow<Record<string, any>, unknown>;
78
78
  afterDeploy: AsyncWorkflow<Record<string, any>, unknown>;
79
- watchFiles: ParallelWorkflow<void>;
80
- fileChange: AsyncWorkflow<{
81
- filename: string;
82
- eventType: 'add' | 'change' | 'unlink';
83
- }, void>;
84
79
  beforeRestart: AsyncWorkflow<void, void>;
85
80
  registerDev: ParallelWorkflow<void, DevToolData>;
86
81
  beforeDevTask: ParallelWorkflow<DevToolData, void>;
@@ -0,0 +1,3 @@
1
+ import { IAppContext } from '../types';
2
+ export declare const addServerConfigToDeps: (dependencies: string[], appDirectory: string, serverConfigFile: string) => Promise<void>;
3
+ export declare function generateWatchFiles(appContext: IAppContext, configDir?: string): Promise<string[]>;
@@ -0,0 +1,6 @@
1
+ import { Entrypoint } from '@modern-js/types';
2
+ /**
3
+ * Allow user to select entrypoints to build.
4
+ */
5
+
6
+ export declare const getSelectedEntries: (entry: string[] | boolean, entrypoints: Entrypoint[]) => Promise<string[]>;
package/lib/types.d.ts CHANGED
@@ -98,8 +98,12 @@ declare module '*.svg?inline' {
98
98
  React.SVGProps<SVGSVGElement>
99
99
  >;
100
100
 
101
- const src: string;
102
- export default src;
101
+ /**
102
+ * The default export type depends on the svgDefaultExport config,
103
+ * it can be a string or a ReactComponent
104
+ * */
105
+ const content: any;
106
+ export default content;
103
107
  }
104
108
 
105
109
  declare module '*.bmp?url' {
package/package.json CHANGED
@@ -11,7 +11,7 @@
11
11
  "modern",
12
12
  "modern.js"
13
13
  ],
14
- "version": "2.0.3-alpha.0",
14
+ "version": "2.2.0",
15
15
  "jsnext:source": "./src/index.ts",
16
16
  "types": "./dist/types/index.d.ts",
17
17
  "main": "./dist/js/node/index.js",
@@ -63,37 +63,37 @@
63
63
  "@babel/runtime": "^7.18.0",
64
64
  "@babel/traverse": "^7.18.0",
65
65
  "@babel/types": "^7.18.0",
66
- "@modern-js/builder": "2.0.2",
67
- "@modern-js/builder-plugin-esbuild": "2.0.2",
68
- "@modern-js/builder-plugin-node-polyfill": "2.0.2",
69
- "@modern-js/builder-shared": "2.0.2",
70
- "@modern-js/builder-webpack-provider": "2.0.2",
71
- "@modern-js/core": "2.0.2",
72
- "@modern-js/new-action": "2.0.2",
73
- "@modern-js/node-bundle-require": "2.0.2",
74
- "@modern-js/plugin": "2.0.2",
75
- "@modern-js/plugin-data-loader": "2.0.3-alpha.0",
76
- "@modern-js/plugin-i18n": "2.0.2",
77
- "@modern-js/plugin-lint": "2.0.2",
78
- "@modern-js/prod-server": "2.0.2",
79
- "@modern-js/server": "2.0.2",
80
- "@modern-js/types": "2.0.2",
81
- "@modern-js/upgrade": "2.0.2",
82
- "@modern-js/utils": "2.0.2",
83
66
  "es-module-lexer": "^1.1.0",
84
- "esbuild": "0.15.7"
67
+ "esbuild": "0.15.7",
68
+ "@modern-js/builder": "2.2.0",
69
+ "@modern-js/builder-plugin-esbuild": "2.2.0",
70
+ "@modern-js/builder-plugin-node-polyfill": "2.2.0",
71
+ "@modern-js/builder-shared": "2.2.0",
72
+ "@modern-js/builder-webpack-provider": "2.2.0",
73
+ "@modern-js/core": "2.2.0",
74
+ "@modern-js/new-action": "2.2.0",
75
+ "@modern-js/node-bundle-require": "2.2.0",
76
+ "@modern-js/plugin": "2.2.0",
77
+ "@modern-js/plugin-data-loader": "2.2.0",
78
+ "@modern-js/plugin-i18n": "2.2.0",
79
+ "@modern-js/plugin-lint": "2.2.0",
80
+ "@modern-js/prod-server": "2.2.0",
81
+ "@modern-js/server": "2.2.0",
82
+ "@modern-js/types": "2.2.0",
83
+ "@modern-js/upgrade": "2.2.0",
84
+ "@modern-js/utils": "2.2.0"
85
85
  },
86
86
  "devDependencies": {
87
- "@modern-js/builder-plugin-swc": "2.0.2",
88
- "@modern-js/server-core": "2.0.2",
89
- "@scripts/build": "2.0.2",
90
- "@scripts/jest-config": "2.0.2",
91
87
  "@types/babel__traverse": "^7.14.2",
92
88
  "@types/jest": "^27",
93
89
  "@types/node": "^14",
94
90
  "jest": "^27",
95
91
  "typescript": "^4",
96
- "webpack": "^5.75.0"
92
+ "webpack": "^5.75.0",
93
+ "@modern-js/builder-plugin-swc": "2.2.0",
94
+ "@modern-js/server-core": "2.2.0",
95
+ "@scripts/jest-config": "2.2.0",
96
+ "@scripts/build": "2.2.0"
97
97
  },
98
98
  "sideEffects": false,
99
99
  "publishConfig": {
@@ -1,115 +0,0 @@
1
- var __async = (__this, __arguments, generator) => {
2
- return new Promise((resolve, reject) => {
3
- var fulfilled = (value) => {
4
- try {
5
- step(generator.next(value));
6
- } catch (e) {
7
- reject(e);
8
- }
9
- };
10
- var rejected = (value) => {
11
- try {
12
- step(generator.throw(value));
13
- } catch (e) {
14
- reject(e);
15
- }
16
- };
17
- var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
18
- step((generator = generator.apply(__this, __arguments)).next());
19
- });
20
- };
21
- import crypto from "crypto";
22
- import fs from "fs";
23
- import path from "path";
24
- import {
25
- isDev,
26
- chokidar,
27
- createDebugger,
28
- isTest,
29
- getServerConfig
30
- } from "@modern-js/utils";
31
- const getPackageConfig = (appDirectory, packageJsonConfig) => {
32
- const PACKAGE_JSON_CONFIG_NAME = "modernConfig";
33
- const json = JSON.parse(
34
- fs.readFileSync(path.resolve(appDirectory, "./package.json"), "utf8")
35
- );
36
- return json[packageJsonConfig != null ? packageJsonConfig : PACKAGE_JSON_CONFIG_NAME];
37
- };
38
- const addServerConfigToDeps = (dependencies, appDirectory, serverConfigFile) => __async(void 0, null, function* () {
39
- const serverConfig = yield getServerConfig(appDirectory, serverConfigFile);
40
- if (serverConfig) {
41
- dependencies.push(serverConfig);
42
- }
43
- });
44
- const debug = createDebugger("watch-files");
45
- const md5 = (data) => crypto.createHash("md5").update(data).digest("hex");
46
- const hashMap = /* @__PURE__ */ new Map();
47
- const createFileWatcher = (appContext, configDir, hooksRunner) => __async(void 0, null, function* () {
48
- if (isDev() || isTest()) {
49
- const { appDirectory, configFile } = appContext;
50
- const extraFiles = yield hooksRunner.watchFiles();
51
- const configPath = path.join(appDirectory, configDir);
52
- const dependencies = getPackageConfig(
53
- appContext.appDirectory,
54
- appContext.packageName
55
- ) ? [path.resolve(appDirectory, "./package.json")] : [];
56
- yield addServerConfigToDeps(
57
- dependencies,
58
- appContext.appDirectory,
59
- appContext.serverConfigFile
60
- );
61
- const watched = [
62
- `${configPath}/html`,
63
- ...extraFiles,
64
- ...dependencies,
65
- configFile
66
- ].filter(Boolean);
67
- debug(`watched: %o`, watched);
68
- const watcher = chokidar.watch(watched, {
69
- cwd: appDirectory,
70
- ignoreInitial: true,
71
- ignorePermissionErrors: true,
72
- ignored: [
73
- /node_modules/,
74
- "**/__test__/**",
75
- "**/*.test.(js|jsx|ts|tsx)",
76
- "**/*.spec.(js|jsx|ts|tsx)",
77
- "**/*.stories.(js|jsx|ts|tsx)"
78
- ]
79
- });
80
- watcher.on("change", (changed) => {
81
- const lastHash = hashMap.get(changed);
82
- const currentHash = md5(
83
- fs.readFileSync(path.join(appDirectory, changed), "utf8")
84
- );
85
- if (currentHash !== lastHash) {
86
- debug(`file change: %s`, changed);
87
- hashMap.set(changed, currentHash);
88
- hooksRunner.fileChange({ filename: changed, eventType: "change" });
89
- }
90
- });
91
- watcher.on("add", (name) => {
92
- debug(`add file: %s`, name);
93
- const currentHash = md5(
94
- fs.readFileSync(path.join(appDirectory, name), "utf8")
95
- );
96
- hashMap.set(name, currentHash);
97
- hooksRunner.fileChange({ filename: name, eventType: "add" });
98
- });
99
- watcher.on("unlink", (name) => {
100
- debug(`remove file: %s`, name);
101
- if (hashMap.has(name)) {
102
- hashMap.delete(name);
103
- }
104
- hooksRunner.fileChange({ filename: name, eventType: "unlink" });
105
- });
106
- watcher.on("error", (err) => {
107
- throw err;
108
- });
109
- return watcher;
110
- }
111
- });
112
- export {
113
- addServerConfigToDeps,
114
- createFileWatcher
115
- };
@@ -1,4 +0,0 @@
1
- import type { IAppContext, ToRunners } from '@modern-js/core';
2
- import { AppToolsHooks } from '../types/hooks';
3
- export declare const addServerConfigToDeps: (dependencies: string[], appDirectory: string, serverConfigFile: string) => Promise<void>;
4
- export declare const createFileWatcher: (appContext: IAppContext, configDir: string | undefined, hooksRunner: ToRunners<AppToolsHooks>) => Promise<import("@modern-js/utils").FSWatcher | undefined>;
@@ -1,2 +0,0 @@
1
- import { Entrypoint } from '@modern-js/types';
2
- export declare const getSpecifiedEntries: (entry: string[] | boolean, entrypoints: Entrypoint[]) => Promise<string[]>;