Skip to content

Commit 7f26e7c

Browse files
authored
Merge pull request #972 from rvsia/migrationGuideV3
Add migration guide to V3
2 parents d2739bc + ebef6da commit 7f26e7c

File tree

4 files changed

+90
-8
lines changed

4 files changed

+90
-8
lines changed

packages/react-renderer-demo/src/components/code-editor/index.js

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,18 @@ const CodeEditor = ({ value, children, className, inExample }) => {
4848

4949
const lang = className ? className.toLowerCase().replace('language-', '') : undefined;
5050
let content = value || children || '';
51-
content = tranformImports(content);
51+
52+
// read props from code in --- { "key": value } ---\n format
53+
let propsFromMD = content.match(/--- .* ---/);
54+
if (propsFromMD) {
55+
propsFromMD = JSON.parse(propsFromMD[0].replace(/-/g, ''));
56+
content = content.replace(/--- .* ---\n/, '');
57+
}
58+
59+
if (propsFromMD?.switchable !== false) {
60+
content = tranformImports(content);
61+
}
62+
5263
content = content.substring(0, content.length - 1);
5364

5465
return (

packages/react-renderer-demo/src/components/navigation/schemas/schema.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,10 @@ const schema = [
7272
linkText: 'FAQ',
7373
link: 'faq'
7474
},
75+
{
76+
link: 'migration-guide-v3',
77+
linkText: 'Migration guide to version 3'
78+
},
7579
{
7680
link: 'migration-guide',
7781
linkText: 'Migration guide to version 2'
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
import DocPage from '@docs/doc-page';
2+
3+
<DocPage>
4+
5+
# Migration guide to version 3
6+
7+
This new version does not bring any new features, but is aimed to improve developer experience by integrating a new build process to reduce bundle sizes and to introduce automatic ESM/CJS module resolution.
8+
9+
---
10+
11+
## Removal of PatternFly 3 Mapper
12+
13+
PatternFly 3 mapper is now removed. You can still use the mapper from version 2, but we can't guarantee any future bug fixes or new features. However, we are able to assist you with your PRs and we can still release them as you need.
14+
15+
**We strongly recommend to migrate to some other mapper** (mainly to PF4), as PF3 package is no longer maintained well and it will have issues with the latest version of React.
16+
17+
Migration should be simple - most of the components share the same API so replacing imports should work fine in most cases.
18+
19+
```diff
20+
--- { "switchable": false } ---
21+
-import { componentMapper, FormTemplate } from '@data-driven-forms/pf3-component-mapper';
22+
+import { componentMapper, FormTemplate } from '@data-driven-forms/pf4-component-mapper';
23+
```
24+
25+
---
26+
27+
## New build process
28+
29+
### Automatic module resolution
30+
31+
You don't have to specify the correct module, your environment will do it automatically, if corectly configured. See [optimization page](/optimization) for more details.
32+
33+
### No UMD packages
34+
35+
UMD format is no longer supported. The import paths for UMD packages now lead to CJS modules in testing environments and ESM modules in browser environments.
36+
37+
### Changed import paths
38+
39+
Due to the new build process, you have to change your imports path, if you use relative imports of specific components or if you consume the specific module system package. There are no longer module system and the dist folder specified.
40+
41+
```diff
42+
--- { "switchable": false } ---
43+
-import useFieldApi from '@data-driven-forms/react-form-renderer/dist/cjs/use-field-api';;
44+
+import useFieldApi from '@data-driven-forms/react-form-renderer/use-field-api';
45+
```
46+
47+
You can use [babel-transform-plugin](/optimization#transformingimportsinbabel) to do this change for you.
48+
49+
### FormRenderer is longer a default export
50+
51+
FormRenderer component is no longer a default export of the `react-form-renderer` package.
52+
53+
```diff
54+
--- { "switchable": false } ---
55+
-import FormRenderer from '@data-driven-forms/react-form-renderer';
56+
+import { FormRenderer } from '@data-driven-forms/react-form-renderer';
57+
58+
// or
59+
60+
+import { FormRenderer } from '@data-driven-forms/react-form-renderer/form-renderer';
61+
```
62+
63+
<br />
64+
65+
### Using of JSS
66+
67+
All the mappers except Ant Design and PatternFly 4 were migrated to use JSS (CSS in JS), so you don't have to use any css-loader. (However, you still need to setup the loader in case you are using ant-component-mapper of pf4-component-mapper. If you are using PF4, you are probably using the loader right now, as you need it also for the core package.)
68+
69+
</DocPage>

packages/react-renderer-demo/src/pages/optimization.md

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -72,12 +72,10 @@ module.exports = {
7272

7373
Result:
7474

75-
76-
`import { useField } from '@data-driven-forms/react-form-renderer';`
77-
78-
will be converted to
79-
80-
`import useField from '@data-driven-forms/react-form-renderer/use-field';`
81-
75+
```diff
76+
--- { "switchable": false } ---
77+
-import { useField } from '@data-driven-forms/react-form-renderer';
78+
+import useField from '@data-driven-forms/react-form-renderer/use-field';
79+
```
8280

8381
</DocPage>

0 commit comments

Comments
 (0)