fix(v2): refactor routes.ts + add route hash for chunkNames key (#3001)

* add simpleHash util

* refactor/split the routes generation logic + add route hash to avoid chunk conflicts

* minor fixes + fix tests

* fix comment typo
This commit is contained in:
Sébastien Lorber 2020-06-30 11:52:39 +02:00 committed by GitHub
parent 984e2d4598
commit cf97662eef
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 161 additions and 149 deletions

View file

@ -8,6 +8,7 @@
import path from 'path';
import {
fileToPath,
simpleHash,
docuHash,
genComponentName,
genChunkName,
@ -71,6 +72,21 @@ describe('load utils', () => {
});
});
test('simpleHash', () => {
const asserts = {
'': 'd41',
'/foo-bar': '096',
'/foo/bar': '1df',
'/endi/lie': '9fa',
'/endi-lie': 'fd3',
'/yangshun/tay': '48d',
'/yangshun-tay': 'f3b',
};
Object.keys(asserts).forEach((file) => {
expect(simpleHash(file, 3)).toBe(asserts[file]);
});
});
test('docuHash', () => {
const asserts = {
'': '-d41',