Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

import' and 'export' may appear only with 'sourceType: module' #483

Closed
irvinebroque opened this issue Aug 1, 2016 · 6 comments
Closed

Comments

@irvinebroque
Copy link

Similar to #112, but I'm on v4.0.0-beta9 and that issue was tracking work on v2 => v3.

I ran into this issue today trying to add documentation to an existing codebase that uses ES6 modules and Flow types:

➜ documentation --version
4.0.0-beta9

➜   ✗ documentation build app.js
/Users/brendan/.nvm/versions/node/v6.3.1/lib/node_modules/documentation/lib/commands/build.js:67
      throw err;
      ^

Error: Parsing file index.js: 'import' and 'export' may appear only with 'sourceType: module' (3:0)
    at Deps.parseDeps (/Users/brendan/.nvm/versions/node/v6.3.1/lib/node_modules/documentation/node_modules/module-deps-sortable/index.js:467:28)
    at fromSource (/Users/brendan/.nvm/versions/node/v6.3.1/lib/node_modules/documentation/node_modules/module-deps-sortable/index.js:402:44)
    at /Users/brendan/.nvm/versions/node/v6.3.1/lib/node_modules/documentation/node_modules/module-deps-sortable/index.js:396:17
    at ConcatStream.<anonymous> (/Users/brendan/.nvm/versions/node/v6.3.1/lib/node_modules/documentation/node_modules/concat-stream/index.js:36:43)

Babel plugins in use:

  "presets": ["es2015", "react"],
  "plugins": [
    "array-includes",
    "syntax-class-properties",
    "transform-class-properties",
    "transform-flow-strip-types",
    "transform-object-rest-spread",
    "transform-react-inline-elements",
    "transform-react-pure-class-to-function",
    "transform-react-remove-prop-types"
  ],

There are a few spots where we use require() instead of import, wondering if mixing and matching this with ES6 modules is an issue for documentation? Nothing stands out otherwise about the configuration of this project or its dependencies:

  "dependencies": {
    "babel-runtime": "6.11.6",
    "date-fns": "1.3.0",
    "inline-style-prefixer": "2.0.1",
    "intl": "1.2.3",
    "lodash": "4.14.0",
    "mailcheck": "1.1.1",
    "query-string": "4.2.0",
    "raven-js": "3.3.0",
    "react": "15.2.1",
    "react-addons-update": "15.2.1",
    "react-dom": "15.2.1",
    "react-draggable": "2.1.1",
    "react-intl": "2.1.1",
    "react-motion": "0.4.3",
    "react-pure-render": "1.0.2",
    "react-redux": "4.4.5",
    "react-responsive": "1.1.4",
    "react-router": "2.6.0",
    "react-router-redux": "4.0.4",
    "react-tap-event-plugin": "1.0.0",
    "redux": "3.5.2",
    "redux-batched-actions": "0.1.2",
    "redux-thunk": "2.0.1",
    "reselect": "2.5.3",
    "scriptjs": "2.5.8",
    "whatwg-fetch": "1.0.0"
  }
@montogeek
Copy link
Contributor

Did you fixed it?

@irvinebroque
Copy link
Author

Nope, just tried again on 4.0.0-beta11 and get the same error. I took a brief pass through configuration docs, and I don't see an option to pass a custom babel config for documentation. My guess is that I'm missing a babel transform that needs to happen before documentation tries to parse.

@tmcw
Copy link
Member

tmcw commented Nov 18, 2016

Sorry, I'm really not seeing any way to reliably replicate or fix this issue: there are issues scattered around babelify, and many many closed issues in babelify, all of which point to configuration errors. Here's our configuration.

Happy to fix this issue if you can provide a testcase, I've tried many variations and haven't been able to trigger it in any of them.

@montogeek
Copy link
Contributor

I think know that maybe is caused by a dynamic import from a third party code

@tmcw
Copy link
Member

tmcw commented Apr 12, 2017

Sorry, closing as 'needs testcase'. Happy to reopen & fix if provided a testcase, otherwise it isn't feasible for me to debug this without replicating it.

@backspaces
Copy link

@irvinebroque Could you look at the end of #950 and try either:

  • delete node_modules, yarn/npm lockfiles etc
  • download your repo to a fresh dir and re-init. Remove lockfiles if in your repo.

Let us know if it works!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants