Yarn workspaces support
See original GitHub issueBug Report
Describe the bug
Compilation fail when importing components from another yarn workspace.
To Reproduce
- Create one
docz
workspace and oneshared
workspace - Create components on
shared
- Import them on
docz
- See error
Module parse failed: Unexpected token (11:2)
You may need an appropriate loader to handle this file type.
|
| export default () => (
> <Touchable onPress={() => alert('pressed')}>
| <Text style={styles.text}>Shared Button</Text>
| </Touchable>
@ ./src/index.mdx 9:0-61 66:93-99
@ ./.docz/app/imports.js
@ ./.docz/app/index.jsx
@ multi ../node_modules/docz-core/node_modules/babel-polyfill/lib/index.js ./.docz/app/index.jsx
Environment
- OS: macOS 10.14
- Node/npm version: Node 8.11.3 / npm 5.6
Additional context/Screenshots
If I move the docz code to shared
it will work. It only works if the components are in the same “project”. If you try to import from another workspace it fails.
If you setup docz in the root directory (outside all workspaces) it fails as well, but with another error.
doczrc.js
module.exports = {
themeConfig: {
colors: {
primary: 'black',
},
},
typescript: true,
}
docz package.json
{
"name": "docz",
"version": "0.0.1",
"scripts": {
"start": "docz dev",
"build": "docz build"
},
"dependencies": {
"shared": "0.0.1"
},
"devDependencies": {
"docz": "^0.10.2"
}
}
docz/src/index.mdx
---
name: Hello world
---
import Button from 'shared/src/components/common/Button.tsx'
# Hello world
<Button>Click</Button>
Issue Analytics
- State:
- Created 5 years ago
- Reactions:7
- Comments:8 (3 by maintainers)
Top Results From Across the Web
Workspaces - Yarn
Workspaces are a new way to set up your package architecture that's available by default starting from Yarn 1.0. It allows you to...
Read more >Yarn workspaces — monorepo beginner's guide | The Startup
In this guide, we will create a sample monorepo using Yarn workspaces. It will contain both back-end (express) and front-end (react) ...
Read more >Scaling out JavaScript Monorepos with Yarn Workspaces
Workspaces : Yarn can now manage dependencies across many independent projects in the same repository. Instead of having several big node_modules ...
Read more >Yarn Workspaces: Organize Your Project's Codebase Like A Pro
Yarn is a package manager by the folks at Facebook, and it has a great feature called Yarn workspaces. Yarn workspaces let you...
Read more >Support yarn workspaces (better indexing of node_modules ...
Yarn workspaces works by creating symlinks between your workspace projects in the parent workspaces node_modules folder - and also pulls all dependencies which ......
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Ended up using something similar to this ^ …feels king of hacky but works
Updated doczrc.js to the following:
For sure @brunolemos I agree with you that is related to docz instead of yarn. But, is not a “problem”, is an architecture decision. It’s not a good practice import from other packages in a monorepo without transpiling and since they will be in the
node_modules
they won’t be transpiled. What you can do in this case is change the loader do transpile from a specificnode_modules
since we’re ignoring allnode_modules
folder to be transpiled.About
create-react-app
I saw this week on twitter that they’re dropping support for monorepo. So, I think that change the entire structure to support monorepo can be a good choice.