I want to create a few typescript components in an existing javascript project. My new components will all be placed in a single folder and will use the react-typescript
compiler as opposed to the react
compiler that the rest of the components use. How can I define this complier to the entire folder (and all the components in it) but keep the existing compiler on all the existing bit components in the project?
you can use the override feature in bit .
Add all your new TypeScript components with a special flag( typescript-components
in my example), so it will be easier to override the compiler for these components.
Here is an example of how the bit object in your package.json
or bit.json
file should look:
{
"env": {
"compiler": "bit.envs/compilers/react@1.0.6"
},
"componentsDefaultDirectory": "components/{name}",
"packageManager": "npm",
"overrides": {
"typescript-components/*": {
"env": {
"compiler": "bit.envs/compilers/react-typescript@3.1.23"
}
}
}
}
As you can see, all the components in the project will use the react
compiler, and all components with typescript-components
namespace will use the react-typescript
compiler.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.