How to initialize bit.dev workspace with JavaScript

157 views Asked by At

I want to create and publish components using bit.dev with JavaScript. But when initialize a new workspace using bit new react (react is the template), the react template is generated with typescript. I want to use javascript instead. How to do it?

1

There are 1 answers

0
Jonatan Kruszewski On BEST ANSWER

You can do that by using the default react-env and the templates provided, but you can also create your own environment without Typescript and your own templates. I think that you can get by with the starting templates at the beginning without hussle, and then once you understand better environments and templating, create some of your own.

Steps to create a JS component from a template

Create an environment

bit new react example_workspace
cd example_workspace

now you can explore the available templates:

bit templates

The output will be:

{...}
teambit.react/react
    react (a basic react component)
    react-context (a react context component)
    react-hook (a react hook component)
    react-js (a basic react component in js)
    react-env (customize the base React env with your configs and tools)

teambit.harmony/aspect
    aspect (extend Bit capabilities)

{...}

Create the JS component

So, now, we can use the react-js template:

bit create react-js my_component

The output will be:

1 component(s) were created

my-org.my-scope/my_component
    location: my-scope/my_component
    env:      teambit.react/react (set by template)
    package:  @my-org/my-scope.my_component


env configuration is according to workspace variants, template config or --env flag. learn more at https://bit.dev/docs/envs/using-envs

Source: CLI Reference