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

issue: "Import in body of module; reoder to top", thrown by CRA next branch. #450

Closed
bebbi opened this issue Apr 3, 2018 · 6 comments
Closed

Comments

@bebbi
Copy link

bebbi commented Apr 3, 2018

This issue is a:

  • Bug report

For my module, nwb has created an es folder with an index.js file starting as follows:

    var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };

    import { myThing } from '@myprefix/mylib'
    // etc.

I'm using this in a monorepo together with create-react-app next branch 2.0.0-next.b2fd8db8.

Running a CRA app with a dependency on my nwb lib errors out with

error Import in body of module; reorder to top

I just confirmed this does not happen with react-scripts version 1.1.2, it will run fine.

I'm posting this here for now as I believe the error thrown by CRA is valid.

I will look at a repro in case this is not an obvious issue.

Is the version of nwb you're using installed globally or locally?

global

Which versions of Node.js, npm and nwb are you using (if using it globally)?

node -v 8.9.1
npm -v 5.7.1
# If nwb is being used as a global install
nwb -v 0.21.5

Which modules are installed in your project?

n.a. I think as the bug is triggered at a consumer.

@insin
Copy link
Owner

insin commented Apr 3, 2018

Does that mean CRA 2.0 is running eslint on code imported node_modules/? That doesn't seem right, but I can't see any relevant open issues in the CRA repo.

@insin
Copy link
Owner

insin commented Apr 3, 2018

It looks like projects created with create-react-app@next don't use react-scripts@next (the test project I created used react-scripts@1.1.2), so it doesn't have this change which excludes node_modules from eslint checking.

@bebbi
Copy link
Author

bebbi commented Apr 3, 2018 via email

@gaearon
Copy link

gaearon commented Apr 3, 2018

Sounds like this should be a CRA bug report instead?

@insin
Copy link
Owner

insin commented Apr 3, 2018

The offending code is then in the nwb module es directory, not in node_modules.

Ah, I missed the significance of the monorepo part - is there a way to configure it so CRA uses your-module/src instead of letting webpack hit package.json and picking up the module build from es/? I hadn't considered how this would work in monorepos.

@bebbi
Copy link
Author

bebbi commented Apr 3, 2018

@gaearon I don't know enough details, filed here because it seemed that es modules should satisfy the imports on top requirement.

I'll file it at CRA instead.

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

No branches or pull requests

3 participants