drei: Build breaks on Node v12
three
version:0.128.0
@react-three/fiber
version:6.1.4
@react-three/drei
version:5.0.0
node
version:12.14.0
npm
(oryarn
) version:7.7.6
Problem description:
After upgrading to v5, my project has stopped building. Has the build process for this library changed?
Relevant code:
[91mFailed to compile.
[0m[91m./node_modules/@react-three/drei/web/Html.js 109:61
Module parse failed: Unexpected token (109:61)
You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See https://webpack.js.org/concepts#loaders
| const transformOuterRef = React.useRef(null);
| const transformInnerRef = React.useRef(null);
> const target = (portal == null ? void 0 : portal.current) ?? gl.domElement.parentNode;
| React.useEffect(() => {
| if (group.current) {
Suggested solution:
I think due to no support of optional chaining and nullish Coalescing operators on node v12, the build breaks. Maybe the build process has changed and these operators are not being transpiled?
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Reactions: 2
- Comments: 21 (9 by maintainers)
I’m having the same issues. I found this: https://stackoverflow.com/questions/63251072/babel-preset-env-version-7-not-transforming-the-null-coalescing-operator
Environment: CRA 4.0.3 npm 7.13.0 node v12.16.1
Occurs by: Including ‘Html’ component.
And: https://github.com/tc39/proposal-nullish-coalescing
So I was able to make it output the polyfill by setting the rollup config to
Or alternatively by following this https://babeljs.io/docs/en/babel-preset-env#include :
Adds the polyfill. But alas, including the built project breaks with complaints about:
I’d say my issue in now unrelated to the OP. But I hope this helps.
Edit - Repro:
Can you all try
drei@5.1.5-beta.1
please. If it worked, a thumbs up will be fine, if it didn’t please only comment if no one else has.Hey i was facing the above issue, it seems to be happening in all versions after 5, i have rolled back to version ^4.1.2 and it is working fine with the rest of the packages
I don’t think we should be transpiling our code for publishing. It makes it harder to debug for everyone involved. I think what you should be doing is asking
react-scripts
to includeproposal-nullish-coalescing-operator
in theirbabel
config. Nextjs do it and i’ve never had an issue.