BabelJS
Created: 2018-06-13 11:53:11 -0700 Modified: 2018-12-07 09:04:23 -0800
Troubleshooting
Section titled TroubleshootingGlobs don’t use the right working directory / “base” directory
Section titled Globs don’t use the right working directory / “base” directoryI was trying to do something like this:
However, it was producing dist/src/foo.js instead of dist/foo.js. There are a couple of solutions:
- In this specific case, since I wanted every single file under “src”, I could just have avoided globs altogether and specified “babel src —out-dir dist”.
- If globs are needed, then you have to be in the directory that you want as the “base”, so your command would change to this:
Spread operator problem
Section titled Spread operator problemThe problem is described here. It’s going to be fixed in Babel 7, so if you run into a situation where you can’t use the spread operator, then just stop using the spread operator or upgrade to version 7 (if you can).
Unexpected token import
Section titled Unexpected token importThis probably just means you’re missing a .babelrc file if you’re trying to use babel-register: