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

Importing CRA module from Next.js module (Lerna) #707

Closed
slorber opened this issue Jan 9, 2017 · 2 comments
Closed

Importing CRA module from Next.js module (Lerna) #707

slorber opened this issue Jan 9, 2017 · 2 comments

Comments

@slorber
Copy link

slorber commented Jan 9, 2017

Hi,

I'm trying to setup a monorepo with Lerna:

  • The "web" package is built with Next
  • The "styleguide" package is built with Create-React-App and imported by the "web" package
  • In the future there might be more clients (ReactNative, browser extensions...) and more shared code as well

I don't want to use a single package because I want to create very explicit dependency boundaries across my app: for example the styleguide package should not be able to import things from the web package.

I don't know if this is the best place for this issue but I'd like to have your recommendation on how this can be achieved when using Next.

Currently I'm able to import the styleguide from the next web app, but at runtime it fails because the imported styleguide is not transpiled.

I could certainly transpile the styleguide and use main: "lib/styleguide.js" but it seems to me it does not really make sense to have multiple transpilation phases and could also mess up with tree-shaking right?

So what I'd like is to be able to expose my styleguide with "module": "src/styleguide.js" or "jsnext:main": "src/styleguide.js", and only transpile the whole client-side app once. Does it make sense? How can I tell Next project to handle the transpilation of my styleguide?

You can check my current repository here: https://github.com/slorber/playground/

Currently it fails at runtime:

image

@slorber slorber changed the title Import properly a Lerna module from Next.js project? Import a Lerna module from Next.js project? Jan 9, 2017
@slorber slorber changed the title Import a Lerna module from Next.js project? Lerna - Import CRA module from Next.js module? Jan 9, 2017
@slorber slorber changed the title Lerna - Import CRA module from Next.js module? Import CRA module from Next.js module (Lerna) Jan 9, 2017
@slorber slorber changed the title Import CRA module from Next.js module (Lerna) Importing CRA module from Next.js module (Lerna) Jan 9, 2017
@arunoda
Copy link
Contributor

arunoda commented Jan 9, 2017

I think this seems like something like this: #706

@slorber
Copy link
Author

slorber commented Jan 9, 2017

hmmmm yes that looks like the same so I'm closing this one

@slorber slorber closed this as completed Jan 9, 2017
@lock lock bot locked as resolved and limited conversation to collaborators May 12, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants