I recently wanted to repurpose an old iPad Mini running iOS 9. I had some issues getting
create-react-app to compile my ES 6 to whatever works on this iPad but I figured it out.
I create an app
Add some ES 6 to the
let x = 42;
Try running it
> cd my-app
> npm run start
I now try connecting with my iPad and see an error with the Developer Tools.
SyntaxError: Unexpected use of reserved word 'let' in strict mode
I open the
package.json file and find a block related to browser support.
"not op_mini all"
"last 1 chrome version",
"last 1 firefox version",
"last 1 safari version"
This means that we will support most recent browsers so I figured I should just add
iOS 9 to both
development, but get the same error.
I start googling and find people talking about doing
npm run eject which basically leaves the confinement of
create-react-app and I don't want to do that.
Finally I come across the manual which I have skimmed many times and spot something I have not seen before.
When editing the
browerslistconfig, you may notice that your changes don't get picked up right away. This is due to an issue in babel-loader not detecting the change in your
package.json. An easy solution is to delete the
node_modules/.cachefolder and try again.
Worth a try.
> rm -rf ./node_modules/.cache
npm run start and cross my fingers. And that's it. God damn it. I spent multiple hours on it and it was in the manual after all...
create-react-app is a cool way to get up and running quickly with React. It allows you to start in an ES 6 environment with modules, webpack, React and a lot of other tools you may need later. Definitely a time saver, but can also be a time sink if you don't read the manual carefully. Lesson learned.