Skip to content

Unexpected token #287

Closed
Closed

Description

@smali-kazmi

getting following error when I started my app

Failed to compile.

./node_modules/react-scan/dist/auto.global.js 329:96
Module parse failed: Unexpected token (329:96)
File was processed with these loaders:
 * ./node_modules/babel-loader/lib/index.js
You may need an additional loader to handle the result of these loaders.
|         inject(o) {
|           const i = ++n;
>           return t.set(i, o), r._instrumentationIsActive || (r._instrumentationIsActive = !0, e?.()), i;
|         },
|         _instrumentationSource: u,

Activity

  1. lxsmnsyc commented on Feb 27, 2025

    @lxsmnsyc
    Contributor

    Hi, please provide an example of your setup (or any case, the setup your followed from the installation guide)

  2. omakarov-playq commented on May 15, 2025

    @omakarov-playq

    I have the same issue, because it contains modern JS syntax (like the logical assignment operator ||=) or possibly ES modules. I tried to configure Babel and Webpack, but I couldn't fix it. @lxsmnsyc, perhaps you've encountered this issue before?

  3. aidenybai commented on May 2, 2026

    @aidenybai
    Owner

    Fixed in v0.5.5 via #437.

    Root cause: esbuild was building React Scan's published bundles with target: 'esnext', leaving optional chaining (?.), nullish coalescing (??), and ?.() calls in the output. Older webpack + babel-loader configs without @babel/preset-env for ES2020 fail to parse those operators when they include node_modules in the babel pipeline (CRA, etc.).

    Lowered the published bundle target to es2019, which transpiles those operators down. Verified all four published bundles (auto.global.js, index.mjs, index.js, lite/index.mjs) contain 0 occurrences of ?. after the rebuild.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions