File tree Expand file tree Collapse file tree 4 files changed +16
-15
lines changed Expand file tree Collapse file tree 4 files changed +16
-15
lines changed Original file line number Diff line number Diff line change 1
1
import { createPath } from '../__test-helpers__'
2
2
3
- import {
4
- tryRequire ,
5
- requireById ,
6
- resolveExport ,
7
- findExport
8
- } from '../src/utils'
3
+ import { tryRequire , resolveExport , findExport } from '../src/utils'
4
+
5
+ import requireById from '../src/requireById'
9
6
10
7
test ( 'tryRequire: requires module using key export finder + calls onLoad with module' , ( ) => {
11
8
const moduleEs6 = createPath ( 'es6' )
Original file line number Diff line number Diff line change 29
29
],
30
30
"scripts" : {
31
31
"build" : " babel src -d dist" ,
32
- "flow-copy" : " flow-copy-source src dist" ,
32
+ "flow-copy" : " flow-copy-source src dist -i 'requireById/index.js' " ,
33
33
"flow-watch" : " clear; printf \"\\ 033[3J\" & npm run flow & fswatch -o ./ | xargs -n1 -I{} sh -c 'clear; printf \"\\ 033[3J\" && npm run flow'" ,
34
34
"flow" : " flow; test $? -eq 0 -o $? -eq 2" ,
35
35
"clean" : " rimraf dist && mkdir dist" ,
Original file line number Diff line number Diff line change
1
+ import { isWebpack } from '../utils'
2
+
3
+ const requireById = id => {
4
+ if ( ! isWebpack ( ) && typeof id === 'string' ) {
5
+ return module . require ( `${ id } ` )
6
+ }
7
+
8
+ return __webpack_require__ ( `${ id } ` )
9
+ }
10
+
11
+ export default requireById
Original file line number Diff line number Diff line change 1
1
// @flow
2
2
import * as React from 'react'
3
+ import requireById from './requireById'
3
4
4
5
import type {
5
6
Id ,
@@ -48,14 +49,6 @@ export const tryRequire = (id: Id): ?any => {
48
49
return null
49
50
}
50
51
51
- export const requireById = ( id : Id ) : ?any => {
52
- if ( ! isWebpack ( ) && typeof id === 'string' ) {
53
- return module . require ( `${ id } ` )
54
- }
55
-
56
- return __webpack_require__ ( `${ id } ` )
57
- }
58
-
59
52
export const resolveExport = (
60
53
mod : ?Mod ,
61
54
key : ?Key ,
You can’t perform that action at this time.
0 commit comments