Skip to content

Commit de698d2

Browse files
motiz88facebook-github-bot
authored andcommitted
Fix _getEntryPointAbsolutePath conflating disk paths with URL pathnames (#1708)
Summary: D102004228 added `[metro-project]`/`[metro-watchFolders]` virtual URL pathname resolution to `_getEntryPointAbsolutePath`, but this method doesn't take URL pathnames - it takes actual filesystem paths (ultimately from Metro's API / CLI). The fix removes virtual prefix resolution from `_getEntryPointAbsolutePath`, making it a plain `path.resolve(serverRootDir, entryFile)` call, consistent with `buildGraph` which already treats the entry file as a plain disk path. Changelog: * **[Fix]:** Remove erroneous `[metro-project]` and `[metro-watchFolders]` resolution from API and CLI Reviewed By: huntie Differential Revision: D104415558
1 parent 99ed38b commit de698d2

2 files changed

Lines changed: 10 additions & 17 deletions

File tree

packages/metro/src/Server.js

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1690,10 +1690,7 @@ export default class Server {
16901690
};
16911691

16921692
_getEntryPointAbsolutePath(entryFile: string): string {
1693-
return (
1694-
this._routeMap.filePathOfUrlDecodedPathname(entryFile) ??
1695-
path.resolve(this._routeMap.serverRootDir, entryFile)
1696-
);
1693+
return path.resolve(this._routeMap.serverRootDir, entryFile);
16971694
}
16981695

16991696
// Wait for the server to finish initializing.

packages/metro/src/integration_tests/__tests__/build-test.js

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -118,21 +118,17 @@ test('allows specifying paths to save bundle and maps', async () => {
118118
);
119119
});
120120

121-
// $FlowFixMe[prop-missing] - test.failing is not in Flow's Jest types
122-
test.failing(
123-
'builds a bundle from a file in a directory literally named [metro-project]',
124-
async () => {
125-
const config = await Metro.loadConfig({
126-
config: require.resolve('../metro.config.js'),
127-
});
121+
test('builds a bundle from a file in a directory literally named [metro-project]', async () => {
122+
const config = await Metro.loadConfig({
123+
config: require.resolve('../metro.config.js'),
124+
});
128125

129-
const result = await Metro.runBuild(config, {
130-
entry: './[metro-project]/LiteralDir.js',
131-
});
126+
const result = await Metro.runBuild(config, {
127+
entry: './[metro-project]/LiteralDir.js',
128+
});
132129

133-
expect(execBundle(result.code)).toBe('from-literal-dir');
134-
},
135-
);
130+
expect(execBundle(result.code)).toBe('from-literal-dir');
131+
});
136132

137133
// $FlowFixMe[prop-missing] - test.failing is not in Flow's Jest types
138134
test.failing(

0 commit comments

Comments
 (0)