Skip to content

Commit

Permalink
chunk names now hash contents instead of path
Browse files Browse the repository at this point in the history
  • Loading branch information
evanw committed Jul 29, 2020
1 parent 5c5c8d0 commit a94f94f
Show file tree
Hide file tree
Showing 3 changed files with 127 additions and 85 deletions.
66 changes: 33 additions & 33 deletions internal/bundler/bundler_splitting_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,19 +29,19 @@ func TestSplittingSharedES6IntoES6(t *testing.T) {
expected: map[string]string{
"/out/a.js": `import {
foo
} from "./chunk.xL6KqlYO.js";
} from "./chunk.iJkFSV6U.js";
// /a.js
console.log(foo);
`,
"/out/b.js": `import {
foo
} from "./chunk.xL6KqlYO.js";
} from "./chunk.iJkFSV6U.js";
// /b.js
console.log(foo);
`,
"/out/chunk.xL6KqlYO.js": `// /shared.js
"/out/chunk.iJkFSV6U.js": `// /shared.js
let foo = 123;
export {
Expand Down Expand Up @@ -75,21 +75,21 @@ func TestSplittingSharedCommonJSIntoES6(t *testing.T) {
expected: map[string]string{
"/out/a.js": `import {
require_shared
} from "./chunk.xL6KqlYO.js";
} from "./chunk.W46Rb0pk.js";
// /a.js
const {foo} = require_shared();
console.log(foo);
`,
"/out/b.js": `import {
require_shared
} from "./chunk.xL6KqlYO.js";
} from "./chunk.W46Rb0pk.js";
// /b.js
const {foo: foo2} = require_shared();
console.log(foo2);
`,
"/out/chunk.xL6KqlYO.js": `// /shared.js
"/out/chunk.W46Rb0pk.js": `// /shared.js
var require_shared = __commonJS((exports) => {
exports.foo = 123;
});
Expand Down Expand Up @@ -185,21 +185,21 @@ func TestSplittingDynamicAndNotDynamicES6IntoES6(t *testing.T) {
expected: map[string]string{
"/out/entry.js": `import {
bar
} from "./chunk.-fk8OGuR.js";
} from "./chunk.nvw10ONy.js";
// /entry.js
import("./foo.js").then(({bar: b}) => console.log(bar, b));
`,
"/out/foo.js": `import {
bar
} from "./chunk.-fk8OGuR.js";
} from "./chunk.nvw10ONy.js";
// /foo.js
export {
bar
};
`,
"/out/chunk.-fk8OGuR.js": `// /foo.js
"/out/chunk.nvw10ONy.js": `// /foo.js
let bar = 123;
export {
Expand Down Expand Up @@ -231,20 +231,20 @@ func TestSplittingDynamicAndNotDynamicCommonJSIntoES6(t *testing.T) {
expected: map[string]string{
"/out/entry.js": `import {
require_foo
} from "./chunk.-fk8OGuR.js";
} from "./chunk.K9Rnzqz2.js";
// /entry.js
const foo = __toModule(require_foo());
import("./foo.js").then(({default: {bar: b}}) => console.log(foo.bar, b));
`,
"/out/foo.js": `import {
require_foo
} from "./chunk.-fk8OGuR.js";
} from "./chunk.K9Rnzqz2.js";
// /foo.js
export default require_foo();
`,
"/out/chunk.-fk8OGuR.js": `// /foo.js
"/out/chunk.K9Rnzqz2.js": `// /foo.js
var require_foo = __commonJS((exports) => {
exports.bar = 123;
});
Expand Down Expand Up @@ -287,20 +287,20 @@ func TestSplittingAssignToLocal(t *testing.T) {
"/out/a.js": `import {
foo,
setFoo
} from "./chunk.xL6KqlYO.js";
} from "./chunk.8-s4RjmR.js";
// /a.js
setFoo(123);
console.log(foo);
`,
"/out/b.js": `import {
foo
} from "./chunk.xL6KqlYO.js";
} from "./chunk.8-s4RjmR.js";
// /b.js
console.log(foo);
`,
"/out/chunk.xL6KqlYO.js": `// /shared.js
"/out/chunk.8-s4RjmR.js": `// /shared.js
let foo;
function setFoo(value) {
foo = value;
Expand Down Expand Up @@ -340,23 +340,23 @@ func TestSplittingSideEffectsWithoutDependencies(t *testing.T) {
AbsOutputDir: "/out",
},
expected: map[string]string{
"/out/a.js": `import "./chunk.xL6KqlYO.js";
"/out/a.js": `import "./chunk.Wqqj8fqN.js";
// /shared.js
let a = 1;
// /a.js
console.log(a);
`,
"/out/b.js": `import "./chunk.xL6KqlYO.js";
"/out/b.js": `import "./chunk.Wqqj8fqN.js";
// /shared.js
let b = 2;
// /b.js
console.log(b);
`,
"/out/chunk.xL6KqlYO.js": `// /shared.js
"/out/chunk.Wqqj8fqN.js": `// /shared.js
console.log("side effect");
`,
},
Expand Down Expand Up @@ -391,19 +391,19 @@ func TestSplittingNestedDirectories(t *testing.T) {
expected: map[string]string{
"/Users/user/project/out/pageA/page.js": `import {
shared_default
} from "../chunk.UcWke4C2.js";
} from "../chunk.Y98gPOMH.js";
// /Users/user/project/src/pages/pageA/page.js
console.log(shared_default);
`,
"/Users/user/project/out/pageB/page.js": `import {
shared_default
} from "../chunk.UcWke4C2.js";
} from "../chunk.Y98gPOMH.js";
// /Users/user/project/src/pages/pageB/page.js
console.log(-shared_default);
`,
"/Users/user/project/out/chunk.UcWke4C2.js": `// /Users/user/project/src/pages/shared.js
"/Users/user/project/out/chunk.Y98gPOMH.js": `// /Users/user/project/src/pages/shared.js
var shared_default = 123;
export {
Expand Down Expand Up @@ -437,7 +437,7 @@ func TestSplittingCircularReferenceIssue251(t *testing.T) {
"/out/a.js": `import {
p,
q
} from "./chunk.xL6KqlYO.js";
} from "./chunk.4ySCMXof.js";
// /a.js
export {
Expand All @@ -448,15 +448,15 @@ export {
"/out/b.js": `import {
p,
q
} from "./chunk.xL6KqlYO.js";
} from "./chunk.4ySCMXof.js";
// /b.js
export {
p,
q
};
`,
"/out/chunk.xL6KqlYO.js": `// /b.js
"/out/chunk.4ySCMXof.js": `// /b.js
var q = 6;
// /a.js
Expand Down Expand Up @@ -500,7 +500,7 @@ func TestSplittingMissingLazyExport(t *testing.T) {
AbsOutputDir: "/out",
},
expected: map[string]string{
"/out/a.js": `import "./chunk.xL6KqlYO.js";
"/out/a.js": `import "./chunk.nsO65Sdr.js";
// /empty.js
const empty_exports = {};
Expand All @@ -513,7 +513,7 @@ function foo() {
// /a.js
console.log(foo());
`,
"/out/b.js": `import "./chunk.xL6KqlYO.js";
"/out/b.js": `import "./chunk.nsO65Sdr.js";
// /common.js
function bar() {
Expand All @@ -523,7 +523,7 @@ function bar() {
// /b.js
console.log(bar());
`,
"/out/chunk.xL6KqlYO.js": `// /empty.js
"/out/chunk.nsO65Sdr.js": `// /empty.js
// /common.js
`,
Expand Down Expand Up @@ -551,7 +551,7 @@ func TestSplittingReExportIssue273(t *testing.T) {
expected: map[string]string{
"/out/a.js": `import {
a
} from "./chunk.xL6KqlYO.js";
} from "./chunk.Ldjbzhqa.js";
// /a.js
export {
Expand All @@ -560,14 +560,14 @@ export {
`,
"/out/b.js": `import {
a
} from "./chunk.xL6KqlYO.js";
} from "./chunk.Ldjbzhqa.js";
// /b.js
export {
a
};
`,
"/out/chunk.xL6KqlYO.js": `// /a.js
"/out/chunk.Ldjbzhqa.js": `// /a.js
const a = 1;
export {
Expand Down Expand Up @@ -679,16 +679,16 @@ func TestSplittingCrossChunkAssignmentDependencies(t *testing.T) {
expected: map[string]string{
"/out/a.js": `import {
setValue
} from "./chunk.xL6KqlYO.js";
} from "./chunk._9Zb2gmb.js";
// /a.js
setValue(123);
`,
"/out/b.js": `import "./chunk.xL6KqlYO.js";
"/out/b.js": `import "./chunk._9Zb2gmb.js";
// /b.js
`,
"/out/chunk.xL6KqlYO.js": `// /shared.js
"/out/chunk._9Zb2gmb.js": `// /shared.js
var observer;
var value;
function getValue() {
Expand Down
Loading

0 comments on commit a94f94f

Please sign in to comment.