Skip to content
Closed
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 @@ -74,7 +74,7 @@ Object {
"type": "js/module",
},
Object {
"code": "__d(function() {foo2()},\\"/root/foo2.js\\",[],\\"foo2.js\\");",
"code": "__d(function() {foo2()},\\"/root/foo2.js\\",null,\\"foo2.js\\");",
"id": "/root/foo2.js",
"map": Object {
"sections": Array [
Expand Down Expand Up @@ -142,7 +142,7 @@ Object {
"type": "js/module",
},
Object {
"code": "__d(function() {baz()},\\"/root/baz.js\\",[],\\"baz.js\\");",
"code": "__d(function() {baz()},\\"/root/baz.js\\",null,\\"baz.js\\");",
"id": "/root/baz.js",
"map": Object {
"sections": Array [
Expand Down Expand Up @@ -176,7 +176,7 @@ Object {
"type": "js/module/asset",
},
Object {
"code": "__d(function() {bar()},\\"/root/bar.js\\",[],\\"bar.js\\");",
"code": "__d(function() {bar()},\\"/root/bar.js\\",null,\\"bar.js\\");",
"id": "/root/bar.js",
"map": Object {
"sections": Array [
Expand Down Expand Up @@ -210,7 +210,7 @@ Object {
"type": "js/module",
},
Object {
"code": "__d(function() {qux()},\\"/root/qux.js\\",[],\\"qux.js\\");",
"code": "__d(function() {qux()},\\"/root/qux.js\\",null,\\"qux.js\\");",
"id": "/root/qux.js",
"map": Object {
"sections": Array [
Expand Down Expand Up @@ -419,7 +419,7 @@ Object {
"type": "js/module",
},
Object {
"code": "__d(function() {foo2()},\\"/root/foo2.js\\",[],\\"foo2.js\\");",
"code": "__d(function() {foo2()},\\"/root/foo2.js\\",null,\\"foo2.js\\");",
"id": "/root/foo2.js",
"map": Object {
"sections": Array [
Expand Down Expand Up @@ -481,7 +481,7 @@ Object {
"type": "js/module",
},
Object {
"code": "__d(function() {baz()},\\"/root/baz.js\\",[],\\"baz.js\\");",
"code": "__d(function() {baz()},\\"/root/baz.js\\",null,\\"baz.js\\");",
"id": "/root/baz.js",
"map": Object {
"sections": Array [
Expand Down Expand Up @@ -512,7 +512,7 @@ Object {
"type": "js/module/asset",
},
Object {
"code": "__d(function() {bar()},\\"/root/bar.js\\",[],\\"bar.js\\");",
"code": "__d(function() {bar()},\\"/root/bar.js\\",null,\\"bar.js\\");",
"id": "/root/bar.js",
"map": Object {
"sections": Array [
Expand Down Expand Up @@ -543,7 +543,7 @@ Object {
"type": "js/module",
},
Object {
"code": "__d(function() {qux()},\\"/root/qux.js\\",[],\\"qux.js\\");",
"code": "__d(function() {qux()},\\"/root/qux.js\\",null,\\"qux.js\\");",
"id": "/root/qux.js",
"map": Object {
"sections": Array [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ test('should generate a very simple bundle', () => {
],
Array [
"bar",
"__d(function() {/* code for bar */},\\"bar\\",[],\\"bar\\");",
"__d(function() {/* code for bar */},\\"bar\\",null,\\"bar\\");",
],
],
"post": "require(\\"foo\\");
Expand Down Expand Up @@ -215,7 +215,7 @@ Object {
"modules": Array [
Array [
"#.js",
"__d(function() {/* code for ascii file with non ascii characters: %30.бундл.Øಚ😁AA */},\\"#.js\\",[],\\"%30.бундл.Øಚ😁AA/src/?/foo=bar/#.js\\");",
"__d(function() {/* code for ascii file with non ascii characters: %30.бундл.Øಚ😁AA */},\\"#.js\\",null,\\"%30.бундл.Øಚ😁AA/src/?/foo=bar/#.js\\");",
],
],
"post": "//# sourceMappingURL=http://localhost/root/%2530.%D0%B1%D1%83%D0%BD%D0%B4%D0%BB.%C3%98%E0%B2%9A%F0%9F%98%81AA/src/%3F/foo%3Dbar/%23.map
Expand Down Expand Up @@ -307,7 +307,7 @@ test('should handle numeric module ids', () => {
],
Array [
1,
"__d(function() {/* code for bar */},1,[],\\"bar\\");",
"__d(function() {/* code for bar */},1,null,\\"bar\\");",
],
]
`);
Expand Down Expand Up @@ -540,7 +540,7 @@ test('does not add polyfills when `modulesOnly` is used', () => {
],
Array [
"bar",
"__d(function() {/* code for bar */},\\"bar\\",[],\\"bar\\");",
"__d(function() {/* code for bar */},\\"bar\\",null,\\"bar\\");",
],
],
"post": "require(\\"foo\\");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ Object {
Object {
"module": Array [
0,
"__d(function() {/* code for bar */},0,[],\\"bar\\",{});
"__d(function() {/* code for bar */},0,null,\\"bar\\",{});
//# sourceMappingURL=http://localhost/bar.map
//# sourceURL=http://localhost/bar.bundle
",
Expand Down Expand Up @@ -172,7 +172,7 @@ Object {
Object {
"module": Array [
2,
"__d(function() {/* code for ascii file with non ascii characters: %30.бундл.Øಚ😁AA */},2,[],\\"%30.бундл.Øಚ😁AA/src/?/foo=bar/#.js\\",{});
"__d(function() {/* code for ascii file with non ascii characters: %30.бундл.Øಚ😁AA */},2,null,\\"%30.бундл.Øಚ😁AA/src/?/foo=bar/#.js\\",{});
//# sourceMappingURL=http://localhost/%2530.%D0%B1%D1%83%D0%BD%D0%B4%D0%BB.%C3%98%E0%B2%9A%F0%9F%98%81AA/src/%3F/foo%3Dbar/%23.map
//# sourceURL=http://localhost/%2530.%D0%B1%D1%83%D0%BD%D0%B4%D0%BB.%C3%98%E0%B2%9A%F0%9F%98%81AA/src/%3F/foo%3Dbar/%23.bundle
",
Expand Down
29 changes: 19 additions & 10 deletions packages/metro/src/DeltaBundler/Serializers/helpers/js.js
Original file line number Diff line number Diff line change
Expand Up @@ -165,16 +165,25 @@ export function getModuleParams(
options,
);

const params = [
moduleId,
hasPaths
? {
// $FlowFixMe[not-an-object] Intentionally spreading an array into an object
...dependencyMapArray,
paths,
}
: dependencyMapArray,
];
const params: Array<unknown> = [moduleId];

// As an optimisation: we only emit an argument for the dependency map if
// it is non-empty. This is safe because either `dependencyMapReservedName`
// is set and we have enforced there are no string occurences of that name,
// or we have used `generateUid` to generate an unbound name for it.
if (hasPaths) {
params.push({
// $FlowFixMe[not-an-object] Intentionally spreading an array into an object
...dependencyMapArray,
paths,
});
} else if (dependencyMapArray.length > 0) {
params.push(dependencyMapArray);
} else if (options.dev) {
// In dev we have one more argument (below), so emit a null to preserve its
// position.
params.push(null);
}

if (options.dev) {
params.push(getModuleVerboseName(module, options));
Expand Down
10 changes: 5 additions & 5 deletions packages/metro/src/Server/__tests__/Server-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -346,7 +346,7 @@ describe('processRequest', () => {
[
'function () {require();}',
'__d(function() {entry();},0,[1],"mybundle.js");',
'__d(function() {foo();},1,[],"foo.js");',
'__d(function() {foo();},1,null,"foo.js");',
'require(0);',
'//# sourceMappingURL=http://localhost:8081/mybundle.map?runModule=true',
'//# sourceURL=http://localhost:8081/mybundle.bundle//&runModule=true',
Expand All @@ -362,7 +362,7 @@ describe('processRequest', () => {
[
'function () {require();}',
'__d(function() {entry();},0,[1],"mybundle.js");',
'__d(function() {foo();},1,[],"foo.js");',
'__d(function() {foo();},1,null,"foo.js");',
'//# sourceMappingURL=http://localhost:8081/mybundle.map?runModule=false',
'//# sourceURL=http://localhost:8081/mybundle.bundle//&runModule=false',
].join('\n'),
Expand Down Expand Up @@ -472,7 +472,7 @@ describe('processRequest', () => {
expect(response._getString()).toEqual(
[
'__d(function() {entry();},0,[1],"mybundle.js");',
'__d(function() {foo();},1,[],"foo.js");',
'__d(function() {foo();},1,null,"foo.js");',
'//# sourceMappingURL=http://localhost:8081/mybundle.map?modulesOnly=true&runModule=false',
'//# sourceURL=http://localhost:8081/mybundle.bundle//&modulesOnly=true&runModule=false',
].join('\n'),
Expand All @@ -493,7 +493,7 @@ describe('processRequest', () => {
expect(response._getString()).toEqual(
[
'__d(function() {entry();},0,[1],"mybundle.js");',
'__d(function() {foo();},1,[],"foo.js");',
'__d(function() {foo();},1,null,"foo.js");',
'//# sourceMappingURL=https://forwardedhost.com/mybundle.map?modulesOnly=true&runModule=false&platform=vr',
'//# sourceURL=https://forwardedhost.com/mybundle.bundle//&modulesOnly=true&runModule=false&platform=vr',
].join('\n'),
Expand Down Expand Up @@ -842,7 +842,7 @@ describe('processRequest', () => {
[
'function () {require();}',
'__d(function() {entry();},0,[1],"mybundle.js");',
'__d(function() {foo();},1,[],"foo.js");',
'__d(function() {foo();},1,null,"foo.js");',
'require(0);',
'//# sourceMappingURL=http://localhost:8081/mybundle.map?runModule=true&TEST_URL_WAS_REWRITTEN=true',
'//# sourceURL=http://localhost:8081/mybundle.bundle//&runModule=true&TEST_URL_WAS_REWRITTEN=true',
Expand Down
6 changes: 3 additions & 3 deletions packages/metro/src/__tests__/HmrServer-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -388,7 +388,7 @@ describe('HmrServer', () => {
id('/root/hi'),
'__d(function() { alert("hi"); },' +
id('/root/hi') +
',[],"hi",{});\n' +
',null,"hi",{});\n' +
'//# sourceMappingURL=http://localhost/hi.map?platform=ios&dev=true&minify=false&modulesOnly=true&runModule=false&shallow=true\n' +
'//# sourceURL=http://localhost/hi.bundle//&platform=ios&dev=true&minify=false&modulesOnly=true&runModule=false&shallow=true\n',
],
Expand Down Expand Up @@ -472,7 +472,7 @@ describe('HmrServer', () => {
id('/root/hi'),
'__d(function() { alert("hi"); },' +
id('/root/hi') +
',[],"hi",{});\n' +
',null,"hi",{});\n' +
'//# sourceMappingURL=http://localhost/hi.map?platform=ios&dev=true&minify=false&modulesOnly=true&runModule=false&shallow=true\n' +
'//# sourceURL=http://localhost/hi.bundle//&platform=ios&dev=true&minify=false&modulesOnly=true&runModule=false&shallow=true\n',
],
Expand Down Expand Up @@ -531,7 +531,7 @@ describe('HmrServer', () => {
id('/root/hi'),
'__d(function() { alert("hi"); },' +
id('/root/hi') +
',[],"hi",{});\n' +
',null,"hi",{});\n' +
'//# sourceMappingURL=http://localhost/hi.map?platform=ios&dev=true&minify=false&modulesOnly=true&runModule=false&shallow=true\n' +
'//# sourceURL=http://localhost/hi.bundle//&platform=ios&dev=true&minify=false&modulesOnly=true&runModule=false&shallow=true\n',
],
Expand Down
2 changes: 1 addition & 1 deletion scripts/__tests__/api-snapshots-sync-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,4 @@ test('Public API snapshots are in sync (yarn run build-api-snapshots produces no
expect(error.errors).toEqual([]);
}
expect(error).toBeUndefined();
}, 120000);
}, 180000);
Loading