GeezerVison is showing github.com — Fixed raw-loader + Jest problem · react/react@8001b64
File treeExpand file treeCollapse file tree Open diff view settings Expand file treeCollapse file tree Open diff view settings Collapse file Copy file name to clipboardExpand all lines: .eslintrc +1Lines changed: 1 addition & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 12 | 12 | }, | 13 | 13 | "globals": { | 14 | 14 | "__DEV__": "readonly", | | 15 | + "__TEST__": "readonly", | 15 | 16 | "jasmine": "readonly", | 16 | 17 | "spyOn": "readonly" | 17 | 18 | } | |
Collapse file Copy file name to clipboardExpand all lines: flow.js +1Lines changed: 1 addition & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -18,6 +18,7 @@ declare module 'events' { | 18 | 18 | } | 19 | 19 |
| 20 | 20 | declare var __DEV__: boolean; | | 21 | +declare var __TEST__: boolean; | 21 | 22 |
| 22 | 23 | declare var jasmine: {| | 23 | 24 | getEnv: () => {| | |
Collapse file Copy file name to clipboardExpand all lines: packages/react-devtools-core/webpack.backend.js +1Lines changed: 1 addition & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -35,6 +35,7 @@ module.exports = { | 35 | 35 | plugins: [ | 36 | 36 | new DefinePlugin({ | 37 | 37 | __DEV__: true, | | 38 | + __TEST__: false, | 38 | 39 | 'process.env.DEVTOOLS_VERSION': `"${DEVTOOLS_VERSION}"`, | 39 | 40 | 'process.env.GITHUB_URL': `"${GITHUB_URL}"`, | 40 | 41 | }), | |
Collapse file Copy file name to clipboardExpand all lines: packages/react-devtools-core/webpack.standalone.js +1Lines changed: 1 addition & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -34,6 +34,7 @@ module.exports = { | 34 | 34 | plugins: [ | 35 | 35 | new DefinePlugin({ | 36 | 36 | __DEV__: false, | | 37 | + __TEST__: false, | 37 | 38 | 'process.env.DEVTOOLS_VERSION': `"${DEVTOOLS_VERSION}"`, | 38 | 39 | 'process.env.GITHUB_URL': `"${GITHUB_URL}"`, | 39 | 40 | 'process.env.NODE_ENV': `"${NODE_ENV}"`, | |
Collapse file Copy file name to clipboardExpand all lines: packages/react-devtools-inline/webpack.config.js +2-1Lines changed: 2 additions & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -38,7 +38,8 @@ module.exports = { | 38 | 38 | }, | 39 | 39 | plugins: [ | 40 | 40 | new DefinePlugin({ | 41 | | - __DEV__: __DEV__, | | 41 | + __DEV__, | | 42 | + __TEST__: false, | 42 | 43 | 'process.env.DEVTOOLS_VERSION': `"${DEVTOOLS_VERSION}"`, | 43 | 44 | 'process.env.GITHUB_URL': `"${GITHUB_URL}"`, | 44 | 45 | 'process.env.NODE_ENV': `"${NODE_ENV}"`, | |
Collapse file Copy file name to clipboardExpand all lines: shells/browser/shared/webpack.backend.js +1Lines changed: 1 addition & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -31,6 +31,7 @@ module.exports = { | 31 | 31 | plugins: [ | 32 | 32 | new DefinePlugin({ | 33 | 33 | __DEV__: true, | | 34 | + __TEST__: false, | 34 | 35 | 'process.env.DEVTOOLS_VERSION': `"${DEVTOOLS_VERSION}"`, | 35 | 36 | 'process.env.GITHUB_URL': `"${GITHUB_URL}"`, | 36 | 37 | }), | |
Collapse file Copy file name to clipboardExpand all lines: shells/browser/shared/webpack.config.js +1Lines changed: 1 addition & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -36,6 +36,7 @@ module.exports = { | 36 | 36 | plugins: [ | 37 | 37 | new DefinePlugin({ | 38 | 38 | __DEV__: false, | | 39 | + __TEST__: false, | 39 | 40 | 'process.env.DEVTOOLS_VERSION': `"${DEVTOOLS_VERSION}"`, | 40 | 41 | 'process.env.GITHUB_URL': `"${GITHUB_URL}"`, | 41 | 42 | 'process.env.NODE_ENV': `"${NODE_ENV}"`, | |
Collapse file Copy file name to clipboardExpand all lines: shells/dev/webpack.config.js +2-1Lines changed: 2 additions & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -39,7 +39,8 @@ const config = { | 39 | 39 | }, | 40 | 40 | plugins: [ | 41 | 41 | new DefinePlugin({ | 42 | | - __DEV__: __DEV__, | | 42 | + __DEV__, | | 43 | + __TEST__: false, | 43 | 44 | 'process.env.GITHUB_URL': `"${GITHUB_URL}"`, | 44 | 45 | 'process.env.DEVTOOLS_VERSION': `"${DEVTOOLS_VERSION}"`, | 45 | 46 | }), | |
Collapse file Copy file name to clipboardExpand all lines: src/__tests__/setupEnv.js +1Lines changed: 1 addition & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -12,3 +12,4 @@ if (!global.hasOwnProperty('localStorage')) { | 12 | 12 |
| 13 | 13 | // Mimic the global we set with Webpack's DefinePlugin | 14 | 14 | global.__DEV__ = process.env.NODE_ENV !== 'production'; | | 15 | +global.__TEST__ = process.env.NODE_ENV === 'test'; |
Collapse file Copy file name to clipboard +28-18Lines changed: 28 additions & 18 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 1 | 1 | // @flow | 2 | 2 |
| 3 | | -// $FlowFixMe Cannot resolve module | 4 | | -import rawStyleString from '!!raw-loader!src/devtools/views/root.css'; // eslint-disable-line import/no-webpack-loader-syntax | 5 | | - | 6 | 3 | // Flip this flag to true to enable verbose console debug logging. | 7 | 4 | export const __DEBUG__ = false; | 8 | 5 |
| 9 | | -const extractVar = varName => { | 10 | | - const regExp = new RegExp(`${varName}: ([0-9]+)`); | 11 | | - const match = rawStyleString.match(regExp); | 12 | | - return parseInt(match[1], 10); | 13 | | -}; | 14 | | - | 15 | | -// TRICKY | 16 | | -// Extracting during build time avoids a temporarily invalid state for the inline target. | 17 | | -// Sometimes the inline target is rendered before root styles are applied, | 18 | | -// which would result in e.g. NaN itemSize being passed to react-window list. | 19 | | -export const COMFORTABLE_LINE_HEIGHT = extractVar( | 20 | | - 'comfortable-line-height-data' | 21 | | -); | 22 | | -export const COMPACT_LINE_HEIGHT = extractVar('compact-line-height-data'); | 23 | | - | 24 | 6 | export const TREE_OPERATION_ADD = 1; | 25 | 7 | export const TREE_OPERATION_REMOVE = 2; | 26 | 8 | export const TREE_OPERATION_REORDER_CHILDREN = 3; | @@ -45,3 +27,31 @@ export const PROFILER_EXPORT_VERSION = 4; | 45 | 27 |
| 46 | 28 | export const CHANGE_LOG_URL = | 47 | 29 | 'https://github.com/bvaughn/react-devtools-experimental/blob/master/CHANGELOG.md'; | | 30 | + | | 31 | +// HACK | | 32 | +// | | 33 | +// Extracting during build time avoids a temporarily invalid state for the inline target. | | 34 | +// Sometimes the inline target is rendered before root styles are applied, | | 35 | +// which would result in e.g. NaN itemSize being passed to react-window list. | | 36 | +// | | 37 | +// We can't use the Webpack loader syntax in the context of Jest though, | | 38 | +// so tests need some reasonably meaningful fallback value. | | 39 | +let COMFORTABLE_LINE_HEIGHT = 15; | | 40 | +let COMPACT_LINE_HEIGHT = 10; | | 41 | + | | 42 | +if (!__TEST__) { | | 43 | + // $FlowFixMe | | 44 | + const rawStyleString = require('!!raw-loader!src/devtools/views/root.css') // eslint-disable-line import/no-webpack-loader-syntax | | 45 | + .default; | | 46 | + | | 47 | + const extractVar = varName => { | | 48 | + const regExp = new RegExp(`${varName}: ([0-9]+)`); | | 49 | + const match = rawStyleString.match(regExp); | | 50 | + return parseInt(match[1], 10); | | 51 | + }; | | 52 | + | | 53 | + COMFORTABLE_LINE_HEIGHT = extractVar('comfortable-line-height-data'); | | 54 | + COMPACT_LINE_HEIGHT = extractVar('compact-line-height-data'); | | 55 | +} | | 56 | + | | 57 | +export { COMFORTABLE_LINE_HEIGHT, COMPACT_LINE_HEIGHT }; |
|