@@ -10,7 +10,10 @@ import {
10
10
} from '@angular-devkit/core/src/utils/literals' ;
11
11
import { initRootBabelConfig } from '../utils/rules' ;
12
12
import { addDepsToPackageJson , formatFiles } from '@nrwl/workspace' ;
13
- import { createProjectGraphAsync } from '@nrwl/workspace/src/core/project-graph' ;
13
+ import {
14
+ createProjectGraphAsync ,
15
+ isNpmProject ,
16
+ } from '@nrwl/workspace/src/core/project-graph' ;
14
17
15
18
let addedEmotionPreset = false ;
16
19
@@ -30,15 +33,15 @@ export default function update(): Rule {
30
33
context . logger . info (
31
34
`
32
35
Found an existing babel.config.json file so we skipped creating it.
33
-
36
+
34
37
You may want to update it to include the Nx preset "@nrwl/web/babel".
35
38
`
36
39
) ;
37
40
} else if ( host . exists ( '/babel.config.js' ) ) {
38
41
context . logger . info (
39
42
`
40
43
Found an existing babel.config.js file so we skipped creating it.
41
-
44
+
42
45
You may want to update it to include the Nx preset "@nrwl/web/babel".
43
46
`
44
47
) ;
@@ -51,7 +54,7 @@ export default function update(): Rule {
51
54
const deps = projectGraph . dependencies [ name ] ;
52
55
const isReact = deps . some (
53
56
( d ) =>
54
- projectGraph . nodes [ d . target ] . type === 'npm' &&
57
+ isNpmProject ( projectGraph . nodes [ d . target ] ) &&
55
58
d . target . indexOf ( 'react' ) !== - 1
56
59
) ;
57
60
if ( isReact ) {
@@ -69,11 +72,11 @@ export default function update(): Rule {
69
72
if ( conflicts . length > 0 ) {
70
73
context . logger . info ( stripIndent `
71
74
The following projects already have .babelrc so we did not create them:
72
-
75
+
73
76
${ conflicts
74
77
. map ( ( [ name , babelrc ] ) => `${ name } - ${ babelrc } ` )
75
78
. join ( '\n ' ) }
76
-
79
+
77
80
You may want to update them to include the Nx preset "@nrwl/react/babel".
78
81
` ) ;
79
82
}
@@ -109,7 +112,7 @@ function createBabelrc(host, context, babelrcPath, deps) {
109
112
context . logger . warn (
110
113
stripIndents `We created a babel config at ${ babelrcPath } with both styled-components and emotion plugins.
111
114
Only one should be used, please remove the unused plugin.
112
-
115
+
113
116
For example, if you don't use styled-components, then remove that plugin from the .babelrc file.
114
117
`
115
118
) ;
0 commit comments