-
Notifications
You must be signed in to change notification settings - Fork 478
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Optional Chaining Breaks Build of NextJS React App Using Latest Tracker v12.0.12 #2180
Comments
I'm currently getting around this by copying all of the v12 tracker files into my project so that it's transpiled with the rest of my code, using a webpack resolution alias. It appears to be working. // https://webpack.js.org/configuration/resolve/
newConfig.resolve = {
...newConfig.resolve,
alias: {
...newConfig.resolve.alias,
// v12.0.12 does not compile due to OpenReplay's failure to transpile optional chaining;
// https://github.com/openreplay/openreplay/issues/2180
'@openreplay/tracker': path.resolve(
__dirname,
'webpackResolution/openReplay/tracker/v12_0_12'
),
},
} |
Simply update (or add) babel/env (with es2020 mode to target and anything below it as output if you want to) to your build chain or update your nodejs to latest 12.x.x or later version (current lts are 18.x.x and 20.x.x), optional chaining was adopted in 2020 for js and 2019 for typescript. I believe that 4 years is enough to not be considered an exotic feature :) or you can simply add babel-transform-optional-chaining if for some reason es2020 does not suit your needs. You also don't need to use /cjs import with latest versions of next/babel/webpack etc because use client/dynamic import models work fine |
@nick-delirium Before creating the ticket, I already added the necessary babel transforms, but that doesn't work. Our node engine is This isn't a problem with my code; see that it transpiles perfectly fine when I put your entire package in my codebase and build it with the rest of my code. Aside from that, there are reasons some systems won't be as up to date as we'd like. It's better to support the native language rather than depend on hoping all systems in the world are up to your pace. Otherwise, you should add minimum system requirements to your upgrade docs. |
nvm use 18
> Now using node v18.18.0 (npm v9.8.1)
yarn list --pattern @openreplay
├─ @openreplay/tracker-assist@8.0.5-0
└─ @openreplay/tracker@12.0.12
✨ Done in 0.14s.
yarn build
...
...
> ✨ Done in 15.12s. (edit: just repeated same process with next.config.js
tsconfig.json
created regular component with tracker, then dynamically import it in root component as example
alternatively using import(trackerpath).then(module => ) to set it into context from root. Checked with both on typescript 4.5.2.
Well, its a native feature and here is ecma spec for optional chaining. |
Describe the issue
Can't use v12.0.12 of the tracker in my NextJS app that is using webpack 4 because it the tracker uses optional chaining and has not been transpiled for older systems.
I get this error, which I don't get in v11 of the tracker, when I run
next build
:Steps to reproduce the issue
@openreplay/tracker@^12.0.12
.next build
in the terminal in the root../node_modules/@openreplay/tracker/cjs/index.js 202:26
Expected behavior
The error should not occur, and my NextJS build should succeed.
Screenshots
No screenshots, just the error output above.
OpenReplay Environment
Additional context
This wasn't an issue in previous versions, including tracker v11
The text was updated successfully, but these errors were encountered: