我遇到了以下非常奇怪的构建问题,这些问题似乎无法在我正在构建的gatsby插件中找到:https://github.com/flockcover/gatsby-plugin-branch-web-sdk。奇怪的是,当我在plugins目录下有完全相同的插件,而不是通过npm进行供应时,构建就可以了
141 | var REACT_CONTEXT_TYPE = hasSymbol ? Symbol.for('react.context') : 0xeace;
142 | var REACT_ASYNC_MODE_TYPE = hasSymbol ? Symbol.for('react.async_mode') : 0xeacf;
> 143 | var REACT_FORWARD_REF_TYPE = hasSymbol ? Symbol.for('react.forward_ref') : 0xead0;
| ^
144 |
145 | // A reserved attribute.
146 | // It is handled by React separately and shouldn't be written to the DOM.
WebpackError:
- react-dom-server.node.development.js?5336:143 Parser.pp$4.raise
~/react-dom/cjs/react-dom-server.node.development.js?5336:143:1
- react.development.js?1871:438 Parser.pp.unexpected
~/react/cjs/react.development.js?1871:438:1
- emptyObject.js?42e4:11 Parser.pp$3.parseExprAtom
~/fbjs/lib/emptyObject.js?42e4:11:1
- index.js?2927:58 Parser.pp$3.parseExprSubscripts
~/object-assign/index.js?2927:58:1
- react.development.js?1871:1455 Parser.pp$3.parseMaybeConditional
~/react/cjs/react.development.js?1871:1455:1
- react.development.js?1871:1432 Parser.pp$3.parseMaybeAssign
~/react/cjs/react.development.js?1871:1432:1
- invariant.js?4599:48 Parser.pp$3.parseExprAtom
~/fbjs/lib/invariant.js?4599:48:27
- index.js?2927:58 Parser.pp$3.parseExprSubscripts
~/object-assign/index.js?2927:58:1
- react.development.js?1871:1455 Parser.pp$3.parseMaybeConditional
~/react/cjs/react.development.js?1871:1455:1
- react.development.js?1871:1432 Parser.pp$3.parseMaybeAssign
~/react/cjs/react.development.js?1871:1432:1
```
gatsby clipboard:
```
System:
OS: macOS High Sierra 10.13.4
CPU: x64 Intel(R) Core(TM) i7-6700HQ CPU @ 2.60GHz
Shell: 3.2.57 - /bin/bash
Binaries:
Node: 8.9.2 - ~/.nvm/versions/node/v8.9.2/bin/node
Yarn: 1.9.4 - /usr/local/bin/yarn
npm: 5.5.1 - ~/.nvm/versions/node/v8.9.2/bin/npm
Browsers:
Chrome: 69.0.3497.100
Firefox: 61.0.2
Safari: 11.1
npmPackages:
gatsby: 1.9.273 => 1.9.273
gatsby-link: ^1.6.40 => 1.6.46
gatsby-plugin-emotion: ^1.1.17 => 1.1.17
gatsby-plugin-intercom-spa: ^0.0.5 => 0.0.5
gatsby-plugin-netlify: ^1.0.19 => 1.0.21
gatsby-plugin-netlify-cms: ^2.0.1 => 2.0.1
gatsby-plugin-react-helmet: ^2.0.10 => 2.0.11
gatsby-plugin-segment-js: ^2.0.1 => 2.0.1
gatsby-plugin-sharp: ^1.6.44 => 1.6.48
gatsby-remark-images: ^1.5.67 => 1.5.67
gatsby-remark-relative-images: ^0.1.2 => 0.1.2
gatsby-source-filesystem: ^1.5.36 => 1.5.39
gatsby-transformer-remark: ^1.7.41 => 1.7.44
gatsby-transformer-sharp: ^1.6.24 => 1.6.27
npmGlobalPackages:
gatsby-cli: 1.1.58
通过明智的调试,我发现在gatsby-ssr中添加对setHeadComponents的调用时似乎会出现这种情况。
任何帮助将不胜感激!我什至不知道在哪里看:(
答案 0 :(得分:0)
最后,经过许多小时的问题,结果是我的插件中缺少.babelrc,这使webpack不知道如何处理JSX。
解决方案是将babel-preset-react添加到插件的package.json中,并对我的babelrc做出反应。
这在我的网站的babel配置处理的plugins目录下有效。