Skip to content

Commit c8bd620

Browse files
authored
feat(gatsby): update gatsby to version 3.10.0 (#6449)
- add webpack5 for gatsby as default init
1 parent 6f37066 commit c8bd620

File tree

8 files changed

+191
-20
lines changed

8 files changed

+191
-20
lines changed

e2e/gatsby/src/gatsby.test.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,20 @@ describe('Gatsby Applications', () => {
5757
await expect(runCLIAsync(`test ${appName}`)).resolves.toBeTruthy();
5858
}, 300000);
5959

60+
it('should support scss', async () => {
61+
const appName = uniq('app');
62+
63+
runCLI(`generate @nrwl/gatsby:app ${appName} --style scss`);
64+
65+
let result = runCLI(`build ${appName}`);
66+
expect(result).toContain('Done building in');
67+
68+
result = runCLI(`lint ${appName}`);
69+
expect(result).not.toMatch('Lint errors found in the listed files');
70+
71+
await expect(runCLIAsync(`test ${appName}`)).resolves.toBeTruthy();
72+
}, 300000);
73+
6074
it('should support --js option', async () => {
6175
const app = uniq('app');
6276
runCLI(`generate @nrwl/gatsby:app ${app} --js`);

packages/gatsby/migrations.json

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,12 @@
55
"version": "11.6.0-beta.0",
66
"description": "Add js patterns to tsconfig.app.json",
77
"factory": "./src/migrations/update-11-6-0/add-js-include-11-6-0"
8+
},
9+
"replace-node-sass-with-sass-12-6-1": {
10+
"cli": "nx",
11+
"version": "12.6.1-beta.0",
12+
"description": "Replace node-sass with sass in package.json",
13+
"factory": "./src/migrations/update-12-6-1/replace-node-sass-with-sass-12-6-1"
814
}
915
},
1016
"packageJsonUpdates": {
@@ -145,6 +151,75 @@
145151
"alwaysAddToPackageJson": false
146152
}
147153
}
154+
},
155+
"12.6.1": {
156+
"version": "12.6.1-beta.0",
157+
"packages": {
158+
"gatsby": {
159+
"version": "3.10.0",
160+
"alwaysAddToPackageJson": false
161+
},
162+
"gatsby-image": {
163+
"version": "3.10.0",
164+
"alwaysAddToPackageJson": false
165+
},
166+
"gatsby-plugin-manifest": {
167+
"version": "3.10.0",
168+
"alwaysAddToPackageJson": false
169+
},
170+
"gatsby-plugin-offline": {
171+
"version": "4.10.0",
172+
"alwaysAddToPackageJson": false
173+
},
174+
"gatsby-plugin-react-helmet": {
175+
"version": "4.10.0",
176+
"alwaysAddToPackageJson": false
177+
},
178+
"gatsby-plugin-sharp": {
179+
"version": "3.10.0",
180+
"alwaysAddToPackageJson": false
181+
},
182+
"gatsby-plugin-styled-jsx": {
183+
"version": "4.10.0",
184+
"alwaysAddToPackageJson": false
185+
},
186+
"gatsby-source-filesystem": {
187+
"version": "3.10.0",
188+
"alwaysAddToPackageJson": false
189+
},
190+
"gatsby-transformer-sharp": {
191+
"version": "3.10.0",
192+
"alwaysAddToPackageJson": false
193+
},
194+
"gatsby-plugin-typescript": {
195+
"version": "3.10.0",
196+
"alwaysAddToPackageJson": false
197+
},
198+
"gatsby-plugin-emotion": {
199+
"version": "6.10.0",
200+
"alwaysAddToPackageJson": false
201+
},
202+
"gatsby-plugin-styled-components": {
203+
"version": "4.10.0",
204+
"alwaysAddToPackageJson": false
205+
},
206+
"gatsby-plugin-sass": {
207+
"version": "4.10.0",
208+
"alwaysAddToPackageJson": false
209+
},
210+
"gatsby-plugin-less": {
211+
"version": "5.10.0",
212+
"alwaysAddToPackageJson": false
213+
},
214+
"gatsby-plugin-stylus": {
215+
"version": "3.10.0",
216+
"alwaysAddToPackageJson": false
217+
},
218+
"@testing-library/react": {
219+
"version": "12.0.0",
220+
"alwaysAddToPackageJson": false
221+
}
222+
}
148223
}
149224
}
150225
}

packages/gatsby/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,6 @@
3636
"@nrwl/node": "*",
3737
"@nrwl/react": "*",
3838
"@nrwl/workspace": "*",
39-
"gatsby-cli": "^3.5.0"
39+
"gatsby-cli": "^3.10.0"
4040
}
4141
}

packages/gatsby/src/generators/init/init.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ function updateDependencies(host: Tree) {
6161
'react-helmet': reactHelmetVersion,
6262
'gatsby-plugin-typescript': gatsbyPluginTypescriptVersion,
6363
...(isPnpm ? { 'gatsby-plugin-pnpm': gatsbyPluginPnpm } : {}),
64+
webpack: '^5.39.1',
6465
},
6566
{
6667
'@nrwl/gatsby': nxVersion,
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
import { readJson, Tree } from '@nrwl/devkit';
2+
import { createTreeWithEmptyWorkspace } from '@nrwl/devkit/testing';
3+
import { sassVersion } from '../../utils/versions';
4+
import update from './replace-node-sass-with-sass-12-6-1';
5+
6+
describe('Replace node-sass with sass to dev dependencies 12.6.1', () => {
7+
let tree: Tree;
8+
9+
beforeEach(async () => {
10+
tree = createTreeWithEmptyWorkspace();
11+
});
12+
13+
it(`should replace node-sass with sass if gatsby-plugin-sass is in devDependencies`, async () => {
14+
tree.write(
15+
'package.json',
16+
JSON.stringify({
17+
dependencies: {},
18+
devDependencies: { 'node-sass': '*', 'gatsby-plugin-sass': '*' },
19+
})
20+
);
21+
22+
await update(tree);
23+
24+
const devDependencies = readJson(tree, 'package.json').devDependencies;
25+
expect(devDependencies['sass']).toEqual(sassVersion);
26+
expect(devDependencies['node-sass']).toBeUndefined();
27+
});
28+
29+
it(`should not replace node-sass with sass if gatsby-plugin-sass is not in devDependencies`, async () => {
30+
tree.write(
31+
'package.json',
32+
JSON.stringify({
33+
dependencies: {},
34+
devDependencies: { 'node-sass': '*' },
35+
})
36+
);
37+
38+
await update(tree);
39+
40+
const devDependencies = readJson(tree, 'package.json').devDependencies;
41+
expect(devDependencies['sass']).toBeUndefined();
42+
expect(devDependencies['node-sass']).toBeDefined();
43+
});
44+
});
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
import {
2+
addDependenciesToPackageJson,
3+
Tree,
4+
formatFiles,
5+
removeDependenciesFromPackageJson,
6+
readJson,
7+
} from '@nrwl/devkit';
8+
import { runTasksInSerial } from '@nrwl/workspace/src/utilities/run-tasks-in-serial';
9+
import { sassVersion } from '../../utils/versions';
10+
11+
/**
12+
* For gatsby app with style scss option, replace node-sass with sass in package.json
13+
*/
14+
export default async function update(tree: Tree) {
15+
const packageJson = readJson(tree, 'package.json');
16+
17+
// does not proceed if gatsby-plugin-sass is not a part of devDependencies
18+
if (!packageJson.devDependencies['gatsby-plugin-sass']) {
19+
return;
20+
}
21+
22+
const uninstallTask = removeDependenciesFromPackageJson(
23+
tree,
24+
[],
25+
['node-sass']
26+
);
27+
const installTask = addDependenciesToPackageJson(
28+
tree,
29+
{},
30+
{
31+
sass: sassVersion,
32+
}
33+
);
34+
await formatFiles(tree);
35+
36+
return runTasksInSerial(uninstallTask, installTask);
37+
}

packages/gatsby/src/utils/styles.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import {
66
gatsbyPluginStyledComponentsVersion,
77
gatsbyPluginStyledJsx,
88
gatsbyPluginStylusVersion,
9-
nodeSassVersion,
9+
sassVersion,
1010
} from './versions';
1111
import { Tree } from '@nrwl/tao/src/shared/tree';
1212
import {
@@ -31,7 +31,7 @@ export const GATSBY_SPECIFIC_STYLE_DEPENDENCIES = {
3131
scss: {
3232
dependencies: {},
3333
devDependencies: {
34-
'node-sass': nodeSassVersion,
34+
sass: sassVersion,
3535
'gatsby-plugin-sass': gatsbyPluginSassVersion,
3636
},
3737
},
Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,25 @@
11
export const nxVersion = '*';
22

3-
export const gatsbyVersion = '3.5.0';
4-
export const gatsbyImageVersion = '3.5.0';
5-
export const gatsbyPluginManifestVersion = '3.5.0';
6-
export const gatsbyPluginOfflineVersion = '4.5.0';
7-
export const gatsbyPluginReactHelmetVersion = '4.5.0';
8-
export const gatsbyPluginSharpVersion = '3.5.0';
9-
export const gatsbyPluginStyledJsx = '4.5.0';
10-
export const gatsbySourceFilesystemVersion = '3.5.0';
11-
export const gatsbyTransformerSharpVersion = '3.5.0';
3+
export const gatsbyVersion = '3.10.0';
4+
export const gatsbyImageVersion = '3.10.0';
5+
export const gatsbyPluginManifestVersion = '3.10.0';
6+
export const gatsbyPluginOfflineVersion = '4.10.0';
7+
export const gatsbyPluginReactHelmetVersion = '4.10.0';
8+
export const gatsbyPluginSharpVersion = '3.10.0';
9+
export const gatsbyPluginStyledJsx = '4.10.0';
10+
export const gatsbySourceFilesystemVersion = '3.10.0';
11+
export const gatsbyTransformerSharpVersion = '3.10.0';
1212
export const propTypesVersion = '15.7.2';
1313
export const reactHelmetVersion = '6.1.0';
14-
export const gatsbyPluginTypescriptVersion = '3.5.0';
14+
export const gatsbyPluginTypescriptVersion = '3.10.0';
1515
export const babelPluginModuleResolverVersion = '4.0.0';
1616
export const babelPresetGatsbyVersion = '0.12.1';
17-
export const testingLibraryReactVersion = '11.2.6';
18-
export const gatsbyPluginEmotionVersion = '6.5.0';
19-
export const gatsbyPluginStyledComponentsVersion = '4.5.0';
20-
export const gatsbyPluginSassVersion = '4.5.0';
21-
export const gatsbyPluginLessVersion = '5.5.0';
22-
export const gatsbyPluginStylusVersion = '3.5.0';
23-
export const nodeSassVersion = '5.0.0';
17+
export const testingLibraryReactVersion = '12.0.0';
18+
export const gatsbyPluginEmotionVersion = '6.10.0';
19+
export const gatsbyPluginStyledComponentsVersion = '4.10.0';
20+
export const gatsbyPluginSassVersion = '4.10.0';
21+
export const gatsbyPluginLessVersion = '5.10.0';
22+
export const gatsbyPluginStylusVersion = '3.10.0';
23+
export const sassVersion = '1.35.2';
2424
export const gatsbyPluginSvgrVersion = '3.0.0-beta.0';
2525
export const gatsbyPluginPnpm = '1.2.6';

0 commit comments

Comments
 (0)