Pass the sourcemap variable correctly to the transformer

Reviewed By: Hypuk

Differential Revision: D7102063

fbshipit-source-id: b6162e6f9052099afec02a67e3ea44da2a6ea8be
This commit is contained in:
Rafael Oleza 2018-02-27 14:27:14 -08:00 committed by Facebook Github Bot
parent 019622ce50
commit 2b32b08b13
2 changed files with 21 additions and 9 deletions

View File

@ -135,10 +135,7 @@ async function _getAllModules(
lastModified: Date,
deltaTransformer: DeltaTransformer,
}> {
const hashedOptions = options;
delete hashedOptions.sourceMapUrl;
const clientId = '__SERVER__' + stableHash(hashedOptions).toString('hex');
const clientId = '__SERVER__' + stableHash(options).toString('hex');
const deltaPatcher = DeltaPatcher.get(clientId);

View File

@ -50,12 +50,12 @@ describe('Serializers', () => {
postProcessModules.mockImplementation(modules => modules);
deltaBundler = {
async getDeltaTransformer() {
return {
getDeltaTransformer: jest.fn().mockReturnValue(
Promise.resolve({
getDelta,
getDependenciesFn,
};
},
}),
),
getPostProcessModulesFn() {
return postProcessModules;
},
@ -101,7 +101,11 @@ describe('Serializers', () => {
});
it('should build the full JS bundle', async () => {
expect(await Serializers.fullBundle(deltaBundler, {})).toMatchSnapshot();
expect(
await Serializers.fullBundle(deltaBundler, {
sourceMapUrl: 'http://localhost:8081/myBundle.js',
}),
).toMatchSnapshot();
getDelta.mockReturnValueOnce(
Promise.resolve({
@ -121,6 +125,17 @@ describe('Serializers', () => {
).toMatchSnapshot();
});
it('should pass the sourcemapURL param to the transformer', async () => {
await Serializers.fullBundle(deltaBundler, {
sourceMapUrl: 'http://localhost:8081/myBundle.js',
});
expect(deltaBundler.getDeltaTransformer.mock.calls[0][1]).toEqual({
deltaBundleId: '1234',
sourceMapUrl: 'http://localhost:8081/myBundle.js',
});
});
// This test actually does not test the sourcemaps generation logic, which
// is already tested in the source-map file.
it('should build the full Source Maps', async () => {