Skip to content

Commit 4f499f8

Browse files
authored
build: remove unused dependencies and bundle react-icons (#2796)
1 parent e0c67af commit 4f499f8

26 files changed

Lines changed: 131 additions & 163 deletions

File tree

packages/code-block/package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,11 +49,12 @@
4949
"test-watch": "vitest watch"
5050
},
5151
"dependencies": {
52-
"@blocknote/core": "0.51.4",
5352
"@shikijs/core": "^4",
5453
"@shikijs/engine-javascript": "^4",
5554
"@shikijs/langs-precompiled": "^4",
56-
"@shikijs/themes": "^4",
55+
"@shikijs/themes": "^4"
56+
},
57+
"optionalDependencies": {
5758
"@shikijs/types": "^4"
5859
},
5960
"devDependencies": {

packages/core/package.json

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -97,17 +97,14 @@
9797
"@tiptap/core": "^3.13.0",
9898
"@tiptap/extension-bold": "^3.13.0",
9999
"@tiptap/extension-code": "^3.13.0",
100-
"@tiptap/extension-horizontal-rule": "^3.13.0",
101100
"@tiptap/extension-italic": "^3.13.0",
102-
"@tiptap/extension-paragraph": "^3.13.0",
103101
"@tiptap/extension-strike": "^3.13.0",
104102
"@tiptap/extension-text": "^3.13.0",
105103
"@tiptap/extension-underline": "^3.13.0",
106104
"@tiptap/extensions": "^3.13.0",
107105
"@tiptap/pm": "^3.13.0",
108106
"emoji-mart": "^5.6.0",
109107
"fast-deep-equal": "^3.1.3",
110-
"lib0": "^0.2.99",
111108
"prosemirror-highlight": "^0.15.1",
112109
"prosemirror-model": "^1.25.4",
113110
"prosemirror-state": "^1.4.4",

packages/core/src/comments/threadstore/yjs/YjsThreadStore.test.ts

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,18 @@
1-
import { beforeEach, describe, expect, it, vi } from "vitest";
1+
import { afterAll, beforeEach, describe, expect, it, vi } from "vitest";
22
import * as Y from "yjs";
33
import { CommentBody } from "../../types.js";
44
import { DefaultThreadStoreAuth } from "../DefaultThreadStoreAuth.js";
55
import { YjsThreadStore } from "./YjsThreadStore.js";
66

7-
// Mock UUID to generate sequential IDs
7+
// Mock crypto.randomUUID to generate sequential IDs
88
let mockUuidCounter = 0;
9-
vi.mock("lib0/random", async (importOriginal) => ({
10-
...(await importOriginal<typeof import("lib0/random")>()),
11-
uuidv4: () => `mocked-uuid-${++mockUuidCounter}`,
12-
}));
9+
const randomUUIDSpy = vi.spyOn(crypto, "randomUUID").mockImplementation(
10+
() => `mocked-uuid-${++mockUuidCounter}` as `${string}-${string}-${string}-${string}-${string}`,
11+
);
12+
13+
afterAll(() => {
14+
randomUUIDSpy.mockRestore();
15+
});
1316

1417
describe("YjsThreadStore", () => {
1518
let store: YjsThreadStore;

packages/core/src/comments/threadstore/yjs/YjsThreadStore.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import { uuidv4 } from "lib0/random";
21
import * as Y from "yjs";
32
import { CommentBody, CommentData, ThreadData } from "../../types.js";
43
import { ThreadStoreAuth } from "../ThreadStoreAuth.js";
@@ -57,7 +56,7 @@ export class YjsThreadStore extends YjsThreadStoreBase {
5756

5857
const comment: CommentData = {
5958
type: "comment",
60-
id: uuidv4(),
59+
id: crypto.randomUUID(),
6160
userId: this.userId,
6261
createdAt: date,
6362
updatedAt: date,
@@ -68,7 +67,7 @@ export class YjsThreadStore extends YjsThreadStoreBase {
6867

6968
const thread: ThreadData = {
7069
type: "thread",
71-
id: uuidv4(),
70+
id: crypto.randomUUID(),
7271
createdAt: date,
7372
updatedAt: date,
7473
comments: [comment],
@@ -105,7 +104,7 @@ export class YjsThreadStore extends YjsThreadStoreBase {
105104
const date = new Date();
106105
const comment: CommentData = {
107106
type: "comment",
108-
id: uuidv4(),
107+
id: crypto.randomUUID(),
109108
userId: this.userId,
110109
createdAt: date,
111110
updatedAt: date,

packages/core/src/extensions/Placeholder/Placeholder.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { Plugin, PluginKey } from "prosemirror-state";
22
import { Decoration, DecorationSet } from "prosemirror-view";
3-
import { uuidv4 } from "lib0/random";
3+
44
import {
55
createExtension,
66
ExtensionOptions,
@@ -23,7 +23,7 @@ export const PlaceholderExtension = createExtension(
2323
new Plugin({
2424
key: PLUGIN_KEY,
2525
view: (view) => {
26-
const uniqueEditorSelector = `placeholder-selector-${uuidv4()}`;
26+
const uniqueEditorSelector = `placeholder-selector-${crypto.randomUUID()}`;
2727
view.dom.classList.add(uniqueEditorSelector);
2828
const styleEl = document.createElement("style");
2929

packages/core/src/extensions/tiptap-extensions/UniqueID/UniqueID.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import {
66
} from "@tiptap/core";
77
import { Fragment, Slice } from "prosemirror-model";
88
import { Plugin, PluginKey } from "prosemirror-state";
9-
import { uuidv4 } from "lib0/random";
9+
1010

1111
/**
1212
* Code from Tiptap UniqueID extension (https://tiptap.dev/api/extensions/unique-id)
@@ -65,7 +65,7 @@ const UniqueID = Extension.create({
6565
return testOptions.mockID.toString() as string;
6666
}
6767

68-
return uuidv4();
68+
return crypto.randomUUID();
6969
},
7070
filterTransaction: null,
7171
};

packages/mantine/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,10 +62,10 @@
6262
},
6363
"dependencies": {
6464
"@blocknote/core": "0.51.4",
65-
"@blocknote/react": "0.51.4",
66-
"react-icons": "^5.5.0"
65+
"@blocknote/react": "0.51.4"
6766
},
6867
"devDependencies": {
68+
"react-icons": "^5.5.0",
6969
"@types/react": "^19.2.3",
7070
"@types/react-dom": "^19.2.3",
7171
"@vitejs/plugin-react": "^6.0.1",

packages/mantine/vite.config.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,16 @@ export default defineConfig((conf) => ({
4545
// make sure to externalize deps that shouldn't be bundled
4646
// into your library
4747
external: (source) => {
48+
// Bundle react-icons into the output (tree-shaken) so consumers
49+
// don't need to install it as a peer/runtime dependency.
50+
const bundledDeps = ["react-icons"];
51+
if (
52+
bundledDeps.some(
53+
(dep) => source === dep || source.startsWith(dep + "/")
54+
)
55+
) {
56+
return false;
57+
}
4858
if (
4959
Object.keys({
5060
...pkg.dependencies,

packages/react/package.json

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -61,22 +61,18 @@
6161
"@blocknote/core": "0.51.4",
6262
"@emoji-mart/data": "^1.2.1",
6363
"@floating-ui/react": "^0.27.18",
64-
"@floating-ui/utils": "^0.2.10",
6564
"@tanstack/react-store": "0.7.7",
6665
"@tiptap/core": "^3.13.0",
6766
"@tiptap/pm": "^3.13.0",
6867
"@tiptap/react": "^3.13.0",
69-
"@types/use-sync-external-store": "1.5.0",
7068
"emoji-mart": "^5.6.0",
7169
"fast-deep-equal": "^3.1.3",
72-
"lodash.merge": "^4.6.2",
73-
"react-icons": "^5.5.0",
7470
"use-sync-external-store": "1.6.0"
7571
},
7672
"devDependencies": {
7773
"@types/lodash.foreach": "^4.5.9",
7874
"@types/lodash.groupby": "^4.6.9",
79-
"@types/lodash.merge": "^4.6.9",
75+
"react-icons": "^5.5.0",
8076
"@types/react": "^19.2.3",
8177
"@types/react-dom": "^19.2.3",
8278
"@vitejs/plugin-react": "^6.0.1",
@@ -91,6 +87,9 @@
9187
"vite-plugin-externalize-deps": "^0.10.0",
9288
"vitest": "^4.1.2"
9389
},
90+
"optionalDependencies": {
91+
"@types/use-sync-external-store": "1.5.0"
92+
},
9493
"peerDependencies": {
9594
"react": "^18.0 || ^19.0 || >= 19.0.0-rc",
9695
"react-dom": "^18.0 || ^19.0 || >= 19.0.0-rc"

packages/react/src/components/FormattingToolbar/DefaultButtons/BasicTextStyleButton.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import {
66
formatKeyboardShortcut,
77
} from "@blocknote/core";
88
import { useCallback } from "react";
9-
import { IconType } from "react-icons";
9+
import type { IconType } from "../../../icons.js";
1010
import {
1111
RiBold,
1212
RiCodeFill,

0 commit comments

Comments
 (0)