question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Next.js babel preset

See original GitHub issue

1) Integration with Next.js (TypeScript)

I don’t know how can I fix the next problem:

import * as React from 'react';

// @ts-ignore : 'fbt' is declared but its value is never read.
import fbt from 'fbt'; 

console.log(fbt); // ( 1 ) 

// @ts-ignore
const node = <fbt desc='desc-text'>Some text</fbt>;
  1. When I commented on this line I get next build error: fbt is not bound. Did you forget to require('fbt')

Did It mean that webpack bundle remove unused import before babel transpilation?

2) Empty childParentMappings:{}

And node_modules/babel-plugin-fbt/bin/collectFBT.js couldn’t collect any phrases from code


DEMO Next.js App

dependencies": {
    "fbt": "^0.9.51",
    "babel-plugin-fbt": "^0.9.12",
    "babel-plugin-fbt-runtime": "^0.9.1",
}

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:8 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
retyuicommented, May 23, 2020

Here is an article about Typescript + fbt where I describe problems that i faced and how to fix them

0reactions
Lpaydatcommented, Sep 8, 2020

@retyui I followed your guideline and its work well ❤️.

But recently, after I have upgraded Next.Js from 9.3.5 to 9.5.3, another issue occurred. It has no problem on localhost but on vercel it throw fbt is not defined error.

Maybe it has been removed by webpack as the unused code.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Advanced Features: Customizing Babel Config - Next.js
Next.js includes the next/babel preset to your app, which includes everything needed to compile React applications and server-side code.
Read more >
Adding Babel presets and plugins in Next.js - Netlify
Next.js comes with several Babel presets built in, and chances are, it will cover most of what you'd like to use in your...
Read more >
babel-preset-next - npm
babel preset used by myself. Latest version: 1.4.0, last published: 3 years ago. Start using babel-preset-next in your project by running ...
Read more >
canary - GitHub
js /packages/next/build/babel/preset.ts. Go to file · Go to file T
Read more >
Adding Babel presets and plugins in Next.js
Next.js comes with several Babel presets built in, and chances are, it will cover most of what you'd like to use in your...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found