Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,52 @@ test('should return the RAM bundle info', async () => {
).toMatchSnapshot();
});

test('passes a working transitive-dependency lookup to getTransformOptions', async () => {
let resolvedDeps: ?Array<string>;
await getRamBundleInfo(
'/root/entry.js',
pre,
{...graph, entryPoints: new Set(['/root/entry.js'])},
{
asyncRequireModulePath: '',
// $FlowFixMe[incompatible-type] createModuleId assumes numeric IDs - is this too strict?
createModuleId: path => path,
dev: true,
excludeSource: false,
getRunModuleStatement,
getTransformOptions: async (entryPoints, opts, getDependenciesOf) => {
resolvedDeps = await getDependenciesOf('/root/foo.js');
return {preloadedModules: {}, ramGroups: []};
},
globalPrefix: '',
includeAsyncPaths: false,
inlineSourceMap: false,
modulesOnly: false,
platform: null,
processModuleFilter: module => true,
projectRoot: '/root',
runBeforeMainModule: [],
runModule: true,
serverRoot: '/root',
shouldAddToIgnoreList: () => false,
sourceMapUrl: 'http://localhost/bundle.map',
sourceUrl: null,
getSourceUrl: null,
},
);
// foo depends on bar, baz, qux — the callback must return those, not [undefined].
if (resolvedDeps == null) {
throw new Error(
'getTransformOptions was not called with a dependency lookup',
);
}
expect([...resolvedDeps].sort()).toEqual([
'/root/bar.js',
'/root/baz.js',
'/root/qux.js',
]);
});

test('emits x_google_ignoreList based on shouldAddToIgnoreList', async () => {
expect(
await getRamBundleInfo(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -157,10 +157,7 @@ async function _getRamOptions(
const {preloadedModules, ramGroups} = await getTransformOptions(
[entryFile],
{dev: options.dev, hot: true, platform: options.platform},
/* $FlowFixMe[incompatible-type](>=0.99.0 site=react_native_fb) This comment suppresses an
* error found when Flow v0.99 was deployed. To see the error, delete this
* comment and run Flow. */
async (x: string) => Array.from(getDependencies),
async (x: string) => Array.from(getDependencies(x)),
);

return {
Expand Down
Loading