Open dustinlacewell opened 3 years ago
This is related to #127 and #112. We don't plan on adding TypeScript support to Docusaurus soon, but we'd appreciate a contribution. If you're unable to contribute at this time, then perhaps this workaround will help you.
I have tried the method mentioned in https://github.com/ZachJW34/nx-plus/issues/112 to no avail:
const tsconfig = require('../../tsconfig.base.json');
const paths = tsconfig.compilerOptions.paths;
const alias = Object.keys(paths).reduce(
(aliases, k) => ({ ...aliases, [k]: './' + paths[k][0] }),
{}
);
module.exports = {
presets: [require.resolve('@docusaurus/core/lib/babel/preset')],
plugins: [
[
require.resolve('babel-plugin-module-resolver'),
{
alias: alias,
},
],
],
};
I couldnot make this work, i've also wrote on the original issue https://github.com/ZachJW34/nx-plus/issues/112#issuecomment-1245663498
I was able to import components from other libraries by prepending the full relative path to the aliases and then importing the components in the mdx files using a full relative path as well.
const tsconfig = require('../../tsconfig.base.json');
const paths = tsconfig.compilerOptions.paths;
const alias = Object.keys(paths)
.reduce(
(aliases, k) => ({ ...aliases, [k]: '../../' + paths[k][0] }),
{}
);
module.exports = {
presets: [require.resolve('@docusaurus/core/lib/babel/preset')],
plugins: [
[
require.resolve('babel-plugin-module-resolver'),
{
alias,
},
],
],
};
And in the markdown file:
# Documentation
import { Button } from '../../../libs/components/src/lib/button/button';
<Button>Test</Button>
It's not pretty but at least the files get resolved correctly that way.
Current Behavior
Unable to import any of the libraries in my workspace.
Expected Behavior
The ability to import workspace libraries.
Steps to Reproduce
Create a workspace with NX 12, boostrap a react component library and docusaurus. Try to import the react component library.
Failure Logs