Docz: tsx support

Created on 13 Jun 2018  路  10Comments  路  Source: doczjs/docz

My project created by create-react-app-typescript. I tried to import .tsx component but got 'This relative module was not found' message. Is the usage incorrect or is it not yet supported?

Most helpful comment

If you want to transpile Typescript on our project just pass a config on your doczrc.js:

// doczrc.js
export default {
  typescript: true
}

So, if you want some custom config do something like we did on docz-plugin-babel6 @mbrn
https://github.com/pedronauck/docz/blob/master/packages/docz-plugin-babel6/src/index.ts

All 10 comments

Did you put the .tsx extension at import?

import { Something } from './Something.tsx'`

I don't even know why this is mandatory on mdx 馃槥

Thanks @pedronauck , I tried it and got "Module parse failed: Unexpected token (3:21)
You may need an appropriate loader to handle this file type." message

You need to enable typescript via CLI --typescript or your docz config file.

docz using babel7 compile tsx, It does not support const enum , So i can't use it for now .
Thanks @albinekb .

You can modify your bundler config to use ts-loader instead of babel plugin @huodon

export default {
  modifyBundlerConfig: (config) => {
    /* set ts-loader here */
    return config
  }
}

Thank you @pedronauck , the problem was solved. 馃憤

@huodon How did you use ts-loader instead? I tried and I failed. Mind showing the essential parts of your config?

@cvle if you want to use ts-loader you can just docz-plugin-babel6 that implements ts-loader together with babel 6 鉁岋笍

if i want to use ts-loader with options: transpileOnly, how can i implement this to doczrc.js

If you want to transpile Typescript on our project just pass a config on your doczrc.js:

// doczrc.js
export default {
  typescript: true
}

So, if you want some custom config do something like we did on docz-plugin-babel6 @mbrn
https://github.com/pedronauck/docz/blob/master/packages/docz-plugin-babel6/src/index.ts

Was this page helpful?
0 / 5 - 0 ratings

Related issues

merelinguist picture merelinguist  路  3Comments

brunolemos picture brunolemos  路  3Comments

w0wka91 picture w0wka91  路  3Comments

mariusespejo picture mariusespejo  路  3Comments

hayk94 picture hayk94  路  3Comments