Skip to content

Commit b7eb5c9

Browse files
authored
chore: upgrade to next 14 (#1952)
1 parent 3a129e6 commit b7eb5c9

File tree

5 files changed

+157
-450
lines changed

5 files changed

+157
-450
lines changed

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -122,8 +122,8 @@
122122
},
123123
"resolutions": {
124124
"handlebars": "4.5.3",
125-
"react": "18.0.0",
126-
"react-dom": "18.0.0",
125+
"react": "18.3.1",
126+
"react-dom": "18.3.1",
127127
"@types/react": "18.3.26",
128128
"@types/react-dom": "18.3.7",
129129
"wrap-ansi": "7.0.0",

packages/visx-demo/next-env.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22
/// <reference types="next/image-types/global" />
33

44
// NOTE: This file should not be edited
5-
// see https://nextjs.org/docs/basic-features/typescript for more information.
5+
// see https://nextjs.org/docs/pages/building-your-application/configuring/typescript for more information.

packages/visx-demo/next.config.js

Lines changed: 44 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
const isProd = process.env.NODE_ENV === 'production';
22

33
const 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(/visx-.*\/src/);
27-
} else if (rule.include) {
28-
rule.include = [rule.include, /visx-.*\/src/];
29-
} else {
30-
rule.include = /visx-.*\/src/;
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(/visx-.*\/src/);
40-
} else if (oneOfRule.include) {
41-
oneOfRule.include = [oneOfRule.include, /visx-.*\/src/];
42-
} else {
43-
oneOfRule.include = /visx-.*\/src/;
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

packages/visx-demo/package.json

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"description": "visx demo",
55
"repository": "https://github.com/airbnb/visx",
66
"scripts": {
7-
"build": "next build && next export",
7+
"build": "next build",
88
"deploy": "rm -rf out && yarn build && cd out && touch .nojekyll && git init && git add . && git commit -m \"Deploy commit\" && git remote add origin git@github.com:airbnb/visx.git && git push -f origin master:gh-pages",
99
"dev": "next",
1010
"preview": "yarn build && cd ./out && npx serve",
@@ -69,7 +69,6 @@
6969
"@visx/wordcloud": "3.13.0-alpha.0",
7070
"@visx/xychart": "3.13.2-alpha.0",
7171
"@visx/zoom": "3.13.0-alpha.0",
72-
"@zeit/next-css": "^1.0.1",
7372
"babel-loader": "^8.2.2",
7473
"classnames": "^2.3.1",
7574
"d3-collection": "^1.0.4",
@@ -78,12 +77,12 @@
7877
"d3-shape": "^1.0.6",
7978
"lodash": "^4.17.21",
8079
"markdown-loader": "^5.1.0",
81-
"next": "^13.0.0",
80+
"next": "^14.2.0",
8281
"nprogress": "^0.2.0",
8382
"prismjs": "^1.19.0",
8483
"raw-loader": "^4.0.0",
85-
"react": "^18.0.0",
86-
"react-dom": "^18.0.0",
84+
"react": "^18.2.0",
85+
"react-dom": "^18.2.0",
8786
"react-github-button": "^0.1.10",
8887
"react-markdown": "^4.3.1",
8988
"topojson-client": "^3.0.0"

0 commit comments

Comments
 (0)