11const isProd = process . env . NODE_ENV === 'production' ;
22
33const nextConfig = {
4+ output : 'export' ,
45 basePath : isProd ? '/visx' : '' ,
56 ...( isProd && { assetPrefix : '/visx/' } ) ,
67 typescript : {
@@ -11,44 +12,52 @@ const nextConfig = {
1112 // Don't run ESLint during builds (it's run at the root level)
1213 ignoreDuringBuilds : true ,
1314 } ,
15+ // Handle ESM packages that are imported by visx
1416 experimental : {
15- // note: this can be removed in future next versions
1617 esmExternals : 'loose' ,
1718 } ,
18- webpack : ( config ) => {
19- // add visx-*/src/* to be parsed by babel
20- // Find all rules that handle JS/TS files and add visx source files to their include
21- config . module . rules . forEach ( ( rule ) => {
22- // Check if this rule handles .tsx/.ts files
23- if ( rule . test && ( rule . test . test ?. ( '.tsx' ) || rule . test . test ?. ( '.ts' ) ) ) {
24- // Expand include to also handle visx packages' src directories
25- if ( Array . isArray ( rule . include ) ) {
26- rule . include . push ( / v i s x - .* \/ s r c / ) ;
27- } else if ( rule . include ) {
28- rule . include = [ rule . include , / v i s x - .* \/ s r c / ] ;
29- } else {
30- rule . include = / v i s x - .* \/ s r c / ;
31- }
32- }
33-
34- // Also check nested rules
35- if ( rule . oneOf ) {
36- rule . oneOf . forEach ( ( oneOfRule ) => {
37- if ( oneOfRule . test && ( oneOfRule . test . test ?. ( '.tsx' ) || oneOfRule . test . test ?. ( '.ts' ) ) ) {
38- if ( Array . isArray ( oneOfRule . include ) ) {
39- oneOfRule . include . push ( / v i s x - .* \/ s r c / ) ;
40- } else if ( oneOfRule . include ) {
41- oneOfRule . include = [ oneOfRule . include , / v i s x - .* \/ s r c / ] ;
42- } else {
43- oneOfRule . include = / v i s x - .* \/ s r c / ;
44- }
45- }
46- } ) ;
47- }
48- } ) ;
49-
50- return config ;
51- } ,
19+ // In Next.js 13+, use transpilePackages to transpile visx source files
20+ // This is simpler and more reliable than custom webpack config
21+ transpilePackages : [
22+ '@visx/annotation' ,
23+ '@visx/axis' ,
24+ '@visx/bounds' ,
25+ '@visx/brush' ,
26+ '@visx/chord' ,
27+ '@visx/clip-path' ,
28+ '@visx/curve' ,
29+ '@visx/delaunay' ,
30+ '@visx/drag' ,
31+ '@visx/event' ,
32+ '@visx/geo' ,
33+ '@visx/glyph' ,
34+ '@visx/gradient' ,
35+ '@visx/grid' ,
36+ '@visx/group' ,
37+ '@visx/heatmap' ,
38+ '@visx/hierarchy' ,
39+ '@visx/legend' ,
40+ '@visx/marker' ,
41+ '@visx/mock-data' ,
42+ '@visx/network' ,
43+ '@visx/pattern' ,
44+ '@visx/point' ,
45+ '@visx/react-spring' ,
46+ '@visx/responsive' ,
47+ '@visx/sankey' ,
48+ '@visx/scale' ,
49+ '@visx/shape' ,
50+ '@visx/stats' ,
51+ '@visx/text' ,
52+ '@visx/threshold' ,
53+ '@visx/tooltip' ,
54+ '@visx/vendor' ,
55+ '@visx/visx' ,
56+ '@visx/voronoi' ,
57+ '@visx/wordcloud' ,
58+ '@visx/xychart' ,
59+ '@visx/zoom' ,
60+ ] ,
5261} ;
5362
5463// eslint-disable-next-line no-undef
0 commit comments