Skip to content

Commit 733ea95

Browse files
committed
emit stable require map
1 parent 0191487 commit 733ea95

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "react-imported-component",
3-
"version": "6.0.0-beta.4",
3+
"version": "6.0.0-beta.5",
44
"description": "I will import your component, and help to handle it",
55
"main": "dist/es5/index.js",
66
"jsnext:main": "dist/es2015/index.js",

src/scanners/scanForImports.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,8 +80,11 @@ export const remapImports = (
8080
.forEach(({name, comment, doNotTransform}) => {
8181
const rootName = doNotTransform ? name : getRelative(root, name);
8282
const fileName = doNotTransform ? name : getRelative(targetDir, name);
83+
const def = `[() => import(${comment}'${fileName}'), '${getChunkName(comment)}', '${rootName}']`;
84+
const slot = getRelative(root, name);
8385

84-
imports[getRelative(root, name)] = `[() => import(${comment}'${fileName}'), '${getChunkName(comment)}', '${rootName}']`
86+
// keep the maximal definition
87+
imports[slot] = !imports[slot] ? def : (imports[slot].length > def.length ? imports[slot] : def);
8588
})
8689
))
8790
);
@@ -95,6 +98,7 @@ function scanTop(root: string, start: string, target: string) {
9598
(await scanDirectory(join(root, start), undefined, rejectSystemFiles) as string[])
9699
.filter(name => normalizePath(name).indexOf(target) === -1)
97100
.filter(name => RESOLVE_EXTENSIONS.indexOf(extname(name)) >= 0)
101+
.sort();
98102

99103
const data: FileContent[] = await Promise.all(
100104
files

0 commit comments

Comments
 (0)