Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Lexical][UI Gallery] Fix meta lexical website intern build errors #19

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
80 changes: 48 additions & 32 deletions packages/lexical-website/docusaurus.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@
const {github: lightCodeTheme, dracula: darkCodeTheme} =
require('prism-react-renderer').themes;
const slugifyPlugin = require('./src/plugins/lexical-remark-slugify-anchors');
const {packagesManager} = require('../../scripts/shared/packagesManager');
const {packagesManager} = process.env.FB_INTERNAL
? {}
: require('../../scripts/shared/packagesManager');
Comment on lines +16 to +18
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

category Functionality

The current implementation uses a ternary operator to conditionally import the packagesManager based on the FB_INTERNAL environment variable. While this approach works, it might lead to potential issues if the FB_INTERNAL environment variable is not set correctly or if there are differences in the package structure between internal and external builds. Consider using a more robust method for handling environment-specific imports, such as dynamic imports or separate build configurations for internal and external environments. This will ensure that the correct packages are always imported regardless of the build environment.

Chat with Korbit by mentioning @korbit-ai, and give a 👍 or 👎 to help Korbit improve your reviews.

const path = require('node:path');

const TITLE = 'Lexical';
Expand Down Expand Up @@ -170,15 +172,20 @@ const sidebarItemsGenerator = async ({
/** @type {Partial<import('docusaurus-plugin-typedoc/dist/types').PluginOptions>} */
const docusaurusPluginTypedocConfig = {
...sourceLinkOptions(),
entryPoints: packagesManager
.getPublicPackages()
.flatMap((pkg) =>
pkg
.getExportedNpmModuleEntries()
.map((entry) => [
path.relative(__dirname, pkg.resolve('src', entry.sourceFileName)),
]),
),
entryPoints: process.env.FB_INTERNAL
? []
: packagesManager
.getPublicPackages()
.flatMap((pkg) =>
pkg
.getExportedNpmModuleEntries()
.map((entry) => [
path.relative(
__dirname,
pkg.resolve('src', entry.sourceFileName),
),
]),
),
excludeInternal: true,
plugin: [
'./src/plugins/lexical-typedoc-plugin-no-inherit',
Expand Down Expand Up @@ -233,21 +240,23 @@ const config = {
onBrokenMarkdownLinks: 'throw',
organizationName: 'facebook',
plugins: [
[
'./plugins/package-docs',
/** @type {import('./plugins/package-docs').PackageDocsPluginOptions} */
{
baseDir: path.resolve(__dirname, '..'),
editUrl: `${GITHUB_REPO_URL}/tree/main/packages/`,
packageFrontMatter: {
lexical: [
'sidebar_position: 1',
'sidebar_label: lexical (core)',
].join('\n'),
},
targetDir: path.resolve(__dirname, 'docs/packages'),
},
],
process.env.FB_INTERNAL
? null
: [
'./plugins/package-docs',
/** @type {import('./plugins/package-docs').PackageDocsPluginOptions} */
{
baseDir: path.resolve(__dirname, '..'),
editUrl: `${GITHUB_REPO_URL}/tree/main/packages/`,
packageFrontMatter: {
lexical: [
'sidebar_position: 1',
'sidebar_label: lexical (core)',
].join('\n'),
},
targetDir: path.resolve(__dirname, 'docs/packages'),
},
],
'./plugins/webpack-buffer',
['docusaurus-plugin-typedoc', docusaurusPluginTypedocConfig],
async function tailwindcss() {
Expand All @@ -260,7 +269,7 @@ const config = {
name: 'docusaurus-tailwindcss',
};
},
],
].filter((plugin) => plugin != null),

presets: [
[
Expand All @@ -274,6 +283,7 @@ const config = {
docs: {
beforeDefaultRemarkPlugins: [slugifyPlugin],
editUrl: `${GITHUB_REPO_URL}/tree/main/packages/lexical-website/`,
exclude: ['/error'],
path: 'docs',
sidebarItemsGenerator,
sidebarPath: require.resolve('./sidebars.js'),
Expand Down Expand Up @@ -377,12 +387,18 @@ const config = {
sidebarId: 'docs',
type: 'docSidebar',
},
{
label: 'API',
position: 'left',
sidebarId: 'api',
type: 'docSidebar',
},
process.env.FB_INTERNAL
? {
href: 'https://lexical.dev/docs/api/',
label: 'API',
position: 'left',
}
: {
label: 'API',
position: 'left',
sidebarId: 'api',
type: 'docSidebar',
},

{label: 'Community', position: 'left', to: '/community'},
{
Expand Down
24 changes: 15 additions & 9 deletions packages/lexical-website/sidebars.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,16 +53,22 @@ const sidebars = {
label: 'Concepts',
type: 'category',
},
{
items: [
{
dirName: 'packages',
type: 'autogenerated',
process.env.FB_INTERNAL
? {
href: 'https://lexical.dev/docs/packages/lexical',
label: 'Packages',
type: 'link',
}
: {
items: [
{
dirName: 'packages',
type: 'autogenerated',
},
],
label: 'Packages',
type: 'category',
},
],
label: 'Packages',
type: 'category',
},
{
items: [{dirName: 'react', type: 'autogenerated'}],
label: 'React',
Expand Down
Loading