5to6 / 5to6-codemod

A collection of codemods that allow you to transform your js code from ES5 to ES6.
https://medium.com/@cpojer/effective-javascript-codemods-5a6686bb46fb
302 stars 36 forks source link

undefined does not match field "value": string | boolean | null | number | RegExp of type Literal #23

Closed mladenp closed 7 years ago

mladenp commented 7 years ago

I am getting this error when i try to transform imports from cjs.js Error: undefined does not match field "value": string | boolean | null | number | RegExp of type Literal But from 190 files i get that error only of 3 of them, but i can't find any significant difference between those 3 files. Here is one file where it fails: http://pastebin.com/C5K01b7M

xjamundx commented 7 years ago

Thanks for the report @mladenp, the pastebin link doesn't seem to be working

mladenp commented 7 years ago

I found out, its require statement, like this: require('../components/css/font-awesome.css');

xjamundx commented 7 years ago

Great can you get me a sample (failing) file (and command) that will fail and I'll try to get it fixed!

mladenp commented 7 years ago

Try this one, that's the same as the one above.

xjamundx commented 7 years ago

Here's the line it can't handle:

require ('es6-promise').polyfill();

I'm not even sure how we could handle that... 🤔

The solution is basically:

import es6promise from 'es6-promise'
es6Promise.polyfill()

But it's tough fro me to guess the name of the variable.

xjamundx commented 7 years ago

In the mean time I'll work toward at least a better error message with clear instructions :)

xjamundx commented 7 years ago

published as + 5to6-codemod@1.1.3