@lark-apaas/fullstack-rspack-preset 1.0.55-alpha.23 → 1.0.55-alpha.25

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.
@@ -63,11 +63,17 @@ function resolveEntryFiles(entry, context) {
63
63
  }
64
64
  /**
65
65
  * 构建入口文件匹配正则:精确匹配 resolved 路径,无路径时兜底默认正则。
66
+ * 路径分隔符统一用 [/\\] 匹配,避免跨平台问题(rspack 传给 test 的路径分隔符不确定)。
66
67
  */
67
68
  function buildEntryTest(entryFiles) {
68
69
  if (entryFiles.length === 0)
69
70
  return FALLBACK_ENTRY_REGEX;
70
- const escaped = entryFiles.map(f => path_1.default.normalize(f).replace(/[.*+?^${}()|[\]\\]/g, '\\$&'));
71
+ const escaped = entryFiles.map(f => {
72
+ return path_1.default.normalize(f)
73
+ .split(path_1.default.sep) // 按平台分隔符拆段
74
+ .map(seg => seg.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')) // 每段转义正则特殊字符
75
+ .join('[/\\\\]'); // 用 [/\\] 重新拼接
76
+ });
71
77
  return new RegExp(`(${escaped.join('|')})$`);
72
78
  }
73
79
  class BasenameInjectionPlugin {
@@ -79,8 +85,7 @@ class BasenameInjectionPlugin {
79
85
  const envBasePath = this.envBasePath;
80
86
  // entryOption hook:配置已完全解析合并(包括异步 entry 函数的返回值),
81
87
  // 是读 entry 最安全的时机。参考 RuntimeInjectionPlugin 的做法。
82
- compiler.hooks.entryOption.tap(PLUGIN_NAME, (_context, entry) => {
83
- const context = compiler.options.context || process.cwd();
88
+ compiler.hooks.entryOption.tap(PLUGIN_NAME, (context, entry) => {
84
89
  // 动态 entry(函数形式)无法在此阶段解析,兜底到默认正则
85
90
  const entryFiles = (typeof entry !== 'function')
86
91
  ? resolveEntryFiles(entry, context)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lark-apaas/fullstack-rspack-preset",
3
- "version": "1.0.55-alpha.23",
3
+ "version": "1.0.55-alpha.25",
4
4
  "files": [
5
5
  "lib",
6
6
  "patches",