@meteorjs/rspack 2.2.0-beta.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.
package/lib/ignore.js CHANGED
@@ -85,15 +85,25 @@ function createIgnoreGlobConfig(entries = []) {
85
85
  /**
86
86
  * Creates a regex pattern to match the specified glob patterns.
87
87
  * Converts glob patterns with * and ** into regex equivalents.
88
- *
88
+ *
89
89
  * @param {string[]} globPatterns - Array of glob patterns from createIgnoreGlobConfig
90
+ * @param {string} [rootPath] - Absolute root that matched paths must belong to
90
91
  * @returns {RegExp} - Regex pattern to match the specified patterns
91
92
  */
92
- function createIgnoreRegex(globPatterns) {
93
+ function createIgnoreRegex(globPatterns, rootPath) {
93
94
  if (!Array.isArray(globPatterns) || globPatterns.length === 0) {
94
95
  throw new Error('globPatterns must be a non-empty array');
95
96
  }
96
97
 
98
+ // Rspack applies context exclusions to absolute module paths. Anchor rooted
99
+ // patterns here so matching starts inside the app, not in a parent folder.
100
+ const pathPrefix = rootPath
101
+ ? `^${rootPath
102
+ .replace(/\\/g, '/')
103
+ .replace(/\/+$/, '')
104
+ .replace(/[.*+?^${}()|[\]\\]/g, '\\$&')}(?=/|$)`
105
+ : '(?:^|/)';
106
+
97
107
  // Process each glob pattern and convert to regex
98
108
  const regexPatterns = globPatterns.map(pattern => {
99
109
  // Skip negation patterns for the regex
@@ -115,9 +125,7 @@ function createIgnoreRegex(globPatterns) {
115
125
  // Convert the ** placeholder to its regex equivalent (any number of characters including /)
116
126
  regexPattern = regexPattern.replace(new RegExp(DOUBLE_ASTERISK_PLACEHOLDER, 'g'), '.*');
117
127
 
118
- // For absolute paths, we don't want to force the pattern to match from the beginning
119
- // but we still want to ensure it matches to the end of the path segment
120
- regexPattern = '(?:^|/)' + regexPattern;
128
+ regexPattern = pathPrefix + regexPattern;
121
129
 
122
130
  return regexPattern;
123
131
  }).filter(pattern => pattern !== null);
package/lib/test.js CHANGED
@@ -44,7 +44,8 @@ const generateEagerTestFile = ({
44
44
 
45
45
  // Create regex from ignore entries
46
46
  const excludeFoldersRegex = createIgnoreRegex(
47
- createIgnoreGlobConfig(ignoreEntries)
47
+ createIgnoreGlobConfig(ignoreEntries),
48
+ projectDir,
48
49
  );
49
50
  // Create regex from meteor ignore entries
50
51
  const excludeMeteorIgnoreRegex = inMeteorIgnoreEntries.length > 0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@meteorjs/rspack",
3
- "version": "2.2.0-beta.0",
3
+ "version": "2.2.0",
4
4
  "description": "Configuration logic for using Rspack in Meteor projects",
5
5
  "main": "index.js",
6
6
  "type": "commonjs",