问题标签 [babeljs]

For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.

0 投票
0 回答
938 浏览

javascript - React.addons 有未定义的 TestUtils(使用 Webpack Mocha Karma Babel)

当我需要 React/addons 时,我不明白为什么未定义 TestUtils。

业力日志 - 在堆栈跟踪底部附近查找未定义。  gulp test:karma
[19:16:34] Using gulpfile ~/dev/react-starter/gulpfile.js [19:16:34] Starting 'test:karma'... DEBUG [config]: autoWatch set to false, because of singleRun DEBUG [plugin]: Loading inlined plugin (defining webpackPlugin, preprocessor:webpack). DEBUG [plugin]: Loading inlined plugin (defining framework:mocha). DEBUG [plugin]: Loading inlined plugin (defining launcher:Chrome, launcher:ChromeCanary, launcher:Dartium, test). DEBUG [plugin]: Loading inlined plugin (defining launcher:IE). DEBUG [plugin]: Loading inlined plugin (defining launcher:Firefox, launcher:FirefoxDeveloper, launcher:FirefoxAurora, launcher:FirefoxNightly). DEBUG [plugin]: Loading inlined plugin (defining launcher:PhantomJS). DEBUG [plugin]: Loading inlined plugin (defining preprocessor:sourcemap). INFO [karma]: Karma v0.12.31 server started at http://localhost:9876/ INFO [launcher]: Starting browser Chrome DEBUG [temp-dir]: Creating temp dir at /var/folders/85/c3khd5g15nq5yy8_1m0s40y00000gn/T/karma-32579705 DEBUG [launcher]: /Applications/Google Chrome.app/Contents/MacOS/Google Chrome --user-data-dir=/var/folders/85/c3khd5g15nq5yy8_1m0s40y00000gn/T/karma-32579705 --no-default-browser-check --no-first-run --disable-default-apps --disable-popup-blocking --disable-translate http://localhost:9876/?id=32579705 DEBUG [web-server]: serving: /Users/ivan/dev/react-starter/node_modules/karma/static/client.html DEBUG [web-server]: serving: /Users/ivan/dev/react-starter/node_modules/karma/static/karma.js DEBUG [web-server]: upgrade /socket.io/1/websocket/Yv-kuQa_TMT0ZHQtt4-A DEBUG [karma]: A browser has connected on socket Yv-kuQa_TMT0ZHQtt4-A INFO [Chrome 41.0.2272 (Mac OS X 10.10.2)]: Connected on socket Yv-kuQa_TMT0ZHQtt4-A with id 32579705 DEBUG [launcher]: Chrome (id 32579705) captured in 3.444 secs Hash: be6e75ac6e8a5e6d6ec9 Version: webpack 1.7.3 Time: 1270ms Asset Size Chunks Chunk Names main 605 kB 0 [emitted] main test/front-end/hello-spec.js 834 kB 1 [emitted] test/front-end/hello-spec.js bundle.js.map 1.02 MB 0, 1 [emitted] main, test/front-end/hello-spec.js chunk {0} main, bundle.js.map (main) 582 kB [0] ./client/js/main.js 357 bytes {0} [built] [1] ./client/js/components/HelloComponent.js 485 bytes {0} {1} [built] [2] ./~/react/react.js 41 bytes {0} {1} [built] [3] ./~/react/lib/React.js 4.78 kB {0} {1} [built] [4] ./~/react/lib/EventPluginUtils.js 6.75 kB {0} {1} [built] [5] ./~/react/lib/ReactChildren.js 4.74 kB {0} {1} [built] [6] ./~/react/lib/ReactComponent.js 4.54 kB {0} {1} [built] [7] ./~/react/lib/ReactClass.js 30 kB {0} {1} [built] [8] ./~/react/lib/ReactContext.js 1.97 kB {0} {1} [built] [9] ./~/react/lib/ReactCurrentOwner.js 738 bytes {0} {1} [built] [10] ./~/react/lib/ReactElement.js 8.27 kB {0} {1} [built] [11] ./~/react/lib/ReactElementValidator.js 14.1 kB {0} {1} [built] [12] ./~/react/lib/ReactDOM.js 3.26 kB {0} {1} [built] [13] ./~/react/lib/ReactDOMTextComponent.js 3.59 kB {0} {1} [built] [14] ./~/react/lib/ReactDefaultInjection.js 5.44 kB {0} {1} [built] [15] ./~/react/lib/ReactInstanceHandles.js 10.6 kB {0} {1} [built] [16] ./~/react/lib/ReactMount.js 31.2 kB {0} {1} [built] [17] ./~/react/lib/ReactPerf.js 2.55 kB {0} {1} [built] [18] ./~/react/lib/ReactPropTypes.js 11.1 kB {0} {1} [built] [19] ./~/react/lib/ReactReconciler.js 3.6 kB {0} {1} [built] [20] ./~/react/lib/ReactServerRendering.js 2.58 kB {0} {1} [built] [21] ./~/react/lib/Object.assign.js 1.26 kB {0} {1} [built] [22] ./~/react/lib/findDOMNode.js 2.4 kB {0} {1} [built] [23] ./~/react/lib/onlyChild.js 1.23 kB {0} {1} [built] [24] ./~/react/lib/EventConstants.js 1.56 kB {0} {1} [built] [25] ./~/react/lib/invariant.js 1.54 kB {0} {1} [built] [26] ./~/react/lib/PooledClass.js 3.27 kB {0} {1} [built] [27] ./~/react/lib/ReactFragment.js 5.74 kB {0} {1} [built] [28] ./~/react/lib/traverseAllChildren.js 7.54 kB {0} {1} [built] [29] ./~/react/lib/warning.js 1.9 kB {0} {1} [built] [30] ./~/react/lib/ReactUpdateQueue.js 9.95 kB {0} {1} [built] [31] ./~/react/lib/ReactErrorUtils.js 843 bytes {0} {1} [built] [32] ./~/react/lib/ReactInstanceMap.js 1.25 kB {0} {1} [built] [33] ./~/react/lib/ReactLifeCycle.js 1.25 kB {0} {1} [built] [34] ./~/react/lib/ReactPropTypeLocations.js 543 bytes {0} {1} [built] [35] ./~/react/lib/ReactPropTypeLocationNames.js 612 bytes {0} {1} [built] [36] ./~/react/lib/keyMirror.js 1.3 kB {0} {1} [built] [37] ./~/react/lib/keyOf.js 1.1 kB {0} {1} [built] [38] ./~/react/lib/emptyObject.js 483 bytes {0} {1} [built] [39] ./~/react/lib/ReactNativeComponent.js 3.22 kB {0} {1} [built] [40] ./~/react/lib/getIteratorFn.js 1.18 kB {0} {1} [built] [41] ./~/react/lib/mapObject.js 1.47 kB {0} {1} [built] [42] ./~/react/lib/DOMPropertyOperations.js 6.03 kB {0} {1} [built] [43] ./~/react/lib/ReactComponentBrowserEnvironment.js 1.29 kB {0} {1} [built] [44] ./~/react/lib/ReactDOMComponent.js 16.9 kB {0} {1} [built] [45] ./~/react/lib/escapeTextContentForBrowser.js 850 bytes {0} {1} [built] [46] ./~/react/lib/BeforeInputEventPlugin.js 15.1 kB {0} {1} [built] [47] ./~/react/lib/ChangeEventPlugin.js 11.5 kB {0} {1} [built] [48] ./~/react/lib/ClientReactRootIndex.js 551 bytes {0} {1} [built] [49] ./~/react/lib/DefaultEventPluginOrder.js 1.34 kB {0} {1} [built] [50] ./~/react/lib/EnterLeaveEventPlugin.js 3.86 kB {0} {1} [built] [51] ./~/react/lib/ExecutionEnvironment.js 1.13 kB {0} {1} [built] [52] ./~/react/lib/HTMLDOMPropertyConfig.js 6.35 kB {0} {1} [built] [53] ./~/react/lib/MobileSafariClickEventPlugin.js 1.72 kB {0} {1} [built] [54] ./~/react/lib/ReactBrowserComponentMixin.js 715 bytes {0} {1} [built] [55] ./~/react/lib/ReactDefaultBatchingStrategy.js 1.91 kB {0} {1} [built] [56] ./~/react/lib/ReactDOMButton.js 1.61 kB {0} {1} [built] [57] ./~/react/lib/ReactDOMForm.js 1.64 kB {0} {1} [built] [58] ./~/react/lib/ReactDOMImg.js 1.41 kB {0} {1} [built] [59] ./~/react/lib/ReactDOMIDOperations.js 5.49 kB {0} {1} [built] [60] ./~/react/lib/ReactDOMIframe.js 1.37 kB {0} {1} [built] [61] ./~/react/lib/ReactDOMInput.js 5.91 kB {0} {1} [built] [62] ./~/react/lib/ReactDOMOption.js 1.34 kB {0} {1} [built] [63] ./~/react/lib/ReactDOMSelect.js 5.21 kB {0} {1} [built] [64] ./~/react/lib/ReactDOMTextarea.js 4.71 kB {0} {1} [built] [65] ./~/react/lib/ReactEventListener.js 5.51 kB {0} {1} [built] [66] ./~/react/lib/ReactInjection.js 1.47 kB {0} {1} [built] [67] ./~/react/lib/ReactReconcileTransaction.js 4.92 kB {0} {1} [built] [68] ./~/react/lib/SelectEventPlugin.js 5.84 kB {0} {1} [built] [69] ./~/react/lib/ServerReactRootIndex.js 868 bytes {0} {1} [built] [70] ./~/react/lib/SimpleEventPlugin.js 12.5 kB {0} {1} [built] [71] ./~/react/lib/SVGDOMPropertyConfig.js 2.74 kB {0} {1} [built] [72] ./~/react/lib/createFullPageComponent.js 1.9 kB {0} {1} [built] [73] ./~/react/lib/ReactRootIndex.js 723 bytes {0} {1} [built] [74] ./~/react/lib/DOMProperty.js 10.2 kB {0} {1} [built] [75] ./~/react/lib/ReactBrowserEventEmitter.js 12.3 kB {0} {1} [built] [76] ./~/react/lib/ReactEmptyComponent.js 2.83 kB {0} {1} [built] [77] ./~/react/lib/ReactMarkupChecksum.js 1.32 kB {0} {1} [built] [78] ./~/react/lib/ReactUpdates.js 9.26 kB {0} {1} [built] [79] ./~/react/lib/containsNode.js 1.23 kB {0} {1} [built] [80] ./~/react/lib/getReactRootElementInContainer.js 888 bytes {0} {1} [built] [81] ./~/react/lib/instantiateReactComponent.js 4.54 kB {0} {1} [built] [82] ./~/react/lib/setInnerHTML.js 3.03 kB {0} {1} [built] [83] ./~/react/lib/shouldUpdateReactComponent.js 4.09 kB {0} {1} [built] [84] ./~/react/lib/emptyFunction.js 1.06 kB {0} {1} [built] [85] ./~/react/lib/ReactRef.js 2 kB {0} {1} [built] [86] ./~/react/lib/ReactServerRenderingTransaction.js 2.72 kB {0} {1} [built] [87] ./~/react/lib/isNode.js 718 bytes {0} {1} [built] [88] ./~/react/lib/quoteAttributeValueForBrowser.js 747 bytes {0} {1} [built] [89] ./~/react/lib/CSSPropertyOperations.js 5.31 kB {0} {1} [built] [90] ./~/react/lib/ReactMultiChild.js 12 kB {0} {1} [built] [91] ./~/react/lib/isEventSupported.js 1.98 kB {0} {1} [built] [92] ./~/react/lib/EventPropagators.js 4.65 kB {0} {1} [built] [93] ./~/react/lib/FallbackCompositionState.js 2.38 kB {0} {1} [built] [94] ./~/react/lib/SyntheticCompositionEvent.js 1.14 kB {0} {1} [built] [95] ./~/react/lib/SyntheticInputEvent.js 1.12 kB {0} {1} [built] [96] ./~/react/lib/EventPluginHub.js 8.23 kB {0} {1} [built] [97] ./~/react/lib/SyntheticEvent.js 4.85 kB {0} {1} [built] [98] ./~/react/lib/isTextInputElement.js 975 bytes {0} {1} [built] [99] ./~/react/lib/SyntheticMouseEvent.js 2.2 kB {0} {1} [built] [100] ./~/react/lib/Transaction.js 9.36 kB {0} {1} [built] [101] ./~/react/lib/AutoFocusMixin.js 595 bytes {0} {1} [built] [102] ./~/react/lib/LocalEventTrapMixin.js 1.74 kB {0} {1} [built] [103] ./~/react/lib/DOMChildrenOperations.js 4.51 kB {0} {1} [built] [104] ./~/react/lib/LinkedValueUtils.js 4.75 kB {0} {1} [built] [105] ./~/react/lib/EventListener.js 2.67 kB {0} {1} [built] [106] ./~/react/lib/getEventTarget.js 931 bytes {0} {1} [built] [107] ./~/react/lib/getUnboundedScrollPosition.js 1.09 kB {0} {1} [built] [108] ./~/react/lib/ReactComponentEnvironment.js 1.7 kB {0} {1} [built] [109] ./~/react/lib/CallbackQueue.js 2.47 kB {0} {1} [built] [110] ./~/react/lib/ReactInputSelection.js 4.25 kB {0} {1} [built] [111] ./~/react/lib/ReactPutListenerQueue.js 1.33 kB {0} {1} [built] [112] ./~/react/lib/getActiveElement.js 788 bytes {0} {1} [built] [113] ./~/react/lib/shallowEqual.js 1.1 kB {0} {1} [built] [114] ./~/react/lib/SyntheticClipboardEvent.js 1.22 kB {0} {1} [built] [115] ./~/react/lib/SyntheticFocusEvent.js 1.08 kB {0} {1} [built] [116] ./~/react/lib/SyntheticKeyboardEvent.js 2.72 kB {0} {1} [built] [117] ./~/react/lib/SyntheticDragEvent.js 1.09 kB {0} {1} [built] [118] ./~/react/lib/SyntheticTouchEvent.js 1.3 kB {0} {1} [built] [119] ./~/react/lib/SyntheticUIEvent.js 1.6 kB {0} {1} [built] [120] ./~/react/lib/SyntheticWheelEvent.js 1.99 kB {0} {1} [built] [121] ./~/react/lib/getEventCharCode.js 1.56 kB {0} {1} [built] [122] ./~/react/lib/EventPluginRegistry.js 8.92 kB {0} {1} [built] [123] ./~/react/lib/ReactEventEmitterMixin.js 1.32 kB {0} {1} [built] [124] ./~/react/lib/ViewportMetrics.js 638 bytes {0} {1} [built] [125] ./~/react/lib/adler32.js 885 bytes {0} {1} [built] [126] ./~/react/lib/isTextNode.js 614 bytes {0} {1} [built] [127] ./~/react/lib/ReactCompositeComponent.js 28.5 kB {0} {1} [built] [128] ./~/react/lib/ReactOwner.js 3.69 kB {0} {1} [built] [129] ./~/react/lib/CSSProperty.js 3.05 kB {0} {1} [built] [130] ./~/react/lib/camelizeStyleName.js 1.03 kB {0} {1} [built] [131] ./~/react/lib/dangerousStyleValue.js 1.93 kB {0} {1} [built] [132] ./~/react/lib/hyphenateStyleName.js 1.01 kB {0} {1} [built] [133] ./~/react/lib/memoizeStringOnly.js 778 bytes {0} {1} [built] [134] ./~/react/lib/ReactMultiChildUpdateTypes.js 835 bytes {0} {1} [built] [135] ./~/react/lib/ReactChildReconciler.js 4.17 kB {0} {1} [built] [136] ./~/react/lib/accumulateInto.js 1.74 kB {0} {1} [built] [137] ./~/react/lib/forEachAccumulated.js 889 bytes {0} {1} [built] [138] ./~/react/lib/getTextContentAccessor.js 1 kB {0} {1} [built] [139] ./~/react/lib/getEventModifierState.js 1.33 kB {0} {1} [built] [140] ./~/react/lib/focusNode.js 728 bytes {0} {1} [built] [141] ./~/react/lib/Danger.js 7.19 kB {0} {1} [built] [142] ./~/react/lib/setTextContent.js 1.19 kB {0} {1} [built] [143] ./~/react/lib/ReactDOMSelection.js 6.14 kB {0} {1} [built] [144] ./~/react/lib/getEventKey.js 2.93 kB {0} {1} [built] [145] ./~/react/lib/camelize.js 714 bytes {0} {1} [built] [146] ./~/react/lib/hyphenate.js 808 bytes {0} {1} [built] [147] ./~/react/lib/flattenChildren.js 1.68 kB {0} {1} [built] [148] ./~/react/lib/createNodesFromMarkup.js 2.69 kB {0} {1} [built] [149] ./~/react/lib/getMarkupWrap.js 3.12 kB {0} {1} [built] [150] ./~/react/lib/getNodeForCharacterOffset.js 1.66 kB {0} {1} [built] [151] ./~/react/lib/createArrayFromMixed.js 2.37 kB {0} {1} [built] [152] ./~/react/lib/toArray.js 2.08 kB {0} {1} [built] chunk {1} test/front-end/hello-spec.js, bundle.js.map (test/front-end/hello-spec.js) 799 kB [rendered] [0] ./test/front-end/hello-spec.js 1.06 kB {1} [built] [1] ./client/js/components/HelloComponent.js 485 bytes {0} {1} [built] [2] ./~/react/react.js 41 bytes {0} {1} [built] [3] ./~/react/lib/React.js 4.78 kB {0} {1} [built] [4] ./~/react/lib/EventPluginUtils.js 6.75 kB {0} {1} [built] [5] ./~/react/lib/ReactChildren.js 4.74 kB {0} {1} [built] [6] ./~/react/lib/ReactComponent.js 4.54 kB {0} {1} [built] [7] ./~/react/lib/ReactClass.js 30 kB {0} {1} [built] [8] ./~/react/lib/ReactContext.js 1.97 kB {0} {1} [built] [9] ./~/react/lib/ReactCurrentOwner.js 738 bytes {0} {1} [built] [10] ./~/react/lib/ReactElement.js 8.27 kB {0} {1} [built] [11] ./~/react/lib/ReactElementValidator.js 14.1 kB {0} {1} [built] [12] ./~/react/lib/ReactDOM.js 3.26 kB {0} {1} [built] [13] ./~/react/lib/ReactDOMTextComponent.js 3.59 kB {0} {1} [built] [14] ./~/react/lib/ReactDefaultInjection.js 5.44 kB {0} {1} [built] [15] ./~/react/lib/ReactInstanceHandles.js 10.6 kB {0} {1} [built] [16] ./~/react/lib/ReactMount.js 31.2 kB {0} {1} [built] [17] ./~/react/lib/ReactPerf.js 2.55 kB {0} {1} [built] [18] ./~/react/lib/ReactPropTypes.js 11.1 kB {0} {1} [built] [19] ./~/react/lib/ReactReconciler.js 3.6 kB {0} {1} [built] [20] ./~/react/lib/ReactServerRendering.js 2.58 kB {0} {1} [built] [21] ./~/react/lib/Object.assign.js 1.26 kB {0} {1} [built] [22] ./~/react/lib/findDOMNode.js 2.4 kB {0} {1} [built] [23] ./~/react/lib/onlyChild.js 1.23 kB {0} {1} [built] [24] ./~/react/lib/EventConstants.js 1.56 kB {0} {1} [built] [25] ./~/react/lib/invariant.js 1.54 kB {0} {1} [built] [26] ./~/react/lib/PooledClass.js 3.27 kB {0} {1} [built] [27] ./~/react/lib/ReactFragment.js 5.74 kB {0} {1} [built] [28] ./~/react/lib/traverseAllChildren.js 7.54 kB {0} {1} [built] [29] ./~/react/lib/warning.js 1.9 kB {0} {1} [built] [30] ./~/react/lib/ReactUpdateQueue.js 9.95 kB {0} {1} [built] [31] ./~/react/lib/ReactErrorUtils.js 843 bytes {0} {1} [built] [32] ./~/react/lib/ReactInstanceMap.js 1.25 kB {0} {1} [built] [33] ./~/react/lib/ReactLifeCycle.js 1.25 kB {0} {1} [built] [34] ./~/react/lib/ReactPropTypeLocations.js 543 bytes {0} {1} [built] [35] ./~/react/lib/ReactPropTypeLocationNames.js 612 bytes {0} {1} [built] [36] ./~/react/lib/keyMirror.js 1.3 kB {0} {1} [built] [37] ./~/react/lib/keyOf.js 1.1 kB {0} {1} [built] [38] ./~/react/lib/emptyObject.js 483 bytes {0} {1} [built] [39] ./~/react/lib/ReactNativeComponent.js 3.22 kB {0} {1} [built] [40] ./~/react/lib/getIteratorFn.js 1.18 kB {0} {1} [built] [41] ./~/react/lib/mapObject.js 1.47 kB {0} {1} [built] [42] ./~/react/lib/DOMPropertyOperations.js 6.03 kB {0} {1} [built] [43] ./~/react/lib/ReactComponentBrowserEnvironment.js 1.29 kB {0} {1} [built] [44] ./~/react/lib/ReactDOMComponent.js 16.9 kB {0} {1} [built] [45] ./~/react/lib/escapeTextContentForBrowser.js 850 bytes {0} {1} [built] [46] ./~/react/lib/BeforeInputEventPlugin.js 15.1 kB {0} {1} [built] [47] ./~/react/lib/ChangeEventPlugin.js 11.5 kB {0} {1} [built] [48] ./~/react/lib/ClientReactRootIndex.js 551 bytes {0} {1} [built] [49] ./~/react/lib/DefaultEventPluginOrder.js 1.34 kB {0} {1} [built] [50] ./~/react/lib/EnterLeaveEventPlugin.js 3.86 kB {0} {1} [built] [51] ./~/react/lib/ExecutionEnvironment.js 1.13 kB {0} {1} [built] [52] ./~/react/lib/HTMLDOMPropertyConfig.js 6.35 kB {0} {1} [built] [53] ./~/react/lib/MobileSafariClickEventPlugin.js 1.72 kB {0} {1} [built] [54] ./~/react/lib/ReactBrowserComponentMixin.js 715 bytes {0} {1} [built] [55] ./~/react/lib/ReactDefaultBatchingStrategy.js 1.91 kB {0} {1} [built] [56] ./~/react/lib/ReactDOMButton.js 1.61 kB {0} {1} [built] [57] ./~/react/lib/ReactDOMForm.js 1.64 kB {0} {1} [built] [58] ./~/react/lib/ReactDOMImg.js 1.41 kB {0} {1} [built] [59] ./~/react/lib/ReactDOMIDOperations.js 5.49 kB {0} {1} [built] [60] ./~/react/lib/ReactDOMIframe.js 1.37 kB {0} {1} [built] [61] ./~/react/lib/ReactDOMInput.js 5.91 kB {0} {1} [built] [62] ./~/react/lib/ReactDOMOption.js 1.34 kB {0} {1} [built] [63] ./~/react/lib/ReactDOMSelect.js 5.21 kB {0} {1} [built] [64] ./~/react/lib/ReactDOMTextarea.js 4.71 kB {0} {1} [built] [65] ./~/react/lib/ReactEventListener.js 5.51 kB {0} {1} [built] [66] ./~/react/lib/ReactInjection.js 1.47 kB {0} {1} [built] [67] ./~/react/lib/ReactReconcileTransaction.js 4.92 kB {0} {1} [built] [68] ./~/react/lib/SelectEventPlugin.js 5.84 kB {0} {1} [built] [69] ./~/react/lib/ServerReactRootIndex.js 868 bytes {0} {1} [built] [70] ./~/react/lib/SimpleEventPlugin.js 12.5 kB {0} {1} [built] [71] ./~/react/lib/SVGDOMPropertyConfig.js 2.74 kB {0} {1} [built] [72] ./~/react/lib/createFullPageComponent.js 1.9 kB {0} {1} [built] [73] ./~/react/lib/ReactRootIndex.js 723 bytes {0} {1} [built] [74] ./~/react/lib/DOMProperty.js 10.2 kB {0} {1} [built] [75] ./~/react/lib/ReactBrowserEventEmitter.js 12.3 kB {0} {1} [built] [76] ./~/react/lib/ReactEmptyComponent.js 2.83 kB {0} {1} [built] [77] ./~/react/lib/ReactMarkupChecksum.js 1.32 kB {0} {1} [built] [78] ./~/react/lib/ReactUpdates.js 9.26 kB {0} {1} [built] [79] ./~/react/lib/containsNode.js 1.23 kB {0} {1} [built] [80] ./~/react/lib/getReactRootElementInContainer.js 888 bytes {0} {1} [built] [81] ./~/react/lib/instantiateReactComponent.js 4.54 kB {0} {1} [built] [82] ./~/react/lib/setInnerHTML.js 3.03 kB {0} {1} [built] [83] ./~/react/lib/shouldUpdateReactComponent.js 4.09 kB {0} {1} [built] [84] ./~/react/lib/emptyFunction.js 1.06 kB {0} {1} [built] [85] ./~/react/lib/ReactRef.js 2 kB {0} {1} [built] [86] ./~/react/lib/ReactServerRenderingTransaction.js 2.72 kB {0} {1} [built] [87] ./~/react/lib/isNode.js 718 bytes {0} {1} [built] [88] ./~/react/lib/quoteAttributeValueForBrowser.js 747 bytes {0} {1} [built] [89] ./~/react/lib/CSSPropertyOperations.js 5.31 kB {0} {1} [built] [90] ./~/react/lib/ReactMultiChild.js 12 kB {0} {1} [built] [91] ./~/react/lib/isEventSupported.js 1.98 kB {0} {1} [built] [92] ./~/react/lib/EventPropagators.js 4.65 kB {0} {1} [built] [93] ./~/react/lib/FallbackCompositionState.js 2.38 kB {0} {1} [built] [94] ./~/react/lib/SyntheticCompositionEvent.js 1.14 kB {0} {1} [built] [95] ./~/react/lib/SyntheticInputEvent.js 1.12 kB {0} {1} [built] [96] ./~/react/lib/EventPluginHub.js 8.23 kB {0} {1} [built] [97] ./~/react/lib/SyntheticEvent.js 4.85 kB {0} {1} [built] [98] ./~/react/lib/isTextInputElement.js 975 bytes {0} {1} [built] [99] ./~/react/lib/SyntheticMouseEvent.js 2.2 kB {0} {1} [built] [100] ./~/react/lib/Transaction.js 9.36 kB {0} {1} [built] [101] ./~/react/lib/AutoFocusMixin.js 595 bytes {0} {1} [built] [102] ./~/react/lib/LocalEventTrapMixin.js 1.74 kB {0} {1} [built] [103] ./~/react/lib/DOMChildrenOperations.js 4.51 kB {0} {1} [built] [104] ./~/react/lib/LinkedValueUtils.js 4.75 kB {0} {1} [built] [105] ./~/react/lib/EventListener.js 2.67 kB {0} {1} [built] [106] ./~/react/lib/getEventTarget.js 931 bytes {0} {1} [built] [107] ./~/react/lib/getUnboundedScrollPosition.js 1.09 kB {0} {1} [built] [108] ./~/react/lib/ReactComponentEnvironment.js 1.7 kB {0} {1} [built] [109] ./~/react/lib/CallbackQueue.js 2.47 kB {0} {1} [built] [110] ./~/react/lib/ReactInputSelection.js 4.25 kB {0} {1} [built] [111] ./~/react/lib/ReactPutListenerQueue.js 1.33 kB {0} {1} [built] [112] ./~/react/lib/getActiveElement.js 788 bytes {0} {1} [built] [113] ./~/react/lib/shallowEqual.js 1.1 kB {0} {1} [built] [114] ./~/react/lib/SyntheticClipboardEvent.js 1.22 kB {0} {1} [built] [115] ./~/react/lib/SyntheticFocusEvent.js 1.08 kB {0} {1} [built] [116] ./~/react/lib/SyntheticKeyboardEvent.js 2.72 kB {0} {1} [built] [117] ./~/react/lib/SyntheticDragEvent.js 1.09 kB {0} {1} [built] [118] ./~/react/lib/SyntheticTouchEvent.js 1.3 kB {0} {1} [built] [119] ./~/react/lib/SyntheticUIEvent.js 1.6 kB {0} {1} [built] [120] ./~/react/lib/SyntheticWheelEvent.js 1.99 kB {0} {1} [built] [121] ./~/react/lib/getEventCharCode.js 1.56 kB {0} {1} [built] [122] ./~/react/lib/EventPluginRegistry.js 8.92 kB {0} {1} [built] [123] ./~/react/lib/ReactEventEmitterMixin.js 1.32 kB {0} {1} [built] [124] ./~/react/lib/ViewportMetrics.js 638 bytes {0} {1} [built] [125] ./~/react/lib/adler32.js 885 bytes {0} {1} [built] [126] ./~/react/lib/isTextNode.js 614 bytes {0} {1} [built] [127] ./~/react/lib/ReactCompositeComponent.js 28.5 kB {0} {1} [built] [128] ./~/react/lib/ReactOwner.js 3.69 kB {0} {1} [built] [129] ./~/react/lib/CSSProperty.js 3.05 kB {0} {1} [built] [130] ./~/react/lib/camelizeStyleName.js 1.03 kB {0} {1} [built] [131] ./~/react/lib/dangerousStyleValue.js 1.93 kB {0} {1} [built] [132] ./~/react/lib/hyphenateStyleName.js 1.01 kB {0} {1} [built] [133] ./~/react/lib/memoizeStringOnly.js 778 bytes {0} {1} [built] [134] ./~/react/lib/ReactMultiChildUpdateTypes.js 835 bytes {0} {1} [built] [135] ./~/react/lib/ReactChildReconciler.js 4.17 kB {0} {1} [built] [136] ./~/react/lib/accumulateInto.js 1.74 kB {0} {1} [built] [137] ./~/react/lib/forEachAccumulated.js 889 bytes {0} {1} [built] [138] ./~/react/lib/getTextContentAccessor.js 1 kB {0} {1} [built] [139] ./~/react/lib/getEventModifierState.js 1.33 kB {0} {1} [built] [140] ./~/react/lib/focusNode.js 728 bytes {0} {1} [built] [141] ./~/react/lib/Danger.js 7.19 kB {0} {1} [built] [142] ./~/react/lib/setTextContent.js 1.19 kB {0} {1} [built] [143] ./~/react/lib/ReactDOMSelection.js 6.14 kB {0} {1} [built] [144] ./~/react/lib/getEventKey.js 2.93 kB {0} {1} [built] [145] ./~/react/lib/camelize.js 714 bytes {0} {1} [built] [146] ./~/react/lib/hyphenate.js 808 bytes {0} {1} [built] [147] ./~/react/lib/flattenChildren.js 1.68 kB {0} {1} [built] [148] ./~/react/lib/createNodesFromMarkup.js 2.69 kB {0} {1} [built] [149] ./~/react/lib/getMarkupWrap.js 3.12 kB {0} {1} [built] [150] ./~/react/lib/getNodeForCharacterOffset.js 1.66 kB {0} {1} [built] [151] ./~/react/lib/createArrayFromMixed.js 2.37 kB {0} {1} [built] [152] ./~/react/lib/toArray.js 2.08 kB {0} {1} [built] [153] ./~/react/addons.js 51 bytes {1} [built] [154] ./~/chai/index.js 40 bytes {1} [built] [155] ./~/react/lib/ReactWithAddons.js 1.69 kB {1} [built] [156] ./~/chai/lib/chai.js 1.28 kB {1} [built] [157] ./~/react/lib/LinkedStateMixin.js 1.17 kB {1} [built] [158] ./~/react/lib/ReactComponentWithPureRenderMixin.js 1.55 kB {1} [built] [159] ./~/react/lib/ReactCSSTransitionGroup.js 1.73 kB {1} [built] [160] ./~/react/lib/ReactTransitionGroup.js 6.3 kB {1} [built] [161] ./~/react/lib/cx.js 1.75 kB {1} [built] [162] ./~/react/lib/cloneWithProps.js 1.82 kB {1} [built] [163] ./~/react/lib/update.js 5.07 kB {1} [built] [164] ./~/chai/lib/chai/config.js 1.46 kB {1} [built] [165] ./~/chai/lib/chai/assertion.js 3.79 kB {1} [built] [166] ./~/chai/lib/chai/core/assertions.js 41.8 kB {1} [built] [167] ./~/chai/lib/chai/interface/expect.js 747 bytes {1} [built] [168] ./~/chai/lib/chai/interface/should.js 2.69 kB {1} [built] [169] ./~/chai/lib/chai/interface/assert.js 31.5 kB {1} [built] [170] ./~/chai/lib/chai/utils/index.js 1.62 kB {1} [built] [171] ./~/react/lib/ReactLink.js 2.03 kB {1} [built] [172] ./~/react/lib/ReactStateSetters.js 3.67 kB {1} [built] [173] ./~/react/lib/ReactCSSTransitionGroupChild.js 3.8 kB {1} [built] [174] ./~/react/lib/ReactTransitionChildMapping.js 3.27 kB {1} [built] [175] ./~/react/lib/ReactPropTransferer.js 3 kB {1} [built] [176] ./~/chai/~/assertion-error/index.js 2.34 kB {1} [built] [177] ./~/chai/lib/chai/utils/test.js 500 bytes {1} [built] [178] ./~/chai/lib/chai/utils/type.js 1.09 kB {1} [built] [179] ./~/chai/lib/chai/utils/getMessage.js 1.3 kB {1} [built] [180] ./~/chai/lib/chai/utils/getActual.js 415 bytes {1} [built] [181] ./~/chai/lib/chai/utils/inspect.js 9.82 kB {1} [built] [182] ./~/chai/lib/chai/utils/objDisplay.js 1.2 kB {1} [built] [183] ./~/chai/lib/chai/utils/flag.js 787 bytes {1} [built] [184] ./~/chai/lib/chai/utils/transferFlags.js 1.29 kB {1} [built] [185] ./~/chai/lib/chai/utils/getPathValue.js 1.01 kB {1} [built] [186] ./~/chai/lib/chai/utils/getPathInfo.js 2.69 kB {1} [built] [187] ./~/chai/lib/chai/utils/hasProperty.js 1.51 kB {1} [built] [188] ./~/chai/lib/chai/utils/getName.js 429 bytes {1} [built] [189] ./~/chai/lib/chai/utils/addProperty.js 1.04 kB {1} [built] [190] ./~/chai/lib/chai/utils/addMethod.js 1.16 kB {1} [built] [191] ./~/chai/lib/chai/utils/overwriteProperty.js 1.51 kB {1} [built] [192] ./~/chai/lib/chai/utils/overwriteMethod.js 1.43 kB {1} [built] [193] ./~/chai/lib/chai/utils/addChainableMethod.js 3.6 kB {1} [built] [194] ./~/chai/lib/chai/utils/overwriteChainableMethod.js 1.71 kB {1} [built] [195] ./~/react/lib/CSSCore.js 3.66 kB {1} [built] [196] ./~/react/lib/ReactTransitionEvents.js 3.14 kB {1} [built] [197] ./~/react/lib/joinClasses.js 941 bytes {1} [built] [198] ./~/chai/~/deep-eql/index.js 39 bytes {1} [built] [199] ./~/chai/lib/chai/utils/getProperties.js 771 bytes {1} [built] [200] ./~/chai/lib/chai/utils/getEnumerableProperties.js 527 bytes {1} [built] [201] ./~/chai/~/deep-eql/lib/eql.js 4.87 kB {1} [built] [202] (webpack)/~/node-libs-browser/~/buffer/index.js 36.7 kB {1} [built] [203] ./~/chai/~/deep-eql/~/type-detect/index.js 40 bytes {1} [built] [204] ./~/chai/~/deep-eql/~/type-detect/lib/type.js 2.75 kB {1} [built] [205] (webpack)/~/node-libs-browser/~/buffer/~/ieee754/index.js 2.09 kB {1} [built] [206] (webpack)/~/node-libs-browser/~/buffer/~/is-array/index.js 470 bytes {1} [built] [207] (webpack)/~/node-libs-browser/~/buffer/~/base64-js/lib/b64.js 3.57 kB {1} [built] webpack: bundle is now VALID. DEBUG [watcher]: Resolved files: /Users/ivan/dev/react-starter/node_modules/mocha/mocha.js /Users/ivan/dev/react-starter/node_modules/karma-mocha/lib/adapter.js /Users/ivan/dev/react-starter/test/front-end/hello-spec.js webpack: bundle is now INVALID. DEBUG [web-server]: serving: /Users/ivan/dev/react-starter/node_modules/karma/static/context.html DEBUG [web-server]: serving (cached): /Users/ivan/dev/react-starter/node_modules/mocha/mocha.js DEBUG [web-server]: serving (cached): /Users/ivan/dev/react-starter/node_modules/karma-mocha/lib/adapter.js DEBUG [web-server]: serving (cached): /Users/ivan/dev/react-starter/test/front-end/hello-spec.js LOG: 'test is ok' LOG: 'log Object.keys(React.addons)', ['CSSTransitionGroup', 'LinkedStateMixin', 'PureRenderMixin', 'TransitionGroup', 'batchedUpdates', 'classSet', 'cloneWithProps', 'createFragment', 'update'] Chrome 41.0.2272 (Mac OS X 10.10.2) HelloComponent says hello in a class of hello FAILED TypeError: Cannot read property 'renderIntoDocument' of undefined at Context.<anonymous> (/Users/ivan/dev/react-starter/test/front-end/hello-spec.js:76:27) Chrome 41.0.2272 (Mac OS X 10.10.2): Executed 3 of 3 (1 FAILED) (0.013 secs / 0.002 secs) DEBUG [karma]: Run complete, exiting. DEBUG [launcher]: Disconnecting all browsers DEBUG [launcher]: Process Chrome exited with code 0 DEBUG [temp-dir]: Cleaning temp dir /var/folders/85/c3khd5g15nq5yy8_1m0s40y00000gn/T/karma-32579705 [19:16:39] 'test:karma' errored after 4.76 s [19:16:39] Error: 1 at formatError (/Users/ivan/.nvm/v0.10.38/lib/node_modules/gulp/bin/gulp.js:169:10) at Gulp.<anonymous> (/Users/ivan/.nvm/v0.10.38/lib/node_modules/gulp/bin/gulp.js:195:15) at Gulp.emit (events.js:95:17) at Gulp.Orchestrator._emitTaskDone (/Users/ivan/dev/react-starter/node_modules/gulp/node_modules/orchestrator/index.js:264:8) at /Users/ivan/dev/react-starter/node_modules/gulp/node_modules/orchestrator/index.js:275:23 at finish (/Users/ivan/dev/react-starter/node_modules/gulp/node_modules/orchestrator/lib/runTask.js:21:8) at cb (/Users/ivan/dev/react-starter/node_modules/gulp/node_modules/orchestrator/lib/runTask.js:29:3) at removeAllListeners (/Users/ivan/dev/react-starter/node_modules/karma/lib/server.js:220:7) at Server.<anonymous> (/Users/ivan/dev/react-starter/node_modules/karma/lib/server.js:231:9) at Server.g (events.js:180:16)

该代码可在此处获得:

这个输出可以用npm install && gulp test:karma

0 投票
3 回答
20478 浏览

webpack - 如何在不使用 watch 功能的情况下提高 webpack / babel 构建性能?

我正在开发一个 SBT/Scala Web 项目,我想利用 ES6 功能和前端 JavaScript 层的新模块语法。SBT 有自己的构建系统,我设法调整现有的 sbt 插件来运行 webpack 以使用 babel 构建我的 JS 文件。当前的解决方案有点混乱,但它可以在 sbt 构建系统中工作并存在。

问题是它很慢。每次更改都会创建一个新的 webpack 实例,它会从头开始编译所有内容。

我知道我可以跳出 sbt 构建系统,只在开发阶段单独使用 webpack 来观察和重建我的文件。但在我这样做之前,我想知道是否有一些方法可以加快 webpack 构建过程。

我检查了文档,在我看来,任何可用的缓存都只在内存中处理,这不适用于我的情况。或者是否有某种文件缓存可以在 webpack 构建的单独运行之间存在?例如,我所有的 npm 依赖项大部分时间都不会更改,因此它们可以编译一次,缓存然后简单地包含...

0 投票
1 回答
1133 浏览

babeljs - Babel & JSX 浏览器代码高亮

我使用https://highlightjs.org/作为浏览器内(以及静态网站生成器)来突出显示博客和网站的代码片段。我几乎可以肯定它不处理 ES6、ES7、JSX 和 Flow。

我怎样才能更好地突出显示这些新添加的 javascript?

请指教。谢谢 :)

0 投票
1 回答
3742 浏览

javascript - 用 babel 和 browserify 咕噜咕噜

我有一个简单的 JavaScript 项目,它使用 Babel 将 ECMAScript 6 转换为 ES5,然后需要 Browserify 来利用 ES6 的模块。

因此,我想出了这个Gruntfile.js来编译它:

grunt运行良好,没有任何错误。但是,我收到以下错误:

Uncaught SyntaxError: Unexpected reserved wordexport Uncaught SyntaxError: Unexpected reserved wordimport

基本上我在主文件中所做的如下:

然后像这样导入它:

我正在根据 ECMAScript 6 编写所有代码。但是,导出/导入似乎不起作用,而是与 JavaScript 保留字冲突(尽管我有browserify.js工作)。

0 投票
1 回答
4899 浏览

javascript - (为什么)我不能从生成器中抛出异常吗?

我试图从 ES6 生成器函数的主体中抛出异常,但它没有通过。这是 ES6 规范的一部分还是 Babel 的怪癖?

这是我尝试过的代码(在 babeljs.io 上):

如果这确实是指定的 ES6 行为,那么发出异常信号的另一种方法是什么?

0 投票
1 回答
1800 浏览

javascript - Webpack 将代码拆分为通过 npm 包含的单独模块,如何编译 es6?

我正在尝试编写一个可以在运行时使用 webpack 动态加载的模块化组件系统。例如,当用户切换选项卡时,显示新选项卡内容的代码应该仅在用户单击该选项卡时加载。

这是完成此操作的一些代码(非常好,我可能会添加):

我已经完成了这项工作,但有一个警告。我正在使用 ES6 和 babel-loader 来加载它。包含选项卡的功能、模板、样式等的模块都必须直接包含在应用程序的目录结构中,如下所示(参见:page_components 目录):

我希望每个页面组件都是它自己的包,带有 package.json,并通过例如: 包含在内require("individial_activity"),用于代码组织。

问题是,webpack 似乎没有node_modules通过任何加载器运行外部模块(例如通过 包含的模块),因此我在尝试加载 ES6 代码时收到有关意外符号的错误。

我尝试了and之类的东西require("babel-loader!individual_activity")require("babel-loader!individual_activity/path/to/main.js")但无济于事。

我正在尝试做的事情不是正常的做事方式吗?我应该将所有模块的所有代码保存在同一目录结构中吗?我在做一些公然错误的事情吗?

webpack.config.js:

谢谢!

0 投票
1 回答
1603 浏览

reactjs - 这在 Babel 编译的方法中是未定义的

我正在尝试使用 React 0.13 和 ES6 语法编写一个小型 webapp。我正在使用 webpack 和 babel-loader 进行编译:

我在方法中使用 this 变量时遇到问题,在我的代码中的多个地方都出现“这是未定义的”。例如:

在这种情况下,永远不应未定义this变量。但是,我发现问题可能出在 Babel 重写代码的方式上:

这样,在我看来,this变量是指对象文字而不是class。我怎样才能解决这个问题?

0 投票
1 回答
5215 浏览

promise - 在 ES6 中扩展 Promise

我正在尝试扩展 Promise:

然后在派生类上调用static resolve,直接创建resolved promise:

在 traceur 中,这会产生:

在 Babel (run as babel-node --experimental promise.js) 中,它会导致:

我依赖于这个:

Promise 的所有静态方法都支持子类化:它们通过接收器创建新实例(想想:new this(...))并通过它访问其他静态方法(this.resolve(...) 与 Promise.resolve(.. .))。

来自http://www.2ality.com/2014/10/es6-promises-api.html

似乎节点检查thison 调用,例如Promise.resolve.call(this, val)是 a Promise,而不是(正确?)Promise 或其派生类(v0.12.0)。

以上是否不再有效,或者没有纳入规范,或者只是没有由 traceur 和/或节点实现?

0 投票
1 回答
4648 浏览

javascript - 使用 babel.js 代替 browserify 编译成 bundle

我从babel.js开始使用 JavaScript ES6 功能,但是我遇到了问题

我目前正在使用 browserify 构建我的应用程序,并使用以下命令进行反应。

现在我想在 babel 中使用一个等效的命令来捆绑我需要的模块,用 ES6 编写到bundle.js中。这不起作用,只是给我一个 ES5 版本的 main.js 文件。

但是我可以使用 babel 将我的 bundle.js 文件编译为 ES6 版本,有 2 个命令

这是将 babel 与 browserify 一起使用的正确方法吗?将您的模块与 browserify 捆绑,然后将捆绑包转换为 ES6?

0 投票
3 回答
3123 浏览

javascript - 尝试将类导出为模块 ES6 babel

我有一个 ES6 类,我试图将其导出为模块,但是我收到错误SyntaxError: Unexpected reserved word

汽车.js

我正在尝试像这样使用 Car 模块

main.js

我正在使用带有 babelify 的 browserify 转换为 ES6

我是否正确导出了 Car 模块,还是我做错了什么?