Reviewed By: davidaurelio

Differential Revision: D5111297

fbshipit-source-id: bde11df412dd694edca78d6a61f4c69e5abba60a
This commit is contained in:
Christoph Pojer 2017-05-23 04:52:46 -07:00 коммит произвёл Facebook Github Bot
Родитель ab346dd1f9
Коммит 4f980eedbd
5 изменённых файлов: 3343 добавлений и 3011 удалений

Просмотреть файл

@ -5,6 +5,8 @@
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*
* @format
*/
'use strict';
@ -26,117 +28,128 @@ describe('Bundle', () => {
describe('source bundle', () => {
it('should create a bundle and get the source', () => {
return Promise.resolve().then(() => {
return addModule({
bundle,
code: 'transformed foo;',
sourceCode: 'source foo',
sourcePath: 'foo path',
return Promise.resolve()
.then(() => {
return addModule({
bundle,
code: 'transformed foo;',
sourceCode: 'source foo',
sourcePath: 'foo path',
});
})
.then(() => {
return addModule({
bundle,
code: 'transformed bar;',
sourceCode: 'source bar',
sourcePath: 'bar path',
});
})
.then(() => {
bundle.finalize({});
expect(bundle.getSource({dev: true})).toBe(
[
'transformed foo;',
'transformed bar;',
'\/\/# sourceMappingURL=test_url',
].join('\n'),
);
});
}).then(() => {
return addModule({
bundle,
code: 'transformed bar;',
sourceCode: 'source bar',
sourcePath: 'bar path',
});
}).then(() => {
bundle.finalize({});
expect(bundle.getSource({dev: true})).toBe([
'transformed foo;',
'transformed bar;',
'\/\/# sourceMappingURL=test_url',
].join('\n'));
});
});
it('should be ok to leave out the source map url', () => {
const otherBundle = new Bundle();
return Promise.resolve().then(() => {
return addModule({
bundle: otherBundle,
code: 'transformed foo;',
sourceCode: 'source foo',
sourcePath: 'foo path',
return Promise.resolve()
.then(() => {
return addModule({
bundle: otherBundle,
code: 'transformed foo;',
sourceCode: 'source foo',
sourcePath: 'foo path',
});
})
.then(() => {
return addModule({
bundle: otherBundle,
code: 'transformed bar;',
sourceCode: 'source bar',
sourcePath: 'bar path',
});
})
.then(() => {
otherBundle.finalize({});
expect(otherBundle.getSource({dev: true})).toBe(
['transformed foo;', 'transformed bar;'].join('\n'),
);
});
}).then(() => {
return addModule({
bundle: otherBundle,
code: 'transformed bar;',
sourceCode: 'source bar',
sourcePath: 'bar path',
});
}).then(() => {
otherBundle.finalize({});
expect(otherBundle.getSource({dev: true})).toBe([
'transformed foo;',
'transformed bar;',
].join('\n'));
});
});
it('should create a bundle and add run module code', () => {
return Promise.resolve().then(() => {
return addModule({
bundle,
code: 'transformed foo;',
sourceCode: 'source foo',
sourcePath: 'foo path',
return Promise.resolve()
.then(() => {
return addModule({
bundle,
code: 'transformed foo;',
sourceCode: 'source foo',
sourcePath: 'foo path',
});
})
.then(() => {
return addModule({
bundle,
code: 'transformed bar;',
sourceCode: 'source bar',
sourcePath: 'bar path',
});
})
.then(() => {
bundle.setMainModuleId('foo');
bundle.finalize({
runBeforeMainModule: ['bar'],
runModule: true,
});
expect(bundle.getSource({dev: true})).toBe(
[
'transformed foo;',
'transformed bar;',
';require("bar");',
';require("foo");',
'\/\/# sourceMappingURL=test_url',
].join('\n'),
);
});
}).then(() => {
return addModule({
bundle,
code: 'transformed bar;',
sourceCode: 'source bar',
sourcePath: 'bar path',
});
}).then(() => {
bundle.setMainModuleId('foo');
bundle.finalize({
runBeforeMainModule: ['bar'],
runModule: true,
});
expect(bundle.getSource({dev: true})).toBe([
'transformed foo;',
'transformed bar;',
';require("bar");',
';require("foo");',
'\/\/# sourceMappingURL=test_url',
].join('\n'));
});
});
it('inserts modules in a deterministic order, independent of timing of the wrapper process',
() => {
const moduleTransports = [
createModuleTransport({name: 'module1'}),
createModuleTransport({name: 'module2'}),
createModuleTransport({name: 'module3'}),
];
it('inserts modules in a deterministic order, independent of timing of the wrapper process', () => {
const moduleTransports = [
createModuleTransport({name: 'module1'}),
createModuleTransport({name: 'module2'}),
createModuleTransport({name: 'module3'}),
];
const resolves = {};
const resolver = {
wrapModule({name}) {
return new Promise(resolve => {
resolves[name] = resolve;
});
},
};
const resolves = {};
const resolver = {
wrapModule({name}) {
return new Promise(resolve => {
resolves[name] = resolve;
});
},
};
const promise = Promise.all(moduleTransports.map(
m => bundle.addModule(resolver, null, {isPolyfill: () => false}, m)
)).then(() => {
expect(bundle.getModules())
.toEqual(moduleTransports);
});
const promise = Promise.all(
moduleTransports.map(m =>
bundle.addModule(resolver, null, {isPolyfill: () => false}, m),
),
).then(() => {
expect(bundle.getModules()).toEqual(moduleTransports);
});
resolves.module2({code: ''});
resolves.module3({code: ''});
resolves.module1({code: ''});
resolves.module2({code: ''});
resolves.module3({code: ''});
resolves.module1({code: ''});
return promise;
},
);
return promise;
});
});
describe('sourcemap bundle', () => {
@ -147,89 +160,93 @@ describe('Bundle', () => {
it('should combine sourcemaps', () => {
const otherBundle = new Bundle({sourceMapUrl: 'test_url'});
return Promise.resolve().then(() => {
return addModule({
bundle: otherBundle,
code: 'transformed foo;\n',
sourceCode: 'source foo',
map: {name: 'sourcemap foo'},
sourcePath: 'foo path',
});
}).then(() => {
return addModule({
bundle: otherBundle,
code: 'transformed bar;\n',
sourceCode: 'source bar',
map: {name: 'sourcemap bar'},
sourcePath: 'bar path',
});
}).then(() => {
return addModule({
bundle: otherBundle,
code: 'image module;\nimage module;',
virtual: true,
sourceCode: 'image module;\nimage module;',
sourcePath: 'image.png',
});
}).then(() => {
otherBundle.setMainModuleId('foo');
otherBundle.finalize({
runBeforeMainModule: ['InitializeCore'],
runModule: true,
});
return Promise.resolve()
.then(() => {
return addModule({
bundle: otherBundle,
code: 'transformed foo;\n',
sourceCode: 'source foo',
map: {name: 'sourcemap foo'},
sourcePath: 'foo path',
});
})
.then(() => {
return addModule({
bundle: otherBundle,
code: 'transformed bar;\n',
sourceCode: 'source bar',
map: {name: 'sourcemap bar'},
sourcePath: 'bar path',
});
})
.then(() => {
return addModule({
bundle: otherBundle,
code: 'image module;\nimage module;',
virtual: true,
sourceCode: 'image module;\nimage module;',
sourcePath: 'image.png',
});
})
.then(() => {
otherBundle.setMainModuleId('foo');
otherBundle.finalize({
runBeforeMainModule: ['InitializeCore'],
runModule: true,
});
const sourceMap = otherBundle.getSourceMap({dev: true});
expect(sourceMap).toEqual({
file: 'test_url',
version: 3,
sections: [
{offset: {line: 0, column: 0}, map: {name: 'sourcemap foo'}},
{offset: {line: 2, column: 0}, map: {name: 'sourcemap bar'}},
{
offset: {
column: 0,
line: 4,
const sourceMap = otherBundle.getSourceMap({dev: true});
expect(sourceMap).toEqual({
file: 'test_url',
version: 3,
sections: [
{offset: {line: 0, column: 0}, map: {name: 'sourcemap foo'}},
{offset: {line: 2, column: 0}, map: {name: 'sourcemap bar'}},
{
offset: {
column: 0,
line: 4,
},
map: {
file: 'image.png',
mappings: 'AAAA;AACA;',
names: [],
sources: ['image.png'],
sourcesContent: ['image module;\nimage module;'],
version: 3,
},
},
map: {
file: 'image.png',
mappings: 'AAAA;AACA;',
names: [],
sources: ['image.png'],
sourcesContent: ['image module;\nimage module;'],
version: 3,
{
offset: {
column: 0,
line: 6,
},
map: {
file: 'require-InitializeCore.js',
mappings: 'AAAA;',
names: [],
sources: ['require-InitializeCore.js'],
sourcesContent: [';require("InitializeCore");'],
version: 3,
},
},
},
{
offset: {
column: 0,
line: 6,
{
offset: {
column: 0,
line: 7,
},
map: {
file: 'require-foo.js',
mappings: 'AAAA;',
names: [],
sources: ['require-foo.js'],
sourcesContent: [';require("foo");'],
version: 3,
},
},
map: {
file: 'require-InitializeCore.js',
mappings: 'AAAA;',
names: [],
sources: ['require-InitializeCore.js'],
sourcesContent: [';require("InitializeCore");'],
version: 3,
},
},
{
offset: {
column: 0,
line: 7,
},
map: {
file: 'require-foo.js',
mappings: 'AAAA;',
names: [],
sources: ['require-foo.js'],
sourcesContent: [';require("foo");'],
version: 3,
},
},
],
],
});
});
});
});
});
@ -248,31 +265,37 @@ describe('Bundle', () => {
describe('getJSModulePaths()', () => {
it('should return module paths', () => {
var otherBundle = new Bundle({sourceMapUrl: 'test_url'});
return Promise.resolve().then(() => {
return addModule({
bundle: otherBundle,
code: 'transformed foo;\n',
sourceCode: 'source foo',
sourcePath: 'foo path',
return Promise.resolve()
.then(() => {
return addModule({
bundle: otherBundle,
code: 'transformed foo;\n',
sourceCode: 'source foo',
sourcePath: 'foo path',
});
})
.then(() => {
return addModule({
bundle: otherBundle,
code: 'image module;\nimage module;',
virtual: true,
sourceCode: 'image module;\nimage module;',
sourcePath: 'image.png',
});
})
.then(() => {
expect(otherBundle.getJSModulePaths()).toEqual(['foo path']);
});
}).then(() => {
return addModule({
bundle: otherBundle,
code: 'image module;\nimage module;',
virtual: true,
sourceCode: 'image module;\nimage module;',
sourcePath: 'image.png',
});
}).then(() => {
expect(otherBundle.getJSModulePaths()).toEqual(['foo path']);
});
});
});
describe('getEtag()', function() {
it('should return an etag', function() {
bundle.finalize({});
var eTag = crypto.createHash('md5').update(bundle.getSource()).digest('hex');
var eTag = crypto
.createHash('md5')
.update(bundle.getSource())
.digest('hex');
expect(bundle.getEtag()).toEqual(eTag);
});
});
@ -305,51 +328,86 @@ describe('Bundle', () => {
it('can create a single group', () => {
bundle = createBundle([fsLocation('React')]);
const {groups} = bundle.getUnbundle();
expect(groups).toEqual(new Map([
[idFor('React'), new Set(['ReactFoo', 'invariant', 'ReactBar', 'cx'].map(idFor))],
]));
expect(groups).toEqual(
new Map([
[
idFor('React'),
new Set(['ReactFoo', 'invariant', 'ReactBar', 'cx'].map(idFor)),
],
]),
);
});
it('can create two groups', () => {
bundle = createBundle([fsLocation('ReactFoo'), fsLocation('ReactBar')]);
const {groups} = bundle.getUnbundle();
expect(groups).toEqual(new Map([
[idFor('ReactFoo'), new Set([idFor('invariant')])],
[idFor('ReactBar'), new Set([idFor('cx')])],
]));
expect(groups).toEqual(
new Map([
[idFor('ReactFoo'), new Set([idFor('invariant')])],
[idFor('ReactBar'), new Set([idFor('cx')])],
]),
);
});
it('can handle circular dependencies', () => {
bundle = createBundle([fsLocation('OtherFramework')]);
const {groups} = bundle.getUnbundle();
expect(groups).toEqual(new Map([[
idFor('OtherFramework'),
new Set(['OtherFrameworkFoo', 'invariant', 'OtherFrameworkBar', 'crc32'].map(idFor)),
]]));
expect(groups).toEqual(
new Map([
[
idFor('OtherFramework'),
new Set(
[
'OtherFrameworkFoo',
'invariant',
'OtherFrameworkBar',
'crc32',
].map(idFor),
),
],
]),
);
});
it('omits modules that are contained by more than one group', () => {
bundle = createBundle([fsLocation('React'), fsLocation('OtherFramework')]);
bundle = createBundle([
fsLocation('React'),
fsLocation('OtherFramework'),
]);
expect(() => {
const {groups} = bundle.getUnbundle(); //eslint-disable-line no-unused-vars
}).toThrow(new Error(`Module ${fsLocation('invariant')} belongs to groups ${fsLocation('React')}` +
`, and ${fsLocation('OtherFramework')}. Removing it from all groups.`));
}).toThrow(
new Error(
`Module ${fsLocation('invariant')} belongs to groups ${fsLocation('React')}` +
`, and ${fsLocation('OtherFramework')}. Removing it from all groups.`,
),
);
});
it('ignores missing dependencies', () => {
bundle = createBundle([fsLocation('Product1')]);
const {groups} = bundle.getUnbundle();
expect(groups).toEqual(new Map([[
idFor('Product1'),
new Set(['React', 'ReactFoo', 'invariant', 'ReactBar', 'cx'].map(idFor)),
]]));
expect(groups).toEqual(
new Map([
[
idFor('Product1'),
new Set(
['React', 'ReactFoo', 'invariant', 'ReactBar', 'cx'].map(idFor),
),
],
]),
);
});
it('throws for group roots that do not exist', () => {
bundle = createBundle([fsLocation('DoesNotExist')]);
expect(() => {
const {groups} = bundle.getUnbundle(); //eslint-disable-line no-unused-vars
}).toThrow(new Error(`Group root ${fsLocation('DoesNotExist')} is not part of the bundle`));
}).toThrow(
new Error(
`Group root ${fsLocation('DoesNotExist')} is not part of the bundle`,
),
);
});
function idFor(name) {
@ -397,7 +455,17 @@ function resolverFor(code, map) {
};
}
function addModule({bundle, code, sourceCode, sourcePath, map, virtual, polyfill, meta, id = ''}) {
function addModule({
bundle,
code,
sourceCode,
sourcePath,
map,
virtual,
polyfill,
meta,
id = '',
}) {
return bundle.addModule(
resolverFor(code, map),
null,

Просмотреть файл

@ -5,6 +5,8 @@
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*
* @format
*/
'use strict';
@ -46,10 +48,12 @@ describe('transforming JS modules:', () => {
it('passes through file name and code', done => {
transformModule(sourceCode, options(), (error, result) => {
expect(result.type).toBe('code');
expect(result.details).toEqual(expect.objectContaining({
code: sourceCode,
file: filename,
}));
expect(result.details).toEqual(
expect.objectContaining({
code: sourceCode,
file: filename,
}),
);
done();
});
});
@ -73,11 +77,17 @@ describe('transforming JS modules:', () => {
});
it('sets `type` to `"script"` if the input is a polyfill', done => {
transformModule(sourceCode, {...options(), polyfill: true}, (error, result) => {
expect(result.type).toBe('code');
expect(result.details).toEqual(expect.objectContaining({type: 'script'}));
done();
});
transformModule(
sourceCode,
{...options(), polyfill: true},
(error, result) => {
expect(result.type).toBe('code');
expect(result.details).toEqual(
expect.objectContaining({type: 'script'}),
);
done();
},
);
});
const defaults = {
@ -89,24 +99,25 @@ describe('transforming JS modules:', () => {
projectRoot: '',
};
it('calls the passed-in transform function with code, file name, and options ' +
'for all passed in variants',
it(
'calls the passed-in transform function with code, file name, and options ' +
'for all passed in variants',
done => {
const variants = {dev: {dev: true}, prod: {dev: false}};
transformModule(sourceCode, options(variants), () => {
expect(transformer.transform).toBeCalledWith({
filename,
localPath: filename,
options: {...defaults, ...variants.dev},
src: sourceCode,
});
filename,
localPath: filename,
options: {...defaults, ...variants.dev},
src: sourceCode,
});
expect(transformer.transform).toBeCalledWith({
filename,
localPath: filename,
options: {...defaults, ...variants.prod},
src: sourceCode,
});
filename,
localPath: filename,
options: {...defaults, ...variants.prod},
src: sourceCode,
});
done();
});
},
@ -127,24 +138,27 @@ describe('transforming JS modules:', () => {
expect(error).toEqual(null);
const {code, dependencyMapName} = result.details.transformed.default;
expect(code.replace(/\s+/g, ''))
.toEqual(
`__d(function(global,require,module,exports,${
dependencyMapName}){${transformedCode}});`
);
expect(code.replace(/\s+/g, '')).toEqual(
`__d(function(global,require,module,exports,${dependencyMapName}){${transformedCode}});`,
);
done();
});
});
it('wraps the code produced by the transform function into an IIFE for polyfills', done => {
transformModule(sourceCode, {...options(), polyfill: true}, (error, result) => {
expect(error).toEqual(null);
transformModule(
sourceCode,
{...options(), polyfill: true},
(error, result) => {
expect(error).toEqual(null);
const {code} = result.details.transformed.default;
expect(code.replace(/\s+/g, ''))
.toEqual(`(function(global){${transformedCode}})(this);`);
done();
});
const {code} = result.details.transformed.default;
expect(code.replace(/\s+/g, '')).toEqual(
`(function(global){${transformedCode}})(this);`,
);
done();
},
);
});
it('creates source maps', done => {
@ -152,8 +166,9 @@ describe('transforming JS modules:', () => {
const {code, map} = result.details.transformed.default;
const column = code.indexOf('code');
const consumer = new SourceMapConsumer(map);
expect(consumer.originalPositionFor({line: 1, column}))
.toEqual(expect.objectContaining({line: 1, column: sourceCode.indexOf('code')}));
expect(consumer.originalPositionFor({line: 1, column})).toEqual(
expect.objectContaining({line: 1, column: sourceCode.indexOf('code')}),
);
done();
});
});
@ -166,8 +181,9 @@ describe('transforming JS modules:', () => {
transformer.transform.stub.returns(transformResult(body));
transformModule(code, options(), (error, result) => {
expect(result.details.transformed.default)
.toEqual(expect.objectContaining({dependencies: [dep1, dep2]}));
expect(result.details.transformed.default).toEqual(
expect.objectContaining({dependencies: [dep1, dep2]}),
);
done();
});
});
@ -176,22 +192,18 @@ describe('transforming JS modules:', () => {
const variants = {dev: {dev: true}, prod: {dev: false}};
transformer.transform.stub
.withArgs(filename, sourceCode, variants.dev)
.returns(transformResult(bodyAst))
.returns(transformResult(bodyAst))
.withArgs(filename, sourceCode, variants.prod)
.returns(transformResult([]));
.returns(transformResult([]));
transformModule(sourceCode, options(variants), (error, result) => {
const {dev, prod} = result.details.transformed;
expect(dev.code.replace(/\s+/g, ''))
.toEqual(
`__d(function(global,require,module,exports,${
dev.dependencyMapName}){arbitrary(code);});`
);
expect(prod.code.replace(/\s+/g, ''))
.toEqual(
`__d(function(global,require,module,exports,${
prod.dependencyMapName}){arbitrary(code);});`
);
expect(dev.code.replace(/\s+/g, '')).toEqual(
`__d(function(global,require,module,exports,${dev.dependencyMapName}){arbitrary(code);});`,
);
expect(prod.code.replace(/\s+/g, '')).toEqual(
`__d(function(global,require,module,exports,${prod.dependencyMapName}){arbitrary(code);});`,
);
done();
});
});
@ -199,23 +211,31 @@ describe('transforming JS modules:', () => {
it('prefixes JSON files with `module.exports = `', done => {
const json = '{"foo":"bar"}';
transformModule(json, {...options(), filename: 'some.json'}, (error, result) => {
const {code} = result.details.transformed.default;
expect(code.replace(/\s+/g, ''))
.toEqual(
transformModule(
json,
{...options(), filename: 'some.json'},
(error, result) => {
const {code} = result.details.transformed.default;
expect(code.replace(/\s+/g, '')).toEqual(
'__d(function(global,require,module,exports){' +
`module.exports=${json}});`
`module.exports=${json}});`,
);
done();
});
done();
},
);
});
it('does not create source maps for JSON files', done => {
transformModule('{}', {...options(), filename: 'some.json'}, (error, result) => {
expect(result.details.transformed.default)
.toEqual(expect.objectContaining({map: null}));
done();
});
transformModule(
'{}',
{...options(), filename: 'some.json'},
(error, result) => {
expect(result.details.transformed.default).toEqual(
expect.objectContaining({map: null}),
);
done();
},
);
});
it('adds package data for `package.json` files', done => {

Просмотреть файл

@ -7,6 +7,7 @@
* of patent rights can be found in the PATENTS file in the same directory.
*
* @flow
* @format
*/
'use strict';
@ -70,12 +71,13 @@ function transformModule(
const {filename, transformer, variants = defaultVariants} = options;
const tasks = {};
Object.keys(variants).forEach(name => {
tasks[name] = asyncify(() => transformer.transform({
tasks[name] = asyncify(() =>
transformer.transform({
filename,
localPath: filename,
options: {...defaultTransformOptions, ...variants[name]},
src: code,
})
}),
);
});
@ -89,7 +91,12 @@ function transformModule(
//$FlowIssue #14545724
Object.entries(results).forEach(([key, value]: [*, TransformFnResult]) => {
transformed[key] = makeResult(value.ast, filename, code, options.polyfill);
transformed[key] = makeResult(
value.ast,
filename,
code,
options.polyfill,
);
});
const annotations = docblock.parseAsObject(docblock.extract(code));
@ -112,10 +119,7 @@ function transformModule(
function transformJSON(json, options, callback) {
const value = JSON.parse(json);
const {filename} = options;
const code =
`__d(function(${JsFileWrapping.MODULE_FACTORY_PARAMETERS.join(', ')}) { module.exports = \n${
json
}\n});`;
const code = `__d(function(${JsFileWrapping.MODULE_FACTORY_PARAMETERS.join(', ')}) { module.exports = \n${json}\n});`;
const moduleData = {
code,
@ -124,9 +128,9 @@ function transformJSON(json, options, callback) {
};
const transformed = {};
Object
.keys(options.variants || defaultVariants)
.forEach(key => (transformed[key] = moduleData));
Object.keys(options.variants || defaultVariants).forEach(
key => (transformed[key] = moduleData),
);
const result: TransformedCodeFile = {
assetContent: null,

Просмотреть файл

@ -5,6 +5,8 @@
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*
* @format
*/
'use strict';
@ -35,16 +37,15 @@ it('symbolicates stack frames', () => {
];
const stack = mappings.map(m => m.to);
const maps =
Object.entries(groupBy(mappings, m => m.from.file))
.map(([file, ms]) => [file, sourceMap(file, ms)]);
const maps = Object.entries(
groupBy(mappings, m => m.from.file),
).map(([file, ms]) => [file, sourceMap(file, ms)]);
return symbolicate(connection, makeData(stack, maps))
.then(() =>
expect(connection.end).toBeCalledWith(
JSON.stringify({result: mappings.map(m => m.to)})
)
);
return symbolicate(connection, makeData(stack, maps)).then(() =>
expect(connection.end).toBeCalledWith(
JSON.stringify({result: mappings.map(m => m.to)}),
),
);
});
it('ignores stack frames without corresponding map', () => {
@ -54,12 +55,12 @@ it('ignores stack frames without corresponding map', () => {
column: 456,
};
return symbolicate(connection, makeData([frame], [['other.js', emptyMap()]]))
.then(() =>
expect(connection.end).toBeCalledWith(
JSON.stringify({result: [frame]})
)
);
return symbolicate(
connection,
makeData([frame], [['other.js', emptyMap()]]),
).then(() =>
expect(connection.end).toBeCalledWith(JSON.stringify({result: [frame]})),
);
});
it('ignores `/debuggerWorker.js` stack frames', () => {
@ -69,12 +70,9 @@ it('ignores `/debuggerWorker.js` stack frames', () => {
column: 456,
};
return symbolicate(connection, makeData([frame]))
.then(() =>
expect(connection.end).toBeCalledWith(
JSON.stringify({result: [frame]})
)
);
return symbolicate(connection, makeData([frame])).then(() =>
expect(connection.end).toBeCalledWith(JSON.stringify({result: [frame]})),
);
});
function makeData(stack, maps = []) {
@ -85,7 +83,8 @@ function sourceMap(file, mappings) {
const g = new SourceMapGenerator();
g.startFile(file, null);
mappings.forEach(({from, to}) =>
g.addSourceMapping(to.lineNumber, to.column, from.lineNumber, from.column));
g.addSourceMapping(to.lineNumber, to.column, from.lineNumber, from.column),
);
return g.toMap();
}

Разница между файлами не показана из-за своего большого размера Загрузить разницу