Skip to content
Merged
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 @@ -424,6 +424,49 @@ test('should add an inline source map to a very simple bundle', () => {
});
});

test('applies processModuleFilter to the inline source map', () => {
const bundle = baseJSBundle(
'/root/foo',
[polyfill],
{
dependencies: new Map([
['/root/foo', fooModule],
['/root/bar', barModule],
]),
entryPoints: new Set(['/root/foo']),
transformOptions,
},
{
asyncRequireModulePath: '',
createModuleId: createModuleIdFactory(),
dev: true,
getRunModuleStatement,
globalPrefix: '',
includeAsyncPaths: false,
inlineSourceMap: true,
modulesOnly: false,
processModuleFilter: module => module.path !== '/polyfill',
projectRoot: '/root',
runBeforeMainModule: [],
runModule: true,
serverRoot: '/root',
shouldAddToIgnoreList: () => false,
sourceMapUrl: null,
sourceUrl: null,
getSourceUrl: null,
},
);
// Without the polyfill, foo and bar are the first two lines of the bundle.
const base64 = bundle.post.slice(bundle.post.lastIndexOf('base64') + 7);
const map = JSON.parse(Buffer.from(base64, 'base64').toString());
expect(
map.sections.map(section => [section.offset.line, section.map.sources[0]]),
).toEqual([
[0, '/root/foo'],
[1, '/root/bar'],
]);
});

test('emits x_google_ignoreList based on shouldAddToIgnoreList', () => {
const bundle = baseJSBundle(
'/root/foo',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ export default function baseJSBundle(
getRunModuleStatement: options.getRunModuleStatement,
globalPrefix: options.globalPrefix,
inlineSourceMap: options.inlineSourceMap,
processModuleFilter: options.processModuleFilter,
runBeforeMainModule: options.runBeforeMainModule,
runModule: options.runModule,
shouldAddToIgnoreList: options.shouldAddToIgnoreList,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ export default function baseJSBundleWithLazyModuleDefinition(
getRunModuleStatement: options.getRunModuleStatement,
globalPrefix: options.globalPrefix,
inlineSourceMap: options.inlineSourceMap,
processModuleFilter: options.processModuleFilter,
runBeforeMainModule: options.runBeforeMainModule,
runModule: options.runModule,
shouldAddToIgnoreList: options.shouldAddToIgnoreList,
Expand Down
3 changes: 2 additions & 1 deletion packages/metro/src/lib/getAppendScripts.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ type Options<T extends number | string> = Readonly<{
getRunModuleStatement: (moduleId: T, globalPrefix: string) => string,
globalPrefix: string,
inlineSourceMap: ?boolean,
processModuleFilter: (module: Module<>) => boolean,
runBeforeMainModule: ReadonlyArray<string>,
runModule: boolean,
shouldAddToIgnoreList: (Module<>) => boolean,
Expand Down Expand Up @@ -73,7 +74,7 @@ export default function getAppendScripts<T extends number | string>(
const sourceMappingURL = options.inlineSourceMap
? getInlineSourceMappingURL(
sourceMapString(modules, {
processModuleFilter: (): boolean => true,
processModuleFilter: options.processModuleFilter,
excludeSource: false,
shouldAddToIgnoreList: options.shouldAddToIgnoreList,
getSourceUrl: options.getSourceUrl,
Expand Down
Loading