Closed afasyah closed 2 weeks ago
What is your base env? You should probably be using one of those if you want react v17 https://bit.cloud/teambit/react/v17/react-env-cjs (if you want cjs) or https://bit.cloud/teambit/react/v17/react-env (if you want esm)
ESM, I've been using the specified command for Bit Environment React 17.
But I think I found the culprit
Shouldn't env.jsonc
specified the default React version to be 17 as a default when generated? it's just specified 18 here out of the blue...
the default react-env template uses react 18 Indeed if you want 17 you have to change it manually. I need to check if we have custom react 17 env template
also still noticed the issue of harmony workspace needs to be installed twice too as already mentioned by this issue. Using latest bit 1.8.20
as of rn @GiladShoham.
I finally got it working after modified the env file from the template. I'll attach the step just in case someone here got the same issue using older version react (<v.18
).
peers
entry in env.jsonc to desired React version (use version 12.*
for the @testing-library/react
for React 17 support)
(I didn't notice that it has to be done, since I thought using the specified command for React 17 will be unnecessary)@teambit/react.v17.mounter
instead of @teambit/react.mounter
on the workspace.jsonc
dependency@teambit/react.v17.docs-template
to the workspace dependency too and add docs.tsx from the env template. preview(): EnvHandler<Preview> {
/**
* @see https://bit.dev/docs/react-env/component-previews
*/
return ReactPreview.from({
mounter: this.previewMounter,
docsTemplate: this.previewDocs,
hostDependencies,
// transformers: [webpackTransformer],
});
}
...and after that, re-install again (twice?)
that's it, although I really hope the react env template would be generated accordingly to the version I choose without having to be meddled with another workaround.
cheers.
Thanks for the feedback. Will make sure to add a proper docs for it. @giteden . About the duplicate install I'm working on it and it should be fine with the latest nightly already. Also we are now making the envs template much more simple and also support soon env.jsonc extends feature which will make almost all the steps you have mentioned unnecessary. After the changes you will probably only have to change the import on your env file to the react 17 one. And the extends field in the env.jsonc file. I'm start working on the extends feature tomorrow so hope it will be available soon. Then we will update the templates accordingly. Thanks again for taking the effort to document everything here for other people.
Before the problem occured, I've been using the default
teambit.react/react
for my environment. In short, I need it to modify my unit test configuration file.So I created a new environment specifically for React v17 to be used for all of the components in my org scope just as I've been instructed by the docs.
I've been stuck here so far. I have tried to delete the cache, node_modules as well as the
pnpm-lock.yaml
and reinstall--recompile everything but the problem still persists. Unit test is fine--all green, every component have passed the test.this is my installed dependencies, in case something is related to the package I've installed