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

next@b2fd8db8 throws if monorepo with nwb modules #4249

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

next@b2fd8db8 throws if monorepo with nwb modules #4249

bebbi opened this issue Apr 3, 2018 · 8 comments

Comments

@bebbi
Copy link
Contributor

bebbi commented Apr 3, 2018

Is this a bug report?

yes.

I'm using the next branch with a monorepo including a cra app and a few nwb modules and am getting the following error:

Failed to compile.

../nwb-lib/es/index.js
/path/proj/packages/nwb-lib/es/index.js
  3:1  error  Import in body of module; reorder to top  import/first

See also insin/nwb#450
@Gaeron suggested to repost here.

Did you try recovering your dependencies?

yes

Which terms did you search for in User Guide?

n.a. I think

Environment

  1. node -v: 8.9.1
  2. npm -v: 5.7.1
  3. yarn --version (if you use Yarn): 1.5.1
  4. npm ls react-scripts (if you haven’t ejected):

Then, specify:

  1. Operating system: macos 10.13.4
  2. Browser and version (if relevant): n.a.

Steps to Reproduce

  1. Create a cra monorepo project
  2. with one package being a nwb component with an es build (web-module in my case if it matters)
  3. build the component and run the app

Expected Behavior

Should just run fine.

Actual Behavior

yarn start doesn't serve but instead shows the above error.

Reproducible Demo

I will try if this issue is not very straightforward.

@gaearon
Copy link
Contributor

gaearon commented Apr 3, 2018

This sounds like the fix would be to wait for #4092.

@bebbi
Copy link
Contributor Author

bebbi commented Apr 3, 2018

@gaearon not sure it is related, as the above nwb-lib is publishable and by definition of the referenced proposal it would still need its own build mechanism and be out of scope for source packages.

@gaearon gaearon added this to the 2.0.0 milestone Apr 3, 2018
@gaearon
Copy link
Contributor

gaearon commented Apr 3, 2018

🤔

In that case we should exclude "publishable" packages from linting.

@bebbi bebbi changed the title next@b2fd8db8 throws "Import in body of module; reoder to top" for nwb module next@b2fd8db8 throws "Import in body of module; reorder to top" for nwb module Apr 5, 2018
@bebbi
Copy link
Contributor Author

bebbi commented Apr 10, 2018

It might be useful to add "Cannot co-exist in a monorepo with publishable packages" to the known issues in #3815?

@bebbi bebbi changed the title next@b2fd8db8 throws "Import in body of module; reorder to top" for nwb module next@b2fd8db8 throws if monorepo with nwb modules Apr 10, 2018
@bradfordlemley
Copy link
Contributor

To summarize:

The current alpha implementation doesn't provide a mechanism to specify which packages in the monorepo should be built/linted -- if your app includes another package in the monorepo, it will be transpiled and linted. This leads to an incompatibility with nwb packages in the monorepo because the nwb-built output (es/index.js) fails to lint (because it has some functions defined at the top of the file, then imports can happen later on).

#4092 proposes a mechanism to specify which packages should be built/transpiled and their source entry points, so it will allow nwb packages to in the monorepo to be used by the app, either by not specifying them as source packages, or specifying their "source" entry point. However, it requires the source packages to be "private", which essentially prevents the app from utilizing nwb packages as source packages because there's almost no reason to use nwb unless you're going to publish your package.

@bradfordlemley
Copy link
Contributor

@gaearon Would you be open to relaxing the "private" flag requirement if the package contains both "source" and "main" (or "browser", "module") entry points? This would allow publicly-published packages (like nwb packages) to be used as source packages, but also help ensure that any publicly-published packages conform to npm ecosystem standards.

@stale
Copy link

stale bot commented Dec 2, 2018

This issue has been automatically marked as stale because it has not had any recent activity. It will be closed in 5 days if no further activity occurs.

@stale stale bot added the stale label Dec 2, 2018
@stale
Copy link

stale bot commented Dec 8, 2018

This issue has been automatically closed because it has not had any recent activity. If you have a question or comment, please open a new issue.

@stale stale bot closed this as completed Dec 8, 2018
@lock lock bot locked and limited conversation to collaborators Jan 9, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants