Skip to content

Commit 6a58389

Browse files
committed
Use dynamic imports for tiptap, prosemirror, codemirror.
1 parent b35ec75 commit 6a58389

File tree

2 files changed

+31
-18
lines changed

2 files changed

+31
-18
lines changed

resources/js/bootstrap/fieldtypes.js

Lines changed: 21 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { defineAsyncComponent } from 'vue';
12
import RevealerFieldtype from '../components/fieldtypes/RevealerFieldtype.vue';
23
import TemplateFieldtype from '../components/fieldtypes/TemplateFieldtype.vue';
34
import Select from '../components/inputs/Select.vue';
@@ -12,12 +13,9 @@ import ArrayFieldtype from '../components/fieldtypes/ArrayFieldtype.vue';
1213
import AssetsFieldtype from '../components/fieldtypes/assets/AssetsFieldtype.vue';
1314
import AssetsIndexFieldtype from '../components/fieldtypes/assets/AssetsIndexFieldtype.vue';
1415
import AssetFolderFieldtype from '../components/fieldtypes/AssetFolderFieldtype.vue';
15-
import BardFieldtype from '../components/fieldtypes/bard/BardFieldtype.vue';
16-
import BardSet from '../components/fieldtypes/bard/Set.vue';
1716
import BardButtonsSettingFieldtype from '../components/fieldtypes/bard/BardButtonsSettingFieldtype.vue';
1817
import ButtonGroupFieldtype from '../components/fieldtypes/ButtonGroupFieldtype.vue';
1918
import CheckboxesFieldtype from '../components/fieldtypes/CheckboxesFieldtype.vue';
20-
import CodeFieldtype from '../components/fieldtypes/CodeFieldtype.vue';
2119
import Routes from '../components/collections/Routes.vue';
2220
import TitleFormats from '../components/collections/TitleFormats.vue';
2321
import ColorFieldtype from '../components/fieldtypes/ColorFieldtype.vue';
@@ -40,7 +38,6 @@ import IntegerFieldtype from '../components/fieldtypes/IntegerFieldtype.vue';
4038
import LinkFieldtype from '../components/fieldtypes/LinkFieldtype.vue';
4139
import ListFieldtype from '../components/fieldtypes/ListFieldtype.vue';
4240
import ListIndexFieldtype from '../components/fieldtypes/ListIndexFieldtype.vue';
43-
import MarkdownFieldtype from '../components/fieldtypes/markdown/MarkdownFieldtype.vue';
4441
import MarkdownButtonsSettingFieldtype from '../components/fieldtypes/markdown/MarkdownButtonsSettingFieldtype.vue';
4542
import RadioFieldtype from '../components/fieldtypes/RadioFieldtype.vue';
4643
import RangeFieldtype from '../components/fieldtypes/RangeFieldtype.vue';
@@ -61,7 +58,6 @@ import ToggleFieldtype from '../components/fieldtypes/ToggleFieldtype.vue';
6158
import ToggleIndexFieldtype from '../components/fieldtypes/ToggleIndexFieldtype.vue';
6259
import WidthFieldtype from '../components/fieldtypes/WidthFieldtype.vue';
6360
import VideoFieldtype from '../components/fieldtypes/VideoFieldtype.vue';
64-
import YamlFieldtype from '../components/fieldtypes/YamlFieldtype.vue';
6561
import SetPicker from '../components/fieldtypes/replicator/SetPicker.vue';
6662
import SetField from '../components/fieldtypes/replicator/Field.vue';
6763

@@ -78,12 +74,21 @@ export default function registerFieldtypes(app) {
7874
app.component('assets-fieldtype', AssetsFieldtype);
7975
app.component('assets-fieldtype-index', AssetsIndexFieldtype);
8076
app.component('asset_folder-fieldtype', AssetFolderFieldtype);
81-
app.component('bard-fieldtype', BardFieldtype);
82-
app.component('bard-fieldtype-set', BardSet);
77+
app.component(
78+
'bard-fieldtype',
79+
defineAsyncComponent(() => import('../components/fieldtypes/bard/BardFieldtype.vue')),
80+
);
81+
app.component(
82+
'bard-fieldtype-set',
83+
defineAsyncComponent(() => import('../components/fieldtypes/bard/Set.vue')),
84+
);
8385
app.component('bard_buttons_setting-fieldtype', BardButtonsSettingFieldtype);
8486
app.component('button_group-fieldtype', ButtonGroupFieldtype);
8587
app.component('checkboxes-fieldtype', CheckboxesFieldtype);
86-
app.component('code-fieldtype', CodeFieldtype);
88+
app.component(
89+
'code-fieldtype',
90+
defineAsyncComponent(() => import('../components/fieldtypes/CodeFieldtype.vue')),
91+
);
8792
app.component('collection_routes-fieldtype', Routes);
8893
app.component('collection_title_formats-fieldtype', TitleFormats);
8994
app.component('color-fieldtype', ColorFieldtype);
@@ -106,7 +111,10 @@ export default function registerFieldtypes(app) {
106111
app.component('link-fieldtype', LinkFieldtype);
107112
app.component('list-fieldtype', ListFieldtype);
108113
app.component('list-fieldtype-index', ListIndexFieldtype);
109-
app.component('markdown-fieldtype', MarkdownFieldtype);
114+
app.component(
115+
'markdown-fieldtype',
116+
defineAsyncComponent(() => import('../components/fieldtypes/markdown/MarkdownFieldtype.vue')),
117+
);
110118
app.component('markdown_buttons_setting-fieldtype', MarkdownButtonsSettingFieldtype);
111119
app.component('radio-fieldtype', RadioFieldtype);
112120
app.component('range-fieldtype', RangeFieldtype);
@@ -128,7 +136,10 @@ export default function registerFieldtypes(app) {
128136
app.component('toggle-fieldtype-index', ToggleIndexFieldtype);
129137
app.component('width-fieldtype', WidthFieldtype);
130138
app.component('video-fieldtype', VideoFieldtype);
131-
app.component('yaml-fieldtype', YamlFieldtype);
139+
app.component(
140+
'yaml-fieldtype',
141+
defineAsyncComponent(() => import('../components/fieldtypes/YamlFieldtype.vue')),
142+
);
132143
app.component('set-picker', SetPicker);
133144
app.component('set-field', SetField);
134145
app.component('revealer-fieldtype', RevealerFieldtype);

resources/js/components/Bard.js

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,3 @@
1-
import * as core from '@tiptap/core';
2-
import * as vue3 from '@tiptap/vue-3';
3-
import * as state from '@tiptap/pm/state';
4-
import * as model from '@tiptap/pm/model';
5-
import * as view from '@tiptap/pm/view';
6-
71
class Bard {
82
constructor(instance) {
93
this.instance = instance;
@@ -24,10 +18,18 @@ class Bard {
2418
this.buttonCallbacks.push(callback);
2519
}
2620

27-
get tiptap() {
21+
async tiptap() {
22+
const [core, vue3, state, model, view] = await Promise.all([
23+
import('@tiptap/core'),
24+
import('@tiptap/vue-3'),
25+
import('@tiptap/pm/state'),
26+
import('@tiptap/pm/model'),
27+
import('@tiptap/pm/view'),
28+
]);
29+
2830
return {
2931
core,
30-
vue2,
32+
vue3,
3133
pm: {
3234
state,
3335
model,

0 commit comments

Comments
 (0)