facebook / facebook/jscodeshift

Unexpected token export

Open
#344 2 comments 0 reactions 0 assignees View on GitHub
bug
Dominant language
JavaScript
Stars
10k
Forks
498
PR merge metrics
No merged PRs in 30d

Description

Hello, I am back after a 3-month retreat and I am now trying to upgrade my react version within my libraries as suggested by react `16.9.0` using `react-codemod` that use under the hood `jscodeshift`.

This is the project I am currently trying to upgrade: https://github.com/bootstrap-styled/v4

I was using react `16.8.4` and now I'd like to upgrade to react `16.9.0`.

I am running the code-mod with

npx react-codemod rename-unsafe-lifecycles src/**/*.js

Instead of adding `UNSAFE_` before each method, it fails with:

```
dka@dev-11:[~/workspace/github.com/bootstrap-styled/v4 (react-16.9.0)]: npx react-codemod rename-unsafe-lifecycles src/**/*.js
? Which dialect of JavaScript do you use? JavaScript
Executing command: jscodeshift --verbose=2 --ignore-pattern=**/node_modules/** --parser babel --extensions=jsx,js --transform /home/dka/workspace/github.com/bootstrap-styled/v4/node_modules/react-codemod/transforms/rename-unsafe-lifecycles.js src/Abbr/index.js
Processing 1 files...
Spawning 1 workers...
Sending 1 files to free worker...
/home/dka/workspace/github.com/bootstrap-styled/v4/node_modules/react-codemod/transforms/rename-unsafe-lifecycles.js:18
export default (file, api, options) => {
^^^^^^

SyntaxError: Unexpected token export
at new Script (vm.js:84:7)
at createScript (vm.js:264:10)
at Object.runInThisContext (vm.js:312:10)
at Module._compile (internal/modules/cjs/loader.js:694:28)
at Module._compile (/home/dka/workspace/github.com/bootstrap-styled/v4/node_modules/pirates/lib/index.js:99:24)
at Module._extensions..js (internal/modules/cjs/loader.js:745:10)
at Object.newLoader [as .js] (/home/dka/workspace/github.com/bootstrap-styled/v4/node_modules/pirates/lib/index.js:104:7)
at Module.load (internal/modules/cjs/loader.js:626:32)
at tryModuleLoad (internal/modules/cjs/loader.js:566:12)
at Function.Module._load (internal/modules/cjs/loader.js:558:3)
All done.
Results:
0 errors
0 unmodified
0 skipped
0 ok
Time elapsed: 0.316seconds
```

It seems that the ES6 files are not readen correctly, am I missing something ?

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.