React-starter-kit: [feature/react-intl] The "path" argument must be of type string

Created on 22 Feb 2018  路  3Comments  路  Source: kriasoft/react-starter-kit

Running yarn messages on Intl branch gives following error:

TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string

@kayluhb created an issue here: https://github.com/yahoo/babel-plugin-react-intl/issues/135

branch featurreact-intl bug

Most helpful comment

@langpavel Adding the line filename: fileName as option for transform() method made it work in my case.

All 3 comments

OK, I think I have a solution (added filename: fileName, line):
file: tools/messages.js:

const processFile = async fileName => {
    try {
      const code = await readFile(fileName);
      const posixName = posixPath(fileName);
      const result = transform(code, {
        filename: fileName,
        presets: babelrc.presets,
        plugins: ['react-intl'],
      }).metadata['react-intl'];
      if (result.messages && result.messages.length) {
        fileToMessages[posixName] = result.messages.sort(compareMessages);
      } else {
        delete fileToMessages[posixName];
      }
    } catch (err) {
      console.error(`extractMessages: In ${fileName}:\n`, err.codeFrame || err);
    }
  };

What should I do for this to be fixed? Code above?

@langpavel Adding the line filename: fileName as option for transform() method made it work in my case.

Was this page helpful?
0 / 5 - 0 ratings