facebook/fbt

Bug: `intlList` doesn't work in OSS version

mrtnzlml opened this issue ยท 2 comments

๐Ÿ› Bug Report

Utility intlList doesn't work in the OSS version of fbt and throws the following error:

ERROR in /adeira/universe/node_modules/fbt/lib/intlList.js
Module not found: Error: Can't resolve './react' in '/adeira/universe/node_modules/fbt/lib'

When I open that /node_modules/fbt/lib/intlList.js file I can see this at the beginning:

var fbt = require("./fbt");
var invariant = require("invariant");
var React = require("./react"); // <<< ๐Ÿค” this file doesn't exist

Maybe somewhere during the OSS build this line gets broken?

const React = require('react');

To Reproduce

Steps to reproduce the behavior create a simple component like so:

import React, { type Node } from 'react';
import fbt from 'fbt';
import intlList from 'fbt/lib/intlList'; // <<< currently broken

export default function MyComponent(): Node {
  return (
    <p>
      {intlList(
        ['Adam', 'Becky', fbt('4 others', 'last item')],
        intlList.CONJUNCTIONS.AND,
        intlList.DELIMITERS.COMMA,
      )}
    </p>
  );
}

Install the latest dependencies from NPM, set up FBT, and try to run it. It won't work because of the aforementioned error.

Expected behavior

It should work without any issues as described here: https://facebook.github.io/fbt/docs/utilities

envinfo

  System:
    OS: macOS 11.4
    CPU: (8) x64 Intel(R) Core(TM) i5-1038NG7 CPU @ 2.00GHz
    Memory: 831.90 MB / 16.00 GB
    Shell: 5.8 - /bin/zsh
  Binaries:
    Node: 16.10.0 - /usr/local/bin/node
    Yarn: 1.22.10 - /usr/local/bin/yarn
    npm: 7.24.0 - /usr/local/bin/npm
    Watchman: 2021.09.13.00 - /usr/local/bin/watchman

Thanks for having a look!

Hi - sorry for the super late response. This problem was fixed recently in 7886bda

Awesome, thanks! ๐Ÿ˜Š