@granite-js/mpack 2.5.5 → 2.5.6

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,13 @@
1
1
  # @granite-js/mpack
2
2
 
3
+ ## 2.5.6
4
+
5
+ ### Patch Changes
6
+
7
+ - 0c7ea11: Fix Metro hot reloads for Yarn PnP workspace packages by forwarding physical file changes to their virtual module paths without losing peer dependency resolution.
8
+ - @granite-js/plugin-core@2.5.6
9
+ - @granite-js/utils@2.5.6
10
+
3
11
  ## 2.5.5
4
12
 
5
13
  ### Patch Changes
@@ -39,6 +39,8 @@ class DependencyGraph extends EventEmitter {
39
39
  _moduleResolver;
40
40
  _resolutionCache;
41
41
  _readyPromise;
42
+ // MARK: - GRANITE: Keep each PnP peer instance while tracking its physical file.
43
+ _virtualPathsByRealPath = /* @__PURE__ */ new Map();
42
44
  constructor(config, options) {
43
45
  super();
44
46
  this._config = config;
@@ -91,6 +93,11 @@ class DependencyGraph extends EventEmitter {
91
93
  /* $FlowFixMe[missing-local-annot] The type annotation(s) required by Flow's
92
94
  * LTI update could not be added via codemod */
93
95
  _onHasteChange({ eventsQueue, hasteFS, moduleMap }) {
96
+ eventsQueue.forEach((event) => {
97
+ this._virtualPathsByRealPath.get(event.filePath)?.forEach((filePath) => {
98
+ eventsQueue.push({ ...event, filePath });
99
+ });
100
+ });
94
101
  this._hasteFS = hasteFS;
95
102
  this._resolutionCache = /* @__PURE__ */ new Map();
96
103
  this._moduleMap = moduleMap;
@@ -150,6 +157,14 @@ class DependencyGraph extends EventEmitter {
150
157
  2) Check \`blockList\` in your metro.config.js and make sure it isn't excluding the file path.`
151
158
  );
152
159
  }
160
+ if (pnpapi && filename !== resolvedPath) {
161
+ let virtualPaths = this._virtualPathsByRealPath.get(resolvedPath);
162
+ if (!virtualPaths) {
163
+ virtualPaths = /* @__PURE__ */ new Set();
164
+ this._virtualPathsByRealPath.set(resolvedPath, virtualPaths);
165
+ }
166
+ virtualPaths.add(filename);
167
+ }
153
168
  return sha1;
154
169
  }
155
170
  getWatcher() {
@@ -157,6 +172,7 @@ class DependencyGraph extends EventEmitter {
157
172
  }
158
173
  end() {
159
174
  this._haste.end();
175
+ this._virtualPathsByRealPath.clear();
160
176
  }
161
177
  /** Given a search context, return a list of file paths matching the query. */
162
178
  matchFilesWithContext(from, context) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@granite-js/mpack",
3
- "version": "2.5.5",
3
+ "version": "2.5.6",
4
4
  "description": "A bundler for Granite apps",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",
@@ -92,8 +92,8 @@
92
92
  "@babel/traverse": "7.28.5",
93
93
  "@babel/types": "7.28.5",
94
94
  "@fastify/middie": "8.3.0",
95
- "@granite-js/plugin-core": "2.5.5",
96
- "@granite-js/utils": "2.5.5",
95
+ "@granite-js/plugin-core": "2.5.6",
96
+ "@granite-js/utils": "2.5.6",
97
97
  "@react-native-community/cli-plugin-metro": "11.3.7",
98
98
  "@react-native-community/cli-server-api": "11.3.7",
99
99
  "@react-native-community/cli-tools": "11.3.7",