Skip to content
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

[Bug]: Breaks react-router-dom #14229

Closed
1 task
cdaycmc opened this issue Feb 3, 2022 · 8 comments
Closed
1 task

[Bug]: Breaks react-router-dom #14229

cdaycmc opened this issue Feb 3, 2022 · 8 comments
Labels
i: regression outdated A closed issue/PR that is archived due to age. Recommended to make a new issue

Comments

@cdaycmc
Copy link

cdaycmc commented Feb 3, 2022

💻

  • Would you like to work on a fix?

How are you using Babel?

babel-loader (webpack)

Input code

  • CRA
  • npm i react-router-dom
  • Include <BrowserRouter>

Configuration file name

No response

Configuration

No response

Current and expected behavior

Fails on npm start

ERROR in ./node_modules/history/index.js
Module build failed (from ./node_modules/babel-loader/lib/index.js):
TypeError: C:\_src\xxx\node_modules\history\index.js: Cannot read property '    at SourceMapTree.originalPositionFor (C:\_src\xxx\node_modules\@ampproject\remapping\dist\remapping.umd.js:159:27)
    at trace (C:\_src\xxx\node_modules\@ampproject\remapping\dist\remapping.umd.js:102:37)
    at EncodedSourceMapImpl.map (C:\_src\xxx\node_modules\@jridgewell\trace-mapping\dist\trace-mapping.umd.js:347:36)
    at TraceMap.map (C:\_src\xxx\node_modules\@jridgewell\trace-mapping\dist\trace-mapping.umd.js:430:31)
    at SourceMapTree.traceMappings (C:\_src\xxx\node_modules\@ampproject\remapping\dist\remapping.umd.js:85:34)
    at remapping (C:\_src\xxx\node_modules\@ampproject\remapping\dist\remapping.umd.js:258:36)
    at mergeSourceMap (C:\_src\xxx\node_modules\@babel\core\lib\transformation\file\merge-map.js:19:30)
    at generateCode (C:\_src\xxx\node_modules\@babel\core\lib\transformation    at run (C:\_src\xxx\node_modules\@babel\core\lib\transformation\index.js:55:33)
    at run.next (<anonymous>)
 @ ./node_modules/react-router-dom/index.js 15:0-78 85:25-45 124:25-42 325:37-47 325:62-72
 @ consume shared module (default) react-router-dom@=6.2.1 (strict) (fallback: ./node_modules/react-router-dom/index.js)
 @ ./src/components/PassThrough.tsx 10:0-72 17:17-28 18:17-28 25:30-40 59:10-21 59:23-34
 @ container entry ./PassThrough[0]

Failed to compile.

Environment

Babel 7.17.0
CRA 5.0.0
react-router-dom 6.2.1

Possible solution

Revert to previous version of @babel/core
npm i -D @babel/core@7.16.12

Additional context

No response

@babel-bot
Copy link
Collaborator

Hey @cdaycmc! We really appreciate you taking the time to report an issue. The collaborators on this project attempt to help as many people as possible, but we're a limited number of volunteers, so it's possible this won't be addressed swiftly.

If you need any help, or just have general Babel or JavaScript questions, we have a vibrant Slack community that typically always has someone willing to help. You can sign-up here for an invite.

@milesj
Copy link

milesj commented Feb 3, 2022

I'm also seeing a similar error in Babel 7.17, but not in react-router-dom specifically. It triggers when upgrading Babel.

[BABEL]: /Users/milesj/Projects/packemon/packages/babel-plugin-env-constants/lib/types.js: Cannot read property 'originalPositionFor' of undefined (While processing: /Users/milesj/Projects/packemon/packages/babel-plugin-env-constants/lib/index.js)

@jridgewell
Copy link
Member

Looking into this.

@Ghustavh97
Copy link

Same issue on Nuxt @ v2.15.8

Module build failed (from ./node_modules/babel-loader/lib/index.js): friendly-errors 06:24:50
TypeError: /home/project/nuxt/definitions/test/index.ts: Cannot read property 'originalPositionFor' of undefined
    at SourceMapTree.originalPositionFor (/home/project/nuxt/node_modules/@ampproject/remapping/dist/remapping.umd.js:159:27)
    at trace (/home/project/nuxt/node_modules/@ampproject/remapping/dist/remapping.umd.js:102:37)
    at EncodedSourceMapImpl.map (/home/project/nuxt/node_modules/@jridgewell/trace-mapping/dist/trace-mapping.umd.js:347:36)
    at TraceMap.map (/home/project/nuxt/node_modules/@jridgewell/trace-mapping/dist/trace-mapping.umd.js:430:31)
    at SourceMapTree.traceMappings (/home/project/nuxt/node_modules/@ampproject/remapping/dist/remapping.umd.js:85:34)
    at remapping (/home/project/nuxt/node_modules/@ampproject/remapping/dist/remapping.umd.js:258:36)
    at mergeSourceMap (/home/project/nuxt/node_modules/@babel/core/lib/transformation/file/merge-map.js:19:30)
    at generateCode (/home/project/nuxt/node_modules/@babel/core/lib/transformation/file/generate.js:72:39)
    at run (/home/project/nuxt/node_modules/@babel/core/lib/transformation/index.js:55:33)
    at run.next (<anonymous>)
    at Function.transform (/home/project/nuxt/node_modules/@babel/core/lib/transform.js:25:41)
    at transform.next (<anonymous>)
    at step (/home/project/nuxt/node_modules/gensync/index.js:261:32)
    at /home/project/nuxt/node_modules/gensync/index.js:273:13
    at async.call.result.err.err (/home/project/nuxt/node_modules/gensync/index.js:223:11)

@jridgewell
Copy link
Member

I found the bug, I'll publish a new @jridgewell/trace-mapping in a few minutes to fix.

@jridgewell
Copy link
Member

Ok, v0.2.3 is published which should resolve the issue.

@patotoma
Copy link

patotoma commented Feb 3, 2022

Ok, v0.2.3 is published which should resolve the issue.

confirmed, working now

if you have npm 7+ all you have to do is run: npm update

@jridgewell thanks for the fast fix

@nicolo-ribaudo
Copy link
Member

I'm closing this since it has been fixes in @jridgewell/trace-mapping (a dependency of a Babel dependency). Please make sure to update it! Your lockfile should show version 0.2.5.

@github-actions github-actions bot added the outdated A closed issue/PR that is archived due to age. Recommended to make a new issue label May 6, 2022
@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 6, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
i: regression outdated A closed issue/PR that is archived due to age. Recommended to make a new issue
Projects
None yet
Development

No branches or pull requests

8 participants