File tree Expand file tree Collapse file tree 11 files changed +54
-2
lines changed
test/configCases/errors/self-reexport Expand file tree Collapse file tree 11 files changed +54
-2
lines changed Original file line number Diff line number Diff line change @@ -108,7 +108,8 @@ const getFinalName = (
108108 moduleToInfoMap ,
109109 requestShortener ,
110110 asCall ,
111- strictHarmonyModule
111+ strictHarmonyModule ,
112+ alreadyVisited = new Set ( )
112113) => {
113114 switch ( info . type ) {
114115 case "concatenated" : {
@@ -134,6 +135,22 @@ const getFinalName = (
134135 }
135136 const reexport = info . reexportMap . get ( exportName ) ;
136137 if ( reexport ) {
138+ if ( alreadyVisited . has ( reexport ) ) {
139+ throw new Error (
140+ `Circular reexports ${ Array . from (
141+ alreadyVisited ,
142+ e =>
143+ `"${ e . module . readableIdentifier ( requestShortener ) } ".${
144+ e . exportName
145+ } `
146+ ) . join (
147+ " --> "
148+ ) } -(circular)-> "${ reexport . module . readableIdentifier (
149+ requestShortener
150+ ) } ".${ reexport . exportName } `
151+ ) ;
152+ }
153+ alreadyVisited . add ( reexport ) ;
137154 const refInfo = moduleToInfoMap . get ( reexport . module ) ;
138155 if ( refInfo ) {
139156 // module is in the concatenation
@@ -143,7 +160,8 @@ const getFinalName = (
143160 moduleToInfoMap ,
144161 requestShortener ,
145162 asCall ,
146- strictHarmonyModule
163+ strictHarmonyModule ,
164+ alreadyVisited
147165 ) ;
148166 }
149167 }
Original file line number Diff line number Diff line change 1+ export { something } from "./a" ;
Original file line number Diff line number Diff line change 1+ import { something } from "./a" ;
2+
3+ something ( ) ;
Original file line number Diff line number Diff line change 1+
2+ import { something , other } from "./b" ;
3+
4+ export {
5+ something as other ,
6+ other as something
7+ }
Original file line number Diff line number Diff line change 1+ import { something } from "./b" ;
2+
3+ something ( ) ;
Original file line number Diff line number Diff line change 1+ export { something } from "./c2" ;
Original file line number Diff line number Diff line change 1+ export { something } from "./c1" ;
Original file line number Diff line number Diff line change 1+ import { something } from "./c1" ;
2+
3+ something ( ) ;
Original file line number Diff line number Diff line change 1+ module . exports = [
2+ [ / C i r c u l a r r e e x p o r t s " \. \/ a .j s " \. s o m e t h i n g - \( c i r c u l a r \) - > " \. \/ a .j s " \. s o m e t h i n g / ] ,
3+ [ / C i r c u l a r r e e x p o r t s " \. \/ b .j s " \. o t h e r - - > " \. \/ b .j s " \. s o m e t h i n g - \( c i r c u l a r \) - > " \. \/ b .j s " \. o t h e r / ] ,
4+ [ / C i r c u l a r r e e x p o r t s " \. \/ c 2 .j s " \. s o m e t h i n g - - > " \. \/ c 1 .j s " \. s o m e t h i n g - \( c i r c u l a r \) - > " \. \/ c 2 .j s " \. s o m e t h i n g / ]
5+ ] ;
Original file line number Diff line number Diff line change 1+ it ( "should not crash on incorrect exports" , function ( ) {
2+ if ( Math . random ( ) < - 1 ) {
3+ import ( /* webpackChunkName: "a" */ "./aa" ) ;
4+ import ( /* webpackChunkName: "b" */ "./bb" ) ;
5+ import ( /* webpackChunkName: "c" */ "./cc" ) ;
6+ }
7+ } ) ;
You can’t perform that action at this time.
0 commit comments