Skip to content

Commit dc75f66

Browse files
authored
Merge pull request #2628 from bigcommerce/arvin/use-lightweight-react-core-runtime
fix: use react runtime core to reduce bundle
2 parents ca8a2a2 + d52d6f6 commit dc75f66

6 files changed

Lines changed: 77 additions & 149 deletions

File tree

.changeset/dry-views-peel.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@bigcommerce/catalyst-makeswift": patch
3+
---
4+
5+
Switch to using `ReactRuntimeCore` instead of `ReactRuntime`, avoiding the bundling of unused dependencies from some Makeswift builtin components. Also bumps to latest `@makeswift/runtime`.

core/lib/makeswift/components.ts

Lines changed: 0 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -14,37 +14,3 @@ import './components/site-header/register';
1414
import './components/site-theme/register';
1515
import './components/slideshow/register';
1616
import './components/sticky-sidebar/register';
17-
18-
import { MakeswiftComponentType } from '@makeswift/runtime';
19-
20-
import { runtime } from './runtime';
21-
22-
// Hide some builtin Makeswift components
23-
24-
runtime.registerComponent(() => null, {
25-
type: MakeswiftComponentType.Carousel,
26-
label: 'Carousel (hidden)',
27-
hidden: true,
28-
props: {},
29-
});
30-
31-
runtime.registerComponent(() => null, {
32-
type: MakeswiftComponentType.Countdown,
33-
label: 'Countdown (hidden)',
34-
hidden: true,
35-
props: {},
36-
});
37-
38-
runtime.registerComponent(() => null, {
39-
type: MakeswiftComponentType.Form,
40-
label: 'Form (hidden)',
41-
hidden: true,
42-
props: {},
43-
});
44-
45-
runtime.registerComponent(() => null, {
46-
type: MakeswiftComponentType.Navigation,
47-
label: 'Navigation (hidden)',
48-
hidden: true,
49-
props: {},
50-
});

core/lib/makeswift/components/button-link/register.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import { MakeswiftComponentType } from '@makeswift/runtime';
21
import { Link, Select, Style, TextInput } from '@makeswift/runtime/controls';
2+
import { MakeswiftComponentType } from '@makeswift/runtime/react/builtins';
33

44
import { runtime } from '~/lib/makeswift/runtime';
55

core/lib/makeswift/runtime.ts

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,34 @@
1-
import { ReactRuntime } from '@makeswift/runtime/react';
1+
import { registerBoxComponent } from '@makeswift/runtime/react/builtins/box';
2+
import { registerDividerComponent } from '@makeswift/runtime/react/builtins/divider';
3+
import { registerEmbedComponent } from '@makeswift/runtime/react/builtins/embed';
4+
import { registerImageComponent } from '@makeswift/runtime/react/builtins/image';
5+
import { registerRootComponent } from '@makeswift/runtime/react/builtins/root';
6+
import { registerSlotComponent } from '@makeswift/runtime/react/builtins/slot';
7+
import { registerSocialLinksComponent } from '@makeswift/runtime/react/builtins/social-links';
8+
import { registerTextComponent } from '@makeswift/runtime/react/builtins/text';
9+
import { registerVideoComponent } from '@makeswift/runtime/react/builtins/video';
10+
import { ReactRuntimeCore } from '@makeswift/runtime/react/core';
211

3-
export const runtime = new ReactRuntime({
12+
const runtime = new ReactRuntimeCore({
413
breakpoints: {
514
small: { width: 640, viewport: 390, label: 'Small' },
615
medium: { width: 768, viewport: 765, label: 'Medium' },
716
large: { width: 1024, viewport: 1000, label: 'Large' },
817
screen: { width: 1280, label: 'XL' },
918
},
1019
});
20+
21+
// Only register necessary built-in components. Omitted components are:
22+
// Navigation, Button, Form, Carousel, Countdown
23+
24+
registerRootComponent(runtime);
25+
registerSlotComponent(runtime);
26+
registerBoxComponent(runtime);
27+
registerTextComponent(runtime);
28+
registerImageComponent(runtime);
29+
registerDividerComponent(runtime);
30+
registerEmbedComponent(runtime);
31+
registerSocialLinksComponent(runtime);
32+
registerVideoComponent(runtime);
33+
34+
export { runtime };

core/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
"@conform-to/react": "^1.6.1",
1919
"@conform-to/zod": "^1.6.1",
2020
"@icons-pack/react-simple-icons": "^11.2.0",
21-
"@makeswift/runtime": "^0.25.0",
21+
"@makeswift/runtime": "^0.26.0",
2222
"@radix-ui/react-accordion": "^1.2.11",
2323
"@radix-ui/react-checkbox": "^1.3.2",
2424
"@radix-ui/react-dialog": "^1.1.14",

0 commit comments

Comments
 (0)