GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Fixed raw-loader + Jest problem · react/react@8001b64

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • .eslintrc
  • flow.js
  • packages
    • react-devtools-core
      • webpack.backend.js
      • webpack.standalone.js
    • react-devtools-inline
      • webpack.config.js
  • shells
    • browser/shared
      • webpack.backend.js
      • webpack.config.js
    • dev
      • webpack.config.js
  • src
    • __tests__
      • setupEnv.js
    • constants.js
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎.eslintrc‎

Copy file name to clipboardExpand all lines: .eslintrc
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
},
1313
"globals": {
1414
"__DEV__": "readonly",
15+
"__TEST__": "readonly",
1516
"jasmine": "readonly",
1617
"spyOn": "readonly"
1718
}
Collapse file

‎flow.js‎

Copy file name to clipboardExpand all lines: flow.js
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ declare module 'events' {
1818
}
1919

2020
declare var __DEV__: boolean;
21+
declare var __TEST__: boolean;
2122

2223
declare var jasmine: {|
2324
getEnv: () => {|
Collapse file

‎packages/react-devtools-core/webpack.backend.js‎

Copy file name to clipboardExpand all lines: packages/react-devtools-core/webpack.backend.js
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ module.exports = {
3535
plugins: [
3636
new DefinePlugin({
3737
__DEV__: true,
38+
__TEST__: false,
3839
'process.env.DEVTOOLS_VERSION': `"${DEVTOOLS_VERSION}"`,
3940
'process.env.GITHUB_URL': `"${GITHUB_URL}"`,
4041
}),
Collapse file

‎packages/react-devtools-core/webpack.standalone.js‎

Copy file name to clipboardExpand all lines: packages/react-devtools-core/webpack.standalone.js
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ module.exports = {
3434
plugins: [
3535
new DefinePlugin({
3636
__DEV__: false,
37+
__TEST__: false,
3738
'process.env.DEVTOOLS_VERSION': `"${DEVTOOLS_VERSION}"`,
3839
'process.env.GITHUB_URL': `"${GITHUB_URL}"`,
3940
'process.env.NODE_ENV': `"${NODE_ENV}"`,
Collapse file

‎packages/react-devtools-inline/webpack.config.js‎

Copy file name to clipboardExpand all lines: packages/react-devtools-inline/webpack.config.js
+2-1Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,8 @@ module.exports = {
3838
},
3939
plugins: [
4040
new DefinePlugin({
41-
__DEV__: __DEV__,
41+
__DEV__,
42+
__TEST__: false,
4243
'process.env.DEVTOOLS_VERSION': `"${DEVTOOLS_VERSION}"`,
4344
'process.env.GITHUB_URL': `"${GITHUB_URL}"`,
4445
'process.env.NODE_ENV': `"${NODE_ENV}"`,
Collapse file

‎shells/browser/shared/webpack.backend.js‎

Copy file name to clipboardExpand all lines: shells/browser/shared/webpack.backend.js
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ module.exports = {
3131
plugins: [
3232
new DefinePlugin({
3333
__DEV__: true,
34+
__TEST__: false,
3435
'process.env.DEVTOOLS_VERSION': `"${DEVTOOLS_VERSION}"`,
3536
'process.env.GITHUB_URL': `"${GITHUB_URL}"`,
3637
}),
Collapse file

‎shells/browser/shared/webpack.config.js‎

Copy file name to clipboardExpand all lines: shells/browser/shared/webpack.config.js
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ module.exports = {
3636
plugins: [
3737
new DefinePlugin({
3838
__DEV__: false,
39+
__TEST__: false,
3940
'process.env.DEVTOOLS_VERSION': `"${DEVTOOLS_VERSION}"`,
4041
'process.env.GITHUB_URL': `"${GITHUB_URL}"`,
4142
'process.env.NODE_ENV': `"${NODE_ENV}"`,
Collapse file

‎shells/dev/webpack.config.js‎

Copy file name to clipboardExpand all lines: shells/dev/webpack.config.js
+2-1Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,8 @@ const config = {
3939
},
4040
plugins: [
4141
new DefinePlugin({
42-
__DEV__: __DEV__,
42+
__DEV__,
43+
__TEST__: false,
4344
'process.env.GITHUB_URL': `"${GITHUB_URL}"`,
4445
'process.env.DEVTOOLS_VERSION': `"${DEVTOOLS_VERSION}"`,
4546
}),
Collapse file

‎src/__tests__/setupEnv.js‎

Copy file name to clipboardExpand all lines: src/__tests__/setupEnv.js
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,4 @@ if (!global.hasOwnProperty('localStorage')) {
1212

1313
// Mimic the global we set with Webpack's DefinePlugin
1414
global.__DEV__ = process.env.NODE_ENV !== 'production';
15+
global.__TEST__ = process.env.NODE_ENV === 'test';
Collapse file

‎src/constants.js‎

Copy file name to clipboard
+28-18Lines changed: 28 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,8 @@
11
// @flow
22

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-
63
// Flip this flag to true to enable verbose console debug logging.
74
export const __DEBUG__ = false;
85

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-
246
export const TREE_OPERATION_ADD = 1;
257
export const TREE_OPERATION_REMOVE = 2;
268
export const TREE_OPERATION_REORDER_CHILDREN = 3;
@@ -45,3 +27,31 @@ export const PROFILER_EXPORT_VERSION = 4;
4527

4628
export const CHANGE_LOG_URL =
4729
'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 };

0 commit comments

Comments
0 (0)
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.