File tree Expand file tree Collapse file tree 2 files changed +16
-2
lines changed Expand file tree Collapse file tree 2 files changed +16
-2
lines changed Original file line number Diff line number Diff line change 1
1
'use strict' ;
2
2
3
3
const path = require ( 'path' ) ;
4
+ const fs = require ( 'fs' ) ;
4
5
const resolveCwd = require ( './resolveCwd' ) ;
5
6
const cwd = process . cwd ( ) ;
6
7
const pkg = require ( resolveCwd ( 'package.json' ) ) ;
@@ -22,8 +23,21 @@ function getResolve() {
22
23
alias,
23
24
} ;
24
25
const name = pkg . name ;
25
- alias [ `${ name } $` ] = resolveCwd ( 'index.js' ) ;
26
+
27
+ // https://github.com/react-component/react-component.github.io/issues/13
28
+ // we dont't want rc-component examples/test code import rc-component from lib
29
+ // we want test with src
30
+ let pkgSrcMain = resolveCwd ( 'index.js' ) ;
31
+ if ( ! fs . existsSync ( pkgSrcMain ) ) {
32
+ pkgSrcMain = resolveCwd ( 'src/index.js' ) ;
33
+ if ( ! fs . existsSync ( pkgSrcMain ) ) {
34
+ console . error ( 'Get webpack.resolve.alias error: no /index.js or /src/index.js exist !!' ) ;
35
+ }
36
+ }
37
+ alias [ `${ name } $` ] = pkgSrcMain ;
38
+
26
39
alias [ `${ name } /${ constants . tsCompiledDir } ` ] = cwd ;
40
+
27
41
alias [ name ] = cwd ;
28
42
return resolve ;
29
43
}
Original file line number Diff line number Diff line change 1
1
{
2
2
"name" : " rc-tools" ,
3
- "version" : " 6.3.7 " ,
3
+ "version" : " 6.4.0 " ,
4
4
"description" : " offline tools for react component" ,
5
5
"keywords" : [
6
6
" react" ,
You can’t perform that action at this time.
0 commit comments