Skip to content

Commit df01bd7

Browse files
committed
fix(build): Address @carbon/react resolution errors and update webpack config
1 parent 6567585 commit df01bd7

File tree

5 files changed

+24
-22
lines changed

5 files changed

+24
-22
lines changed

gatsby-config.js

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -73,16 +73,5 @@ module.exports = {
7373
directory: path.resolve(__dirname, './src/data/chart-index'),
7474
},
7575
},
76-
// Fix for Sass legacy JS API deprecation warnings:
77-
{
78-
resolve: 'gatsby-plugin-sass',
79-
options: {
80-
implementation: require('sass'), // Use Dart Sass explicitly
81-
sassOptions: {
82-
// No need for 'api' here as Dart Sass is default now, but you can silence warnings:
83-
quietDeps: true,
84-
},
85-
},
86-
},
8776
],
88-
};
77+
};

gatsby-node.js

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
const path = require('path');
22

33
exports.onCreateWebpackConfig = ({ actions, getConfig }) => {
4-
// Allows importing html files for component code examples
54
actions.setWebpackConfig({
65
module: {
76
rules: [
@@ -19,15 +18,25 @@ exports.onCreateWebpackConfig = ({ actions, getConfig }) => {
1918
],
2019
},
2120
resolve: {
21+
// Ensure node_modules are in the path for resolution
2222
modules: [path.resolve(__dirname, 'src'), 'node_modules'],
2323
alias: {
24-
// light-weight fork of buble compiler from react-live team
2524
buble: path.resolve(__dirname, 'node_modules', '@philpl/buble'),
25+
// Explicitly resolve @carbon packages to their node_modules path
26+
'@carbon/react': path.resolve(__dirname, 'node_modules/@carbon/react'),
27+
'@carbon/icons-react': path.resolve(__dirname, 'node_modules/@carbon/icons-react'),
28+
'@carbon/styles': path.resolve(__dirname, 'node_modules/@carbon/styles'), // Keep for Sass if needed
2629
},
30+
// Fallback for older module resolution patterns
31+
fallback: {
32+
'crypto': false, // Example of adding fallbacks if needed for older modules
33+
'stream': false,
34+
'path': require.resolve('path-browserify'), // Ensure path resolves correctly
35+
// You might need more if other 'cannot resolve' errors appear for node built-ins
36+
}
2737
},
2838
});
2939

30-
// Disable sourcemaps in production
3140
if (getConfig().mode === 'production') {
3241
actions.setWebpackConfig({
3342
devtool: false,
@@ -38,7 +47,6 @@ exports.onCreateWebpackConfig = ({ actions, getConfig }) => {
3847
exports.createPages = ({ actions }) => {
3948
const { createRedirect } = actions;
4049

41-
// Community index
4250
createRedirect({
4351
fromPath: '/community/components',
4452
toPath: '/community/component-index',
@@ -50,7 +58,6 @@ exports.createPages = ({ actions }) => {
5058
isPermanent: true,
5159
});
5260

53-
// Developing
5461
createRedirect({
5562
fromPath: '/resources',
5663
toPath: '/developing/developer-resources',
@@ -97,7 +104,6 @@ exports.createPages = ({ actions }) => {
97104
isPermanent: true,
98105
});
99106

100-
// Case studies
101107
createRedirect({
102108
fromPath: ' /case-studies/overview',
103109
toPath: '/all-about-carbon/who-uses-carbon/',
@@ -114,7 +120,6 @@ exports.createPages = ({ actions }) => {
114120
isPermanent: true,
115121
});
116122

117-
// Data-visualization
118123
createRedirect({
119124
fromPath: '/data-visualization/basic-charts',
120125
toPath: '/data-visualization/simple-charts',
@@ -126,7 +131,6 @@ exports.createPages = ({ actions }) => {
126131
isPermanent: true,
127132
});
128133

129-
// Elements L0 - 2022/02
130134
createRedirect({
131135
fromPath: '/guidelines/2x-grid/overview',
132136
toPath: '/elements/2x-grid/overview',
@@ -247,4 +251,4 @@ exports.createPages = ({ actions }) => {
247251
toPath: '/elements/typography/code',
248252
isPermanent: true,
249253
});
250-
};
254+
};

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@
5151
"gatsby-plugin-sharp": "^5.13.1",
5252
"gatsby-theme-carbon": "^4.3.6",
5353
"markdown-it": "^14.1.0",
54+
"path-browserify": "^1.0.1",
5455
"prettier-config-carbon": "^0.11.0",
5556
"react": "^18.2.0",
5657
"react-copy-to-clipboard": "^5.1.0",
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
import ArticleCard from './ArticleCard';
22

3-
export default ArticleCard;
3+
export default ArticleCard;

yarn.lock

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8764,6 +8764,7 @@ __metadata:
87648764
markdown-it: "npm:^14.1.0"
87658765
markdown-loader: "npm:^8.0.0"
87668766
netlify-cli: "npm:^18.1.0"
8767+
path-browserify: "npm:^1.0.1"
87678768
prettier: "npm:^2.0.2"
87688769
prettier-config-carbon: "npm:^0.11.0"
87698770
react: "npm:^18.2.0"
@@ -22054,6 +22055,13 @@ __metadata:
2205422055
languageName: node
2205522056
linkType: hard
2205622057

22058+
"path-browserify@npm:^1.0.1":
22059+
version: 1.0.1
22060+
resolution: "path-browserify@npm:1.0.1"
22061+
checksum: 10c0/8b8c3fd5c66bd340272180590ae4ff139769e9ab79522e2eb82e3d571a89b8117c04147f65ad066dccfb42fcad902e5b7d794b3d35e0fd840491a8ddbedf8c66
22062+
languageName: node
22063+
linkType: hard
22064+
2205722065
"path-case@npm:^3.0.4":
2205822066
version: 3.0.4
2205922067
resolution: "path-case@npm:3.0.4"

0 commit comments

Comments
 (0)