@modern-js/app-tools 2.22.1 → 2.23.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/CHANGELOG.md CHANGED
@@ -1,5 +1,104 @@
1
1
  # @modern-js/app-tools
2
2
 
3
+ ## 2.23.1
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies [20c85bb]
8
+ - Updated dependencies [f08bbfc]
9
+ - Updated dependencies [a6b313a]
10
+ - Updated dependencies [5772927]
11
+ - Updated dependencies [811ccd4]
12
+ - Updated dependencies [5a3eeff]
13
+ - Updated dependencies [4af25d9]
14
+ - Updated dependencies [4d4dca0]
15
+ - Updated dependencies [8f2cab0]
16
+ - @modern-js/builder-webpack-provider@2.23.1
17
+ - @modern-js/builder-rspack-provider@2.23.1
18
+ - @modern-js/builder@2.23.1
19
+ - @modern-js/utils@2.23.1
20
+ - @modern-js/builder-shared@2.23.1
21
+ - @modern-js/builder-plugin-esbuild@2.23.1
22
+ - @modern-js/builder-plugin-node-polyfill@2.23.1
23
+ - @modern-js/core@2.23.1
24
+ - @modern-js/plugin-data-loader@2.23.1
25
+ - @modern-js/plugin-i18n@2.23.1
26
+ - @modern-js/plugin-lint@2.23.1
27
+ - @modern-js/new-action@2.23.1
28
+ - @modern-js/prod-server@2.23.1
29
+ - @modern-js/server@2.23.1
30
+ - @modern-js/node-bundle-require@2.23.1
31
+ - @modern-js/plugin@2.23.1
32
+ - @modern-js/upgrade@2.23.1
33
+ - @modern-js/types@2.23.1
34
+
35
+ ## 2.23.0
36
+
37
+ ### Minor Changes
38
+
39
+ - b185fdf: refactor: merge the swc plugin
40
+ refactor: 合并 swc 插件
41
+
42
+ ### Patch Changes
43
+
44
+ - 162fb9d: fix: should only restart when changed file is watched
45
+ fix: 只有在变化的文件被监听是才重启
46
+ - 7e6fb5f: chore: publishConfig add provenance config
47
+
48
+ chore: publishConfig 增加 provenance 配置
49
+
50
+ - b593040: fix(app-tools): incorrect tools.tailwindcss schema
51
+
52
+ fix(app-tools): 修复 tools.tailwindcss schema 错误
53
+
54
+ - 6dec7c2: test(utils): reuse the snapshot serializer of vitest config
55
+
56
+ test(utils): 复用 vitest 的 snapshot serializer
57
+
58
+ - c3216b5: chore: split the scheme into the plugin
59
+
60
+ chore: 拆分 scheme 到插件内部
61
+
62
+ - e5259fb: fix: absoluteEntryDir should support directory entry
63
+ fix: absoluteEntryDir 应该支持配置目录 entry,这里 document 会使用
64
+ - Updated dependencies [15eac36]
65
+ - Updated dependencies [a912b66]
66
+ - Updated dependencies [9b270b6]
67
+ - Updated dependencies [d4e85c1]
68
+ - Updated dependencies [7e6fb5f]
69
+ - Updated dependencies [a7a7ad7]
70
+ - Updated dependencies [f212633]
71
+ - Updated dependencies [b593040]
72
+ - Updated dependencies [e2245c3]
73
+ - Updated dependencies [5684381]
74
+ - Updated dependencies [6dec7c2]
75
+ - Updated dependencies [c3216b5]
76
+ - Updated dependencies [f14f920]
77
+ - Updated dependencies [692cc0e]
78
+ - Updated dependencies [38eccef]
79
+ - Updated dependencies [e5259fb]
80
+ - Updated dependencies [f91c557]
81
+ - Updated dependencies [65721f2]
82
+ - Updated dependencies [a82d6f7]
83
+ - @modern-js/builder-webpack-provider@2.23.0
84
+ - @modern-js/builder-rspack-provider@2.23.0
85
+ - @modern-js/builder-shared@2.23.0
86
+ - @modern-js/builder@2.23.0
87
+ - @modern-js/builder-plugin-node-polyfill@2.23.0
88
+ - @modern-js/node-bundle-require@2.23.0
89
+ - @modern-js/builder-plugin-esbuild@2.23.0
90
+ - @modern-js/plugin-data-loader@2.23.0
91
+ - @modern-js/new-action@2.23.0
92
+ - @modern-js/prod-server@2.23.0
93
+ - @modern-js/plugin-i18n@2.23.0
94
+ - @modern-js/plugin-lint@2.23.0
95
+ - @modern-js/upgrade@2.23.0
96
+ - @modern-js/plugin@2.23.0
97
+ - @modern-js/server@2.23.0
98
+ - @modern-js/types@2.23.0
99
+ - @modern-js/utils@2.23.0
100
+ - @modern-js/core@2.23.0
101
+
3
102
  ## 2.22.1
4
103
 
5
104
  ### Patch Changes
@@ -19,6 +19,7 @@ const ensureExtensions = (file) => {
19
19
  }
20
20
  return file;
21
21
  };
22
+ const isDirectory = (file) => !_path.default.extname(file);
22
23
  const ifAlreadyExists = (entrypoints, checked) => entrypoints.some((entrypoint) => {
23
24
  if (ensureExtensions(entrypoint.entry) === ensureExtensions(checked.entry)) {
24
25
  checked.entryName = entrypoint.entryName;
@@ -34,7 +35,7 @@ const ifAlreadyExists = (entrypoints, checked) => entrypoints.some((entrypoint)
34
35
  });
35
36
  const getBundleEntry = (appContext, config) => {
36
37
  const { appDirectory, packageName } = appContext;
37
- const { source: { disableDefaultEntries, entries, entriesDir } } = config;
38
+ const { disableDefaultEntries, entries, entriesDir } = config.source;
38
39
  const defaults = disableDefaultEntries ? [] : (0, _getFileSystemEntry.getFileSystemEntry)(appContext, config);
39
40
  if (entries) {
40
41
  Object.keys(entries).forEach((name) => {
@@ -42,13 +43,13 @@ const getBundleEntry = (appContext, config) => {
42
43
  const entrypoint = typeof value === "string" ? {
43
44
  entryName: name,
44
45
  entry: (0, _utils.ensureAbsolutePath)(appDirectory, value),
45
- absoluteEntryDir: _path.default.dirname((0, _utils.ensureAbsolutePath)(appDirectory, value)),
46
+ absoluteEntryDir: isDirectory((0, _utils.ensureAbsolutePath)(appDirectory, value)) ? (0, _utils.ensureAbsolutePath)(appDirectory, value) : _path.default.dirname((0, _utils.ensureAbsolutePath)(appDirectory, value)),
46
47
  isAutoMount: true,
47
48
  fileSystemRoutes: _utils.fs.statSync((0, _utils.ensureAbsolutePath)(appDirectory, value)).isDirectory() ? {} : void 0
48
49
  } : {
49
50
  entryName: name,
50
51
  entry: (0, _utils.ensureAbsolutePath)(appDirectory, value.entry),
51
- absoluteEntryDir: _path.default.dirname((0, _utils.ensureAbsolutePath)(appDirectory, value.entry)),
52
+ absoluteEntryDir: isDirectory((0, _utils.ensureAbsolutePath)(appDirectory, value.entry)) ? (0, _utils.ensureAbsolutePath)(appDirectory, value.entry) : _path.default.dirname((0, _utils.ensureAbsolutePath)(appDirectory, value.entry)),
52
53
  isAutoMount: !value.disableMount,
53
54
  customBootstrap: value.customBootstrap && (0, _utils.ensureAbsolutePath)(appDirectory, value.customBootstrap),
54
55
  fileSystemRoutes: _utils.fs.statSync((0, _utils.ensureAbsolutePath)(appDirectory, value.entry)).isDirectory() ? {} : void 0
@@ -41,7 +41,7 @@ const _default = ({ bundler }) => {
41
41
  }
42
42
  } catch {
43
43
  }
44
- const apiOnly = await (0, _utils.isApiOnly)(appContext.appDirectory, (_resolvedConfig_source = resolvedConfig.source) === null || _resolvedConfig_source === void 0 ? void 0 : _resolvedConfig_source.entriesDir);
44
+ const apiOnly = await (0, _utils.isApiOnly)(appContext.appDirectory, (_resolvedConfig_source = resolvedConfig.source) === null || _resolvedConfig_source === void 0 ? void 0 : _resolvedConfig_source.entriesDir, appContext.apiDirectory);
45
45
  await hookRunners.addRuntimeExports();
46
46
  if (apiOnly) {
47
47
  const { routes: routes2 } = await hookRunners.modifyServerRoutes({
@@ -12,7 +12,7 @@ const _path = require("path");
12
12
  const _createCopyPattern = require("./createCopyPattern");
13
13
  const builderPluginAdapterModern = (options) => {
14
14
  return {
15
- name: "builder-plugin-adapter-",
15
+ name: "builder-plugin-adapter-modern",
16
16
  setup(api) {
17
17
  const { normalizedConfig: modernConfig, appContext } = options;
18
18
  api.modifyWebpackChain((chain, { CHAIN_ID }) => {
@@ -21,7 +21,7 @@ const start = async (api) => {
21
21
  const hookRunners = api.useHookRunners();
22
22
  const { appDirectory, port, serverConfigFile } = appContext;
23
23
  _utils.logger.log(_utils.chalk.cyan(`Starting the modern server...`));
24
- const apiOnly = await (0, _utils.isApiOnly)(appContext.appDirectory, userConfig === null || userConfig === void 0 ? void 0 : (_userConfig_source = userConfig.source) === null || _userConfig_source === void 0 ? void 0 : _userConfig_source.entriesDir);
24
+ const apiOnly = await (0, _utils.isApiOnly)(appContext.appDirectory, userConfig === null || userConfig === void 0 ? void 0 : (_userConfig_source = userConfig.source) === null || _userConfig_source === void 0 ? void 0 : _userConfig_source.entriesDir, appContext.apiDirectory);
25
25
  const serverInternalPlugins = await (0, _getServerInternalPlugins.getServerInternalPlugins)(api);
26
26
  const app = await (0, _prodserver.default)({
27
27
  pwd: appDirectory,
package/dist/cjs/index.js CHANGED
@@ -112,6 +112,12 @@ const _default = (options = {
112
112
  ],
113
113
  setup: (api) => {
114
114
  const appContext = api.useAppContext();
115
+ let watchedFiles = [];
116
+ const isWatched = (fn) => {
117
+ return watchedFiles.some((ff) => {
118
+ return fn.includes(ff);
119
+ });
120
+ };
115
121
  api.setAppContext({
116
122
  ...appContext,
117
123
  toolsType: "app-tools"
@@ -172,15 +178,17 @@ const _default = (options = {
172
178
  async watchFiles() {
173
179
  const appContext2 = api.useAppContext();
174
180
  const config = api.useResolvedConfigContext();
175
- return (0, _generateWatchFiles.generateWatchFiles)(appContext2, config.source.configDir);
181
+ const files = await (0, _generateWatchFiles.generateWatchFiles)(appContext2, config.source.configDir);
182
+ watchedFiles = files;
183
+ return files;
176
184
  },
177
185
  // 这里会被 core/initWatcher 监听的文件变动触发,如果是 src 目录下的文件变动,则不做 restart
178
186
  async fileChange(e) {
179
187
  const { filename, eventType } = e;
180
188
  const appContext2 = api.useAppContext();
181
- const { appDirectory, srcDirectory } = appContext2;
189
+ const { appDirectory } = appContext2;
182
190
  const absolutePath = _path.default.resolve(appDirectory, filename);
183
- if (!absolutePath.includes(srcDirectory) && (eventType === "change" || eventType === "unlink")) {
191
+ if (isWatched(absolutePath) && (eventType === "change" || eventType === "unlink")) {
184
192
  const { closeServer } = await Promise.resolve().then(() => /* @__PURE__ */ _interop_require_wildcard._(require("./utils/createServer")));
185
193
  await closeServer();
186
194
  await (0, _restart.restart)(api.useHookRunners(), filename);
@@ -166,29 +166,13 @@ const server = {
166
166
  }
167
167
  };
168
168
  const tools = {
169
- tailwindcss: {
170
- type: "object"
171
- },
172
- jest: {
173
- typeof: [
174
- "object",
175
- "function"
176
- ]
177
- },
178
169
  esbuild: {
179
170
  typeof: [
180
171
  "object"
181
172
  ]
182
173
  }
183
174
  };
184
- const deploy = {
185
- microFrontend: {
186
- type: [
187
- "boolean",
188
- "object"
189
- ]
190
- }
191
- };
175
+ const deploy = {};
192
176
  const builderPlugins = {
193
177
  type: "array"
194
178
  };
@@ -10,6 +10,9 @@ var ensureExtensions = function(file) {
10
10
  }
11
11
  return file;
12
12
  };
13
+ var isDirectory = function(file) {
14
+ return !path.extname(file);
15
+ };
13
16
  var ifAlreadyExists = function(entrypoints, checked) {
14
17
  return entrypoints.some(function(entrypoint) {
15
18
  if (ensureExtensions(entrypoint.entry) === ensureExtensions(checked.entry)) {
@@ -32,13 +35,13 @@ export var getBundleEntry = function(appContext, config) {
32
35
  var entrypoint = typeof value === "string" ? {
33
36
  entryName: name,
34
37
  entry: ensureAbsolutePath(appDirectory, value),
35
- absoluteEntryDir: path.dirname(ensureAbsolutePath(appDirectory, value)),
38
+ absoluteEntryDir: isDirectory(ensureAbsolutePath(appDirectory, value)) ? ensureAbsolutePath(appDirectory, value) : path.dirname(ensureAbsolutePath(appDirectory, value)),
36
39
  isAutoMount: true,
37
40
  fileSystemRoutes: fs.statSync(ensureAbsolutePath(appDirectory, value)).isDirectory() ? {} : void 0
38
41
  } : {
39
42
  entryName: name,
40
43
  entry: ensureAbsolutePath(appDirectory, value.entry),
41
- absoluteEntryDir: path.dirname(ensureAbsolutePath(appDirectory, value.entry)),
44
+ absoluteEntryDir: isDirectory(ensureAbsolutePath(appDirectory, value.entry)) ? ensureAbsolutePath(appDirectory, value.entry) : path.dirname(ensureAbsolutePath(appDirectory, value.entry)),
42
45
  isAutoMount: !value.disableMount,
43
46
  customBootstrap: value.customBootstrap && ensureAbsolutePath(appDirectory, value.customBootstrap),
44
47
  fileSystemRoutes: fs.statSync(ensureAbsolutePath(appDirectory, value.entry)).isDirectory() ? {} : void 0
@@ -42,7 +42,7 @@ export default function(param) {
42
42
  }
43
43
  return [
44
44
  4,
45
- isApiOnly(appContext.appDirectory, (_resolvedConfig_source = resolvedConfig.source) === null || _resolvedConfig_source === void 0 ? void 0 : _resolvedConfig_source.entriesDir)
45
+ isApiOnly(appContext.appDirectory, (_resolvedConfig_source = resolvedConfig.source) === null || _resolvedConfig_source === void 0 ? void 0 : _resolvedConfig_source.entriesDir, appContext.apiDirectory)
46
46
  ];
47
47
  case 1:
48
48
  apiOnly = _state.sent();
@@ -3,7 +3,7 @@ import { join } from "path";
3
3
  import { createPublicPattern } from "./createCopyPattern";
4
4
  export var builderPluginAdapterModern = function(options) {
5
5
  return {
6
- name: "builder-plugin-adapter-",
6
+ name: "builder-plugin-adapter-modern",
7
7
  setup: function setup(api) {
8
8
  var modernConfig = options.normalizedConfig, appContext = options.appContext;
9
9
  api.modifyWebpackChain(function(chain, param) {
@@ -20,7 +20,7 @@ export var start = function() {
20
20
  logger.log(chalk.cyan("Starting the modern server..."));
21
21
  return [
22
22
  4,
23
- isApiOnly(appContext.appDirectory, userConfig === null || userConfig === void 0 ? void 0 : (_userConfig_source = userConfig.source) === null || _userConfig_source === void 0 ? void 0 : _userConfig_source.entriesDir)
23
+ isApiOnly(appContext.appDirectory, userConfig === null || userConfig === void 0 ? void 0 : (_userConfig_source = userConfig.source) === null || _userConfig_source === void 0 ? void 0 : _userConfig_source.entriesDir, appContext.apiDirectory)
24
24
  ];
25
25
  case 1:
26
26
  apiOnly = _state.sent();
package/dist/esm/index.js CHANGED
@@ -297,6 +297,12 @@ export default function() {
297
297
  ],
298
298
  setup: function(api) {
299
299
  var appContext = api.useAppContext();
300
+ var watchedFiles = [];
301
+ var isWatched = function(fn) {
302
+ return watchedFiles.some(function(ff) {
303
+ return fn.includes(ff);
304
+ });
305
+ };
300
306
  api.setAppContext(_object_spread_props(_object_spread({}, appContext), {
301
307
  toolsType: "app-tools"
302
308
  }));
@@ -501,14 +507,24 @@ export default function() {
501
507
  },
502
508
  watchFiles: function watchFiles() {
503
509
  return _async_to_generator(function() {
504
- var appContext2, config;
510
+ var appContext2, config, files;
505
511
  return _ts_generator(this, function(_state) {
506
- appContext2 = api.useAppContext();
507
- config = api.useResolvedConfigContext();
508
- return [
509
- 2,
510
- generateWatchFiles(appContext2, config.source.configDir)
511
- ];
512
+ switch (_state.label) {
513
+ case 0:
514
+ appContext2 = api.useAppContext();
515
+ config = api.useResolvedConfigContext();
516
+ return [
517
+ 4,
518
+ generateWatchFiles(appContext2, config.source.configDir)
519
+ ];
520
+ case 1:
521
+ files = _state.sent();
522
+ watchedFiles = files;
523
+ return [
524
+ 2,
525
+ files
526
+ ];
527
+ }
512
528
  });
513
529
  })();
514
530
  },
@@ -516,15 +532,15 @@ export default function() {
516
532
  // 这里会被 core/initWatcher 监听的文件变动触发,如果是 src 目录下的文件变动,则不做 restart
517
533
  function fileChange(e) {
518
534
  return _async_to_generator(function() {
519
- var filename, eventType, appContext2, appDirectory, srcDirectory, absolutePath, closeServer;
535
+ var filename, eventType, appContext2, appDirectory, absolutePath, closeServer;
520
536
  return _ts_generator(this, function(_state) {
521
537
  switch (_state.label) {
522
538
  case 0:
523
539
  filename = e.filename, eventType = e.eventType;
524
540
  appContext2 = api.useAppContext();
525
- appDirectory = appContext2.appDirectory, srcDirectory = appContext2.srcDirectory;
541
+ appDirectory = appContext2.appDirectory;
526
542
  absolutePath = path.resolve(appDirectory, filename);
527
- if (!(!absolutePath.includes(srcDirectory) && (eventType === "change" || eventType === "unlink")))
543
+ if (!(isWatched(absolutePath) && (eventType === "change" || eventType === "unlink")))
528
544
  return [
529
545
  3,
530
546
  4
@@ -144,29 +144,13 @@ var server = {
144
144
  }
145
145
  };
146
146
  var tools = {
147
- tailwindcss: {
148
- type: "object"
149
- },
150
- jest: {
151
- typeof: [
152
- "object",
153
- "function"
154
- ]
155
- },
156
147
  esbuild: {
157
148
  typeof: [
158
149
  "object"
159
150
  ]
160
151
  }
161
152
  };
162
- var deploy = {
163
- microFrontend: {
164
- type: [
165
- "boolean",
166
- "object"
167
- ]
168
- }
169
- };
153
+ var deploy = {};
170
154
  var builderPlugins = {
171
155
  type: "array"
172
156
  };
@@ -8,6 +8,7 @@ const ensureExtensions = (file) => {
8
8
  }
9
9
  return file;
10
10
  };
11
+ const isDirectory = (file) => !path.extname(file);
11
12
  const ifAlreadyExists = (entrypoints, checked) => entrypoints.some((entrypoint) => {
12
13
  if (ensureExtensions(entrypoint.entry) === ensureExtensions(checked.entry)) {
13
14
  checked.entryName = entrypoint.entryName;
@@ -23,7 +24,7 @@ const ifAlreadyExists = (entrypoints, checked) => entrypoints.some((entrypoint)
23
24
  });
24
25
  export const getBundleEntry = (appContext, config) => {
25
26
  const { appDirectory, packageName } = appContext;
26
- const { source: { disableDefaultEntries, entries, entriesDir } } = config;
27
+ const { disableDefaultEntries, entries, entriesDir } = config.source;
27
28
  const defaults = disableDefaultEntries ? [] : getFileSystemEntry(appContext, config);
28
29
  if (entries) {
29
30
  Object.keys(entries).forEach((name) => {
@@ -31,13 +32,13 @@ export const getBundleEntry = (appContext, config) => {
31
32
  const entrypoint = typeof value === "string" ? {
32
33
  entryName: name,
33
34
  entry: ensureAbsolutePath(appDirectory, value),
34
- absoluteEntryDir: path.dirname(ensureAbsolutePath(appDirectory, value)),
35
+ absoluteEntryDir: isDirectory(ensureAbsolutePath(appDirectory, value)) ? ensureAbsolutePath(appDirectory, value) : path.dirname(ensureAbsolutePath(appDirectory, value)),
35
36
  isAutoMount: true,
36
37
  fileSystemRoutes: fs.statSync(ensureAbsolutePath(appDirectory, value)).isDirectory() ? {} : void 0
37
38
  } : {
38
39
  entryName: name,
39
40
  entry: ensureAbsolutePath(appDirectory, value.entry),
40
- absoluteEntryDir: path.dirname(ensureAbsolutePath(appDirectory, value.entry)),
41
+ absoluteEntryDir: isDirectory(ensureAbsolutePath(appDirectory, value.entry)) ? ensureAbsolutePath(appDirectory, value.entry) : path.dirname(ensureAbsolutePath(appDirectory, value.entry)),
41
42
  isAutoMount: !value.disableMount,
42
43
  customBootstrap: value.customBootstrap && ensureAbsolutePath(appDirectory, value.customBootstrap),
43
44
  fileSystemRoutes: fs.statSync(ensureAbsolutePath(appDirectory, value.entry)).isDirectory() ? {} : void 0
@@ -30,7 +30,7 @@ export default ({ bundler }) => {
30
30
  }
31
31
  } catch {
32
32
  }
33
- const apiOnly = await isApiOnly(appContext.appDirectory, (_resolvedConfig_source = resolvedConfig.source) === null || _resolvedConfig_source === void 0 ? void 0 : _resolvedConfig_source.entriesDir);
33
+ const apiOnly = await isApiOnly(appContext.appDirectory, (_resolvedConfig_source = resolvedConfig.source) === null || _resolvedConfig_source === void 0 ? void 0 : _resolvedConfig_source.entriesDir, appContext.apiDirectory);
34
34
  await hookRunners.addRuntimeExports();
35
35
  if (apiOnly) {
36
36
  const { routes: routes2 } = await hookRunners.modifyServerRoutes({
@@ -2,7 +2,7 @@ import { join } from "path";
2
2
  import { createPublicPattern } from "./createCopyPattern";
3
3
  export const builderPluginAdapterModern = (options) => {
4
4
  return {
5
- name: "builder-plugin-adapter-",
5
+ name: "builder-plugin-adapter-modern",
6
6
  setup(api) {
7
7
  const { normalizedConfig: modernConfig, appContext } = options;
8
8
  api.modifyWebpackChain((chain, { CHAIN_ID }) => {
@@ -10,7 +10,7 @@ export const start = async (api) => {
10
10
  const hookRunners = api.useHookRunners();
11
11
  const { appDirectory, port, serverConfigFile } = appContext;
12
12
  logger.log(chalk.cyan(`Starting the modern server...`));
13
- const apiOnly = await isApiOnly(appContext.appDirectory, userConfig === null || userConfig === void 0 ? void 0 : (_userConfig_source = userConfig.source) === null || _userConfig_source === void 0 ? void 0 : _userConfig_source.entriesDir);
13
+ const apiOnly = await isApiOnly(appContext.appDirectory, userConfig === null || userConfig === void 0 ? void 0 : (_userConfig_source = userConfig.source) === null || _userConfig_source === void 0 ? void 0 : _userConfig_source.entriesDir, appContext.apiDirectory);
14
14
  const serverInternalPlugins = await getServerInternalPlugins(api);
15
15
  const app = await server({
16
16
  pwd: appDirectory,
@@ -84,6 +84,12 @@ export default (options = {
84
84
  ],
85
85
  setup: (api) => {
86
86
  const appContext = api.useAppContext();
87
+ let watchedFiles = [];
88
+ const isWatched = (fn) => {
89
+ return watchedFiles.some((ff) => {
90
+ return fn.includes(ff);
91
+ });
92
+ };
87
93
  api.setAppContext({
88
94
  ...appContext,
89
95
  toolsType: "app-tools"
@@ -144,15 +150,17 @@ export default (options = {
144
150
  async watchFiles() {
145
151
  const appContext2 = api.useAppContext();
146
152
  const config = api.useResolvedConfigContext();
147
- return generateWatchFiles(appContext2, config.source.configDir);
153
+ const files = await generateWatchFiles(appContext2, config.source.configDir);
154
+ watchedFiles = files;
155
+ return files;
148
156
  },
149
157
  // 这里会被 core/initWatcher 监听的文件变动触发,如果是 src 目录下的文件变动,则不做 restart
150
158
  async fileChange(e) {
151
159
  const { filename, eventType } = e;
152
160
  const appContext2 = api.useAppContext();
153
- const { appDirectory, srcDirectory } = appContext2;
161
+ const { appDirectory } = appContext2;
154
162
  const absolutePath = path.resolve(appDirectory, filename);
155
- if (!absolutePath.includes(srcDirectory) && (eventType === "change" || eventType === "unlink")) {
163
+ if (isWatched(absolutePath) && (eventType === "change" || eventType === "unlink")) {
156
164
  const { closeServer } = await import("./utils/createServer");
157
165
  await closeServer();
158
166
  await restart(api.useHookRunners(), filename);
@@ -145,29 +145,13 @@ const server = {
145
145
  }
146
146
  };
147
147
  const tools = {
148
- tailwindcss: {
149
- type: "object"
150
- },
151
- jest: {
152
- typeof: [
153
- "object",
154
- "function"
155
- ]
156
- },
157
148
  esbuild: {
158
149
  typeof: [
159
150
  "object"
160
151
  ]
161
152
  }
162
153
  };
163
- const deploy = {
164
- microFrontend: {
165
- type: [
166
- "boolean",
167
- "object"
168
- ]
169
- }
170
- };
154
+ const deploy = {};
171
155
  const builderPlugins = {
172
156
  type: "array"
173
157
  };
@@ -9,20 +9,25 @@ export type BuilderToolsConfig = UnwrapBuilderConfig<BuilderConfig, 'tools'> & {
9
9
  esbuild?: PluginEsbuildOptions;
10
10
  };
11
11
  export type RsBuilderToolsConfig = UnwrapBuilderConfig<RsBuilderConfig, 'tools'>;
12
- /**
13
- * The configuration of `tools.tailwindcss` is provided by `tailwindcss` plugin.
14
- * Please use `yarn new` or `pnpm new` to enable the corresponding capability.
15
- * @requires `tailwindcss` plugin
16
- */
17
12
  export type Tailwindcss = Record<string, any> | ((options: Record<string, any>) => Record<string, any> | void);
18
13
  export interface SharedToolsConfig extends BuilderSharedToolsConfig {
14
+ /**
15
+ * The configuration of `tools.tailwindcss` is provided by `tailwindcss` plugin.
16
+ * Please use `yarn new` or `pnpm new` to enable the corresponding capability.
17
+ * @requires `tailwindcss` plugin
18
+ */
19
19
  tailwindcss?: Tailwindcss;
20
+ /**
21
+ * The configuration of `tools.jest` is provided by `test` plugin.
22
+ * Please use `yarn new` or `pnpm new` to enable the corresponding capability.
23
+ * @requires `test` plugin
24
+ */
20
25
  jest?: JestConfig | ((jestConfig: JestConfig) => JestConfig);
21
26
  /**
22
27
  * The configuration of `swc` is provided by `swc` plugin.
23
28
  * @requires `swc` plugin
24
29
  */
25
- swc?: PluginSwcOptions;
30
+ swc?: PluginSwcOptions<'outer'>;
26
31
  }
27
32
  export interface ToolsUserConfig extends BuilderToolsConfig, SharedToolsConfig {}
28
33
  export interface RsToolsUserConfig extends SharedToolsConfig, RsBuilderToolsConfig {}
package/package.json CHANGED
@@ -15,7 +15,7 @@
15
15
  "modern",
16
16
  "modern.js"
17
17
  ],
18
- "version": "2.22.1",
18
+ "version": "2.23.1",
19
19
  "jsnext:source": "./src/index.ts",
20
20
  "types": "./dist/types/index.d.ts",
21
21
  "main": "./dist/cjs/index.js",
@@ -73,23 +73,23 @@
73
73
  "esbuild": "0.15.7",
74
74
  "rspack-plugin-virtual-module": "0.1.0",
75
75
  "@swc/helpers": "0.5.1",
76
- "@modern-js/builder": "2.22.1",
77
- "@modern-js/builder-plugin-esbuild": "2.22.1",
78
- "@modern-js/builder-plugin-node-polyfill": "2.22.1",
79
- "@modern-js/builder-shared": "2.22.1",
80
- "@modern-js/builder-webpack-provider": "2.22.1",
81
- "@modern-js/core": "2.22.1",
82
- "@modern-js/new-action": "2.22.1",
83
- "@modern-js/node-bundle-require": "2.22.1",
84
- "@modern-js/plugin": "2.22.1",
85
- "@modern-js/plugin-data-loader": "2.22.1",
86
- "@modern-js/plugin-i18n": "2.22.1",
87
- "@modern-js/plugin-lint": "2.22.1",
88
- "@modern-js/prod-server": "2.22.1",
89
- "@modern-js/server": "2.22.1",
90
- "@modern-js/types": "2.22.1",
91
- "@modern-js/upgrade": "2.22.1",
92
- "@modern-js/utils": "2.22.1"
76
+ "@modern-js/builder": "2.23.1",
77
+ "@modern-js/builder-plugin-esbuild": "2.23.1",
78
+ "@modern-js/builder-plugin-node-polyfill": "2.23.1",
79
+ "@modern-js/builder-shared": "2.23.1",
80
+ "@modern-js/builder-webpack-provider": "2.23.1",
81
+ "@modern-js/core": "2.23.1",
82
+ "@modern-js/new-action": "2.23.1",
83
+ "@modern-js/node-bundle-require": "2.23.1",
84
+ "@modern-js/plugin": "2.23.1",
85
+ "@modern-js/plugin-data-loader": "2.23.1",
86
+ "@modern-js/plugin-i18n": "2.23.1",
87
+ "@modern-js/plugin-lint": "2.23.1",
88
+ "@modern-js/prod-server": "2.23.1",
89
+ "@modern-js/server": "2.23.1",
90
+ "@modern-js/types": "2.23.1",
91
+ "@modern-js/upgrade": "2.23.1",
92
+ "@modern-js/utils": "2.23.1"
93
93
  },
94
94
  "devDependencies": {
95
95
  "@types/babel__traverse": "^7.14.2",
@@ -98,14 +98,14 @@
98
98
  "jest": "^29",
99
99
  "typescript": "^5",
100
100
  "webpack": "^5.82.1",
101
- "@modern-js/builder-plugin-swc": "2.22.1",
102
- "@modern-js/builder-rspack-provider": "2.22.1",
103
- "@modern-js/server-core": "2.22.1",
104
- "@scripts/build": "2.22.1",
105
- "@scripts/jest-config": "2.22.1"
101
+ "@modern-js/builder-plugin-swc": "2.23.1",
102
+ "@modern-js/builder-rspack-provider": "2.23.1",
103
+ "@modern-js/server-core": "2.23.1",
104
+ "@scripts/build": "2.23.1",
105
+ "@scripts/jest-config": "2.23.1"
106
106
  },
107
107
  "peerDependencies": {
108
- "@modern-js/builder-rspack-provider": "^2.22.1"
108
+ "@modern-js/builder-rspack-provider": "^2.23.1"
109
109
  },
110
110
  "peerDependenciesMeta": {
111
111
  "@modern-js/builder-rspack-provider": {
@@ -115,7 +115,8 @@
115
115
  "sideEffects": false,
116
116
  "publishConfig": {
117
117
  "registry": "https://registry.npmjs.org/",
118
- "access": "public"
118
+ "access": "public",
119
+ "provenance": true
119
120
  },
120
121
  "scripts": {
121
122
  "new": "modern-lib new",