Skip to content

Commit a011609

Browse files
committed
build: code-split the locales
1 parent 47d93bc commit a011609

File tree

7 files changed

+20
-11
lines changed

7 files changed

+20
-11
lines changed

examples/09-ai/01-minimal/App.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,11 @@ import {
1515
import {
1616
AIMenuController,
1717
AIToolbarButton,
18-
locales as aiLocales,
1918
createAIExtension,
2019
createBlockNoteAIClient,
2120
getAISlashMenuItems,
2221
} from "@blocknote/xl-ai";
22+
import { en as aiEn } from "@blocknote/xl-ai/locales";
2323
import "@blocknote/xl-ai/style.css";
2424
import { getEnv } from "./getEnv.js";
2525

@@ -58,7 +58,7 @@ export default function App() {
5858
const editor = useCreateBlockNote({
5959
dictionary: {
6060
...en,
61-
ai: aiLocales.en, // add default translations for the AI extension
61+
ai: aiEn, // add default translations for the AI extension
6262
},
6363
// Register the AI extension
6464
extensions: [

examples/09-ai/02-playground/App.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,13 @@ import {
2020
import {
2121
AIMenuController,
2222
AIToolbarButton,
23-
locales as aiLocales,
2423
createAIExtension,
2524
createBlockNoteAIClient,
2625
getAIExtension,
2726
getAISlashMenuItems,
2827
llmFormats,
2928
} from "@blocknote/xl-ai";
29+
import { en as aiEn } from "@blocknote/xl-ai/locales";
3030
import "@blocknote/xl-ai/style.css";
3131
import { Fieldset, MantineProvider, Switch } from "@mantine/core";
3232

@@ -88,7 +88,7 @@ export default function App() {
8888
const editor = useCreateBlockNote({
8989
dictionary: {
9090
...en,
91-
ai: aiLocales.en, // add default translations for the AI extension
91+
ai: aiEn, // add default translations for the AI extension
9292
},
9393
// Register the AI extension
9494
extensions: [

examples/09-ai/03-custom-ai-menu-items/App.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,12 @@ import {
1616
AIMenu,
1717
AIMenuController,
1818
AIToolbarButton,
19-
locales as aiLocales,
2019
createAIExtension,
2120
createBlockNoteAIClient,
2221
getAISlashMenuItems,
2322
getDefaultAIMenuItems,
2423
} from "@blocknote/xl-ai";
24+
import { en as aiEn } from "@blocknote/xl-ai/locales";
2525
import "@blocknote/xl-ai/style.css";
2626
import { getEnv } from "./getEnv.js";
2727

@@ -62,7 +62,7 @@ export default function App() {
6262
const editor = useCreateBlockNote({
6363
dictionary: {
6464
...en,
65-
ai: aiLocales.en, // add default translations for the AI extension
65+
ai: aiEn, // add default translations for the AI extension
6666
},
6767
// Register the AI extension
6868
extensions: [

examples/09-ai/04-with-collaboration/App.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,11 @@ import {
1515
import {
1616
AIMenuController,
1717
AIToolbarButton,
18-
locales as aiLocales,
1918
createAIExtension,
2019
createBlockNoteAIClient,
2120
getAISlashMenuItems,
2221
} from "@blocknote/xl-ai";
22+
import { en as aiEn } from "@blocknote/xl-ai/locales";
2323
import "@blocknote/xl-ai/style.css";
2424
import { useEffect, useState } from "react";
2525
import YPartyKitProvider from "y-partykit/provider";
@@ -104,7 +104,7 @@ export default function App() {
104104
},
105105
dictionary: {
106106
...en,
107-
ai: aiLocales.en, // add default translations for the AI extension
107+
ai: aiEn, // add default translations for the AI extension
108108
},
109109
// Register the AI extension
110110
extensions: [

packages/xl-ai/package.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,11 @@
4848
"import": "./dist/style.css",
4949
"require": "./dist/style.css",
5050
"style": "./dist/style.css"
51+
},
52+
"./locales": {
53+
"types": "./types/src/i18n/locales/index.d.ts",
54+
"import": "./dist/locales.js",
55+
"require": "./dist/locales.cjs"
5156
}
5257
},
5358
"scripts": {

packages/xl-ai/src/index.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,5 @@ export * from "./components/FormattingToolbar/AIToolbarButton.js";
1111
export * from "./components/SuggestionMenu/getAISlashMenuItems.js";
1212

1313
export * from "./i18n/dictionary.js";
14-
export * as locales from "./i18n/locales/index.js";
1514

1615
export * from "./api/index.js";

packages/xl-ai/vite.config.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,14 @@ export default defineConfig((conf) => ({
3030
build: {
3131
sourcemap: true,
3232
lib: {
33-
entry: path.resolve(__dirname, "src/index.ts"),
33+
entry: {
34+
"blocknote-xl-ai": path.resolve(__dirname, "src/index.ts"),
35+
locales: path.resolve(__dirname, "src/i18n/locales/index.ts"),
36+
},
3437
name: "blocknote-xl-ai",
35-
fileName: "blocknote-xl-ai",
38+
formats: ["es", "cjs"],
39+
fileName: (format, entryName) =>
40+
format === "es" ? `${entryName}.js` : `${entryName}.cjs`,
3641
},
3742
rollupOptions: {
3843
// make sure to externalize deps that shouldn't be bundled

0 commit comments

Comments
 (0)