diff --git a/.changeset/breezy-dryers-raise.md b/.changeset/breezy-dryers-raise.md new file mode 100644 index 0000000000..f2f843f48e --- /dev/null +++ b/.changeset/breezy-dryers-raise.md @@ -0,0 +1,5 @@ +--- +'nextra': patch +--- + +remove `jsx-runtime.cjs`, import runtime from 'react/jsx-runtime' diff --git a/.gitignore b/.gitignore index 346b276368..f9136cb436 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,6 @@ .DS_Store .next/ +.tsup/ node_modules/ *.log dist/ diff --git a/README.md b/README.md index ebdfd4d718..88375301e2 100644 --- a/README.md +++ b/README.md @@ -47,6 +47,9 @@ the watch mode for both nextra and the theme in separated terminals.
- Speakeasy + Speakeasy preview + + + xyflow preview
diff --git a/docs/app/_meta.ts b/docs/app/_meta.ts index 3fb850bfc6..0e94ab3c4f 100644 --- a/docs/app/_meta.ts +++ b/docs/app/_meta.ts @@ -7,33 +7,42 @@ export default { type: 'page', title: 'Documentation' }, - showcase: { - type: 'page', - theme: { - typesetting: 'article', - layout: 'full' - } - }, - about: { - type: 'page', - theme: { - typesetting: 'article' - } - }, - version: { + versions: { type: 'menu', - title: 'Version', + title: 'Versions', items: { - _3: { + '3': { title: 'Nextra v3 Docs ↗', href: 'https://nextra-v2-pyibc76cq-shud.vercel.app', newWindow: true }, - _2: { + '2': { title: 'Nextra v2 Docs ↗', href: 'https://nextra-v2-oe0zrpzjp-shud.vercel.app', newWindow: true } } - } + }, + about: { + type: 'page', + theme: { + typesetting: 'article' + } + }, + showcase: { + type: 'page', + theme: { + typesetting: 'article', + layout: 'full', + timestamp: false + } + }, + sponsors: { + type: 'page', + title: 'Sponsors', + theme: { + typesetting: 'article', + timestamp: false + } + }, } diff --git a/docs/app/about/page.mdx b/docs/app/about/page.mdx index 1038b13217..ac84b082e9 100644 --- a/docs/app/about/page.mdx +++ b/docs/app/about/page.mdx @@ -1,5 +1,3 @@ -import { Cards } from 'nextra/components' - export const metadata = { sidebarTitle: 'About' } @@ -10,15 +8,28 @@ Nextra was initially created by [Vercel](https://vercel.com) members [Shu Ding](https://twitter.com/shuding_) and [Paco Coursey](https://twitter.com/pacocoursey) in 2020. Since 2021, [Yixuan Xu](https://twitter.com/yixuanxu94) contributed tremendously to the -project. In 2022, [Dimitri Postolov](https://twitter.com/dimaMachina_) from +project. + +In 2022, [Dimitri Postolov](https://twitter.com/dimaMachina_) from [The Guild](https://the-guild.dev) joined the core team to help with the -development of 2.0. +development of Nextra 2. + +In 2024 Nextra 3 was released, current primary maintainer +[Dimitri Postolov](https://twitter.com/dimaMachina_) fully developed it, and +[Oscar Xie](https://github.com/87xie) +[actively contributed](https://github.com/shuding/nextra/pulls?q=sort%3Aupdated-desc+is%3Apr+author%3A87xie+is%3Aclosed+created%3A%3C2024-10-03) +to this release. + +In 2024 Nextra 4 prerelease with [App Router](https://nextjs.org/docs/app) +support was released, [Dimitri Postolov](https://twitter.com/dimaMachina_) fully +developed it too. Currently, it's under development and +[we are receiving feedback](https://github.com/shuding/nextra/issues/2600#issuecomment-2385107206). ## Team -Currently, the project is maintained by [Shu Ding](https://twitter.com/shuding_) -and [Dimitri Postolov](https://twitter.com/dimaMachina_). You can check out the -full list of contributors on +Currently, the project is maintained by +[Dimitri Postolov](https://twitter.com/dimaMachina_). You can check out the full +list of contributors on [GitHub](https://github.com/shuding/nextra/graphs/contributors). ## Credits @@ -53,16 +64,3 @@ product. ## License The Nextra project and themes are licensed under the MIT license. - -## Sponsors - - - - <>![Speakeasy](../showcase/_logos/speakeasy.png) - - diff --git a/docs/app/docs/guide/organize-files/page.mdx b/docs/app/docs/guide/organize-files/page.mdx index 364e455cbc..52baefcfeb 100644 --- a/docs/app/docs/guide/organize-files/page.mdx +++ b/docs/app/docs/guide/organize-files/page.mdx @@ -77,12 +77,55 @@ page: - - It's also possible to use the `.jsx`, `.ts`, `.tsx` extensions for `_meta` - files (e.g. `_meta.ts`) - +### Allowed Extensions -For example, you can put this in your `pages/_meta.js` file: +It's possible to use the `.jsx`, `.ts` and `.tsx` extensions for `_meta` files +as well (e.g. `_meta.ts`). + +### Sorting Pages Alphabetically + +You can use ESLint's built-in `sort-keys` rule, append +`/* eslint sort-keys: error */` comment at the top of your `_meta` file, and you +will receive ESLint's errors about incorrect order. + +### Usage with `next-sitemap` + +If you are using +[next-sitemap](https://github.com/iamvishnusankar/next-sitemap), you will +probably need to add `exclude: ['*/_meta']{:js}` to your +`next-sitemap.config.js` file, as it is +[tricky to exclude `_meta` files from the build](https://github.com/vercel/next.js/issues/8974#issuecomment-542525837). + +### Allowed Keys Values + +The type of your `_meta` keys should be always `string` and not `number` since +[numbers are always ordered first](https://dev.to/frehner/the-order-of-js-object-keys-458d) +for JavaScript objects. + +Following: + +```js filename="pages/_meta.js" +export default { + foo: '', + 1992_10_21: '', + 1: '' +} +``` + +Will be converted to: + +{/* prettier-ignore */} +```js filename="pages/_meta.js" +export default { + '1': '', + '19921021': '', + foo: '' +} +``` + +## Example + +Put this in your `pages/_meta.js` file: ```js filename="pages/_meta.js" export default { @@ -108,18 +151,6 @@ export default { } ``` - - You can use ESLint's built-in rule sort keys with a `/* eslint sort-keys: - error */` comment to sort your sidebar items alphabetically. - - - - If you are using - [next-sitemap](https://github.com/iamvishnusankar/next-sitemap), you will - probably need to add `exclude: ['*/_meta']` to your `next-sitemap.config.js` - file, as it is tricky to exclude `_meta` files from the build. - - The extra configurations are passed to the **theme** as additional information. Check the corresponding pages for more information: diff --git a/docs/app/showcase/_logos/react-flow.jpg b/docs/app/showcase/_logos/react-flow.jpg new file mode 100644 index 0000000000..c085ea5227 Binary files /dev/null and b/docs/app/showcase/_logos/react-flow.jpg differ diff --git a/docs/app/showcase/_logos/svelte-flow.jpg b/docs/app/showcase/_logos/svelte-flow.jpg new file mode 100644 index 0000000000..42d88a98a2 Binary files /dev/null and b/docs/app/showcase/_logos/svelte-flow.jpg differ diff --git a/docs/app/showcase/_logos/xyflow.jpg b/docs/app/showcase/_logos/xyflow.jpg new file mode 100644 index 0000000000..f145289660 Binary files /dev/null and b/docs/app/showcase/_logos/xyflow.jpg differ diff --git a/docs/app/showcase/page.mdx b/docs/app/showcase/page.mdx index 5360440bf8..131c59d23f 100644 --- a/docs/app/showcase/page.mdx +++ b/docs/app/showcase/page.mdx @@ -3,196 +3,173 @@ import { Cards } from 'nextra/components'
# Showcase -{

Open source -projects powered by Nextra

} - +

+ {'Open source projects powered by Nextra'} +

- + + <>![Speakeasy preview](./_logos/speakeasy.png) + + + <>![React Flow preview](./_logos/react-flow.jpg) + + + <>![Svelte Flow preview](./_logos/svelte-flow.jpg) + + <>![The Graph preview](./_logos/thegraph.jpeg) - - + + <>![GraphQL preview](./_logos/graphql.png) - - + + <>![SWR preview](./_logos/swr.png) - - + + <>![COBE preview](./_logos/cobe.png) - - + <>![JavaScript Patterns preview](./_logos/javascript-patterns.jpg) - - + <>![CodeSandbox preview](./_logos/codesandbox.jpg) - - + + <>![DocsGPT preview](./_logos/docsgpt.png) - - + + <>![CloudQuery preview](./_logos/cloudquery.svg) - - + + <>![Edge Runtime preview](./_logos/edge-runtime.jpeg) - - + + <>![Livepeer preview](./_logos/livepeer.png) - - + + <>![Sound.xyz preview](./_logos/sound.xyz.png) - - - <>![Speakeasy preview](./_logos/speakeasy.png) - - + + <>![Panda preview](./_logos/panda.png) - - + + <>![Kuma UI preview](./_logos/kuma-ui.png) - - + + <>![Langfuse Open Source LLM Engineering Platform](./_logos/langfuse.png) - - + + <>![The Guild Blog preview](./_logos/the-guild.png) - - + + <>![GraphQL Hive preview](./_logos/graphql-hive.png) - - + + <>![GraphQL Yoga preview](./_logos/graphql-yoga.png) - - + + <>![GraphQL Envelop preview](./_logos/graphql-envelop.png) - - + <>![GraphQL Inspector preview](./_logos/graphql-inspector.png) - - + <>![GraphQL Code Generator preview](./_logos/graphql-codegen.png) - - + + <>![GraphQL Mesh preview](./_logos/graphql-mesh.png) - - + + <>![GraphQL Tools preview](./_logos/graphql-tools.png) - - + + <>![GraphQL Modules preview](./_logos/graphql-modules.png) - - + + <>![GraphQL ESLint preview](./_logos/graphql-eslint.png) - - + + <>![GraphQL Config preview](./_logos/graphql-config.png) - - + + <>![GraphQL Scalars preview](./_logos/graphql-scalars.png) - - + + <>![GraphQL Shield preview](./_logos/graphql-shield.png) - - + + <>![GraphQL SOFA preview](./_logos/graphql-sofa.png) - - + <>![Apollo Angular preview](./_logos/apollo-angular.png) - - + + <>![KitQL preview](./_logos/kitql.png) - - + + <>![GraphQL SSE preview](./_logos/graphql-sse.png) - - + + <>![GraphQL WS preview](./_logos/graphql-ws.png) - - + + <>![feTS preview](./_logos/fets.png) - - + <>![JavaScript Code Challenges preview](./_logos/jscodechallenges.png) - - + + <>![React Cosmos preview](./_logos/react-cosmos.png) - - + + <>![Typia preview](./_logos/typia.png) - - + + <>![Nestia preview](./_logos/nestia.png) - - + + <>![Safe preview](./_logos/safe-core.png) - - + + <>![Auth.js preview](./_logos/authjs.png) - - + + <>![imgix preview](./_logos/imgix.png) - - + + <>![AnythingLLM preview](./_logos/anythingllm.png) - + -export const ShowcaseCard = Object.assign( +export const Card = Object.assign( // Copy card component and add default props Cards.Card.bind(), { - displayName: 'ShowcaseCard', + displayName: 'Card', defaultProps: { arrow: true, - target: '_blank' + target: '_blank', + rel: 'noreferrer' } } ) diff --git a/docs/app/sponsors.mdx b/docs/app/sponsors.mdx new file mode 100644 index 0000000000..817b684812 --- /dev/null +++ b/docs/app/sponsors.mdx @@ -0,0 +1,38 @@ +import { Button, Cards } from 'nextra/components' +import { Card } from './showcase.mdx' + +

+ {'Sponsors'} +

+ +

+ {'Your sponsorship means a lot to open source projects, including Nextra'} +

+ + + +{/*

Organization Sponsors

*/} + + + + <>![Speakeasy preview](./showcase/speakeasy.png) + + + <>![xyflow preview](./showcase/xyflow.jpg) + + diff --git a/examples/swr-site/mdx/es/docs/getting-started.mdx b/examples/swr-site/mdx/es/docs/getting-started.mdx index 441259c1e5..9850ef8a22 100644 --- a/examples/swr-site/mdx/es/docs/getting-started.mdx +++ b/examples/swr-site/mdx/es/docs/getting-started.mdx @@ -1,4 +1,4 @@ -import { Callout } from 'nextra/components' +import { Callout, Steps } from 'nextra/components' # Comienza @@ -17,12 +17,16 @@ import { Callout } from 'nextra/components' ## Instalación -Dentro del directorio de su proyecto React, ejecute lo siguiente: + -```bash npm2yarn +### Dentro del directorio de su proyecto React, ejecute lo siguiente: + +```sh npm2yarn npm i swr ``` + + ## Inicio rápido Para APIs RESTFul normales con datos JSON, primero necesita crear una función diff --git a/packages/nextra-theme-blog/CHANGELOG.md b/packages/nextra-theme-blog/CHANGELOG.md index 90982b9e72..d219e593a2 100644 --- a/packages/nextra-theme-blog/CHANGELOG.md +++ b/packages/nextra-theme-blog/CHANGELOG.md @@ -67,6 +67,18 @@ - Updated dependencies [99f34d3] - nextra@4.0.0-app-router.0 +## 3.0.3 + +### Patch Changes + +- 9d93caf: RTL support for the `` component. +- 5fbce2f: Added golang logo for code blocks. +- Updated dependencies [82fc267] +- Updated dependencies [edc6c29] +- Updated dependencies [9d93caf] +- Updated dependencies [5fbce2f] + - nextra@3.0.3 + ## 3.0.2 ### Patch Changes diff --git a/packages/nextra-theme-blog/tsconfig.json b/packages/nextra-theme-blog/tsconfig.json index eea21afb56..c07ac2af5b 100644 --- a/packages/nextra-theme-blog/tsconfig.json +++ b/packages/nextra-theme-blog/tsconfig.json @@ -2,16 +2,14 @@ "compilerOptions": { "target": "es2018", "module": "ESNext", - "declaration": false, + "declaration": true, "noEmit": true, "esModuleInterop": true, "strict": true, "skipLibCheck": true, - "allowJs": true, "jsx": "react-jsx", "moduleResolution": "Node", - "types": ["vitest/globals"], - "resolveJsonModule": true + "types": ["vitest/globals"] }, "exclude": ["dist"] } diff --git a/packages/nextra-theme-docs/CHANGELOG.md b/packages/nextra-theme-docs/CHANGELOG.md index 71c6004905..359a092010 100644 --- a/packages/nextra-theme-docs/CHANGELOG.md +++ b/packages/nextra-theme-docs/CHANGELOG.md @@ -118,6 +118,18 @@ - Updated dependencies [99f34d3] - nextra@4.0.0-app-router.0 +## 3.0.3 + +### Patch Changes + +- 9d93caf: RTL support for the `` component. +- 5fbce2f: Added golang logo for code blocks. +- Updated dependencies [82fc267] +- Updated dependencies [edc6c29] +- Updated dependencies [9d93caf] +- Updated dependencies [5fbce2f] + - nextra@3.0.3 + ## 3.0.2 ### Patch Changes diff --git a/packages/nextra-theme-docs/postcss.config.mjs b/packages/nextra-theme-docs/postcss.config.mjs index a221115d65..01cec1d1bf 100644 --- a/packages/nextra-theme-docs/postcss.config.mjs +++ b/packages/nextra-theme-docs/postcss.config.mjs @@ -5,7 +5,7 @@ export default { 'tailwindcss/nesting': {}, tailwindcss: {}, 'postcss-lightningcss': { - browsers: '>= .25%' + browsers: '>= .25% and not dead' } } } diff --git a/packages/nextra-theme-docs/tsconfig.json b/packages/nextra-theme-docs/tsconfig.json index 52cd294597..75a384093e 100644 --- a/packages/nextra-theme-docs/tsconfig.json +++ b/packages/nextra-theme-docs/tsconfig.json @@ -2,17 +2,15 @@ "compilerOptions": { "target": "es2018", "module": "ESNext", - "declaration": false, + "declaration": true, "noEmit": true, "esModuleInterop": true, "strict": true, "skipLibCheck": true, - "allowJs": true, "jsx": "react-jsx", "moduleResolution": "node", "lib": ["ESNext", "DOM"], - "types": ["vitest/globals"], - "resolveJsonModule": true + "types": ["vitest/globals"] }, "exclude": ["dist"] } diff --git a/packages/nextra/CHANGELOG.md b/packages/nextra/CHANGELOG.md index fb729bc731..941296906a 100644 --- a/packages/nextra/CHANGELOG.md +++ b/packages/nextra/CHANGELOG.md @@ -37,6 +37,16 @@ Router, something may be broken, check https://github.com/shuding/nextra/tree/v4-v2/examples for the migration guide +## 3.0.3 + +### Patch Changes + +- 82fc267: remove + `Critical dependency: the request of a dependency is an expression` warnings +- edc6c29: remove `truthy()` helper function +- 9d93caf: RTL support for the `` component. +- 5fbce2f: Added golang logo for code blocks. + ## 3.0.2 ### Patch Changes diff --git a/packages/nextra/src/client/components/remote-content.tsx b/packages/nextra/src/client/components/remote-content.tsx index c115cb6b80..33adc6bc40 100644 --- a/packages/nextra/src/client/components/remote-content.tsx +++ b/packages/nextra/src/client/components/remote-content.tsx @@ -1,9 +1,14 @@ -import { jsxRuntime } from '../jsx-runtime.cjs' +import jsxDevRuntime from 'react/jsx-dev-runtime' +import jsxRuntime from 'react/jsx-runtime' import type { MDXComponents } from '../mdx.js' import { useMDXComponents } from '../mdx.js' type Scope = Record +const runtime = + process.env.NODE_ENV === 'production' ? jsxRuntime : jsxDevRuntime + + export function evaluate(compiledSource: string, scope: Scope = {}) { // if we're ready to render, we can assemble the component tree and let React do its thing // first we set up the scope which has to include the mdx custom @@ -17,7 +22,7 @@ export function evaluate(compiledSource: string, scope: Scope = {}) { // function with the actual values. const hydrateFn = Reflect.construct(Function, ['$', ...keys, compiledSource]) - return hydrateFn({ useMDXComponents, ...jsxRuntime }, ...values) + return hydrateFn({ useMDXComponents, ...runtime }, ...values) } export type RemoteContentProps = { diff --git a/packages/nextra/src/client/icons/go.svg b/packages/nextra/src/client/icons/go.svg new file mode 100644 index 0000000000..048287ffc2 --- /dev/null +++ b/packages/nextra/src/client/icons/go.svg @@ -0,0 +1,21 @@ + + + + + + + diff --git a/packages/nextra/src/client/icons/index.ts b/packages/nextra/src/client/icons/index.ts index 8456486bf5..922279c8a8 100644 --- a/packages/nextra/src/client/icons/index.ts +++ b/packages/nextra/src/client/icons/index.ts @@ -5,6 +5,7 @@ export { ReactComponent as DiscordIcon } from './discord.svg' export { ReactComponent as ExpandIcon } from './expand.svg' export { ReactComponent as GitHubIcon } from './github.svg' export { ReactComponent as GlobeIcon } from './globe.svg' +export { ReactComponent as GoIcon } from './go.svg' export { ReactComponent as InformationCircleIcon } from './information-circle.svg' export { ReactComponent as MenuIcon } from './menu.svg' export { ReactComponent as MoonIcon } from './moon.svg' diff --git a/packages/nextra/src/client/jsx-runtime.cjs b/packages/nextra/src/client/jsx-runtime.cjs deleted file mode 100644 index 77975b0b63..0000000000 --- a/packages/nextra/src/client/jsx-runtime.cjs +++ /dev/null @@ -1,13 +0,0 @@ -/* eslint-env node */ -/* eslint-disable @typescript-eslint/no-require-imports */ - -/** - * Allow jsx-runtime to be successfully imported from either React 17 or React 18. - * - * Inspired by the approach here: https://github.com/contentlayerdev/contentlayer/blob/main/packages/next-contentlayer/src/hooks/jsx-runtime.cjs - */ -if (process.env.NODE_ENV === 'development') { - module.exports.jsxRuntime = require('react/jsx-dev-runtime') -} else { - module.exports.jsxRuntime = require('react/jsx-runtime') -} diff --git a/packages/nextra/src/server/compile.ts b/packages/nextra/src/server/compile.ts index 48121f6f12..d52614729f 100644 --- a/packages/nextra/src/server/compile.ts +++ b/packages/nextra/src/server/compile.ts @@ -38,7 +38,7 @@ import { remarkRemoveImports, remarkStaticImage } from './remark-plugins/index.js' -import { logger, truthy } from './utils.js' +import { logger } from './utils.js' const cachedCompilerForFormat: Record< Exclude, @@ -192,7 +192,7 @@ export async function compileMdx( } ] satisfies Pluggable, remarkSmartypants - ].filter(truthy), + ].filter(v => !!v), rehypePlugins: [ ...(rehypePlugins || []), format === 'md' && [ @@ -234,7 +234,7 @@ export async function compileMdx( [rehypeAttachCodeMeta, { search }] ]), [rehypeExtractTocContent, { isRemoteContent }] - ].filter(truthy), + ].filter(v => !!v), recmaPlugins: [ (() => (ast: Program, file) => { const mdxContentIndex = ast.body.findIndex(node => { @@ -286,7 +286,7 @@ export async function compileMdx( }) satisfies Plugin<[], Program>, isRemoteContent ? recmaRewriteFunctionBody : recmaRewriteJsx, ...(recmaPlugins || []) - ].filter(truthy) + ].filter(v => !!v) }) } } diff --git a/packages/nextra/src/server/index.ts b/packages/nextra/src/server/index.ts index d6ac493dc2..79bc830c3a 100644 --- a/packages/nextra/src/server/index.ts +++ b/packages/nextra/src/server/index.ts @@ -15,6 +15,8 @@ const DEFAULT_EXTENSIONS = ['js', 'jsx', 'ts', 'tsx'] const AGNOSTIC_PAGE_MAP_PATH = `.next${sep}static${sep}chunks${sep}nextra-page-map` +const RE_SEP = sep === '/' ? '/' : '\\\\' + const nextra: Nextra = nextraConfig => { const { error, data: loaderOptions } = nextraConfigSchema.safeParse(nextraConfig) @@ -80,6 +82,14 @@ const nextra: Nextra = nextraConfig => { const rules = config.module.rules as RuleSetRule[] + const defaultLoaderOptions = [ + options.defaultLoaders.babel, + { + loader: 'nextra/loader', + options: loaderOptions + } + ] + rules.push( { test: MARKDOWN_EXTENSION_REGEX, @@ -101,10 +111,7 @@ const nextra: Nextra = nextraConfig => { issuer: request => (!!request && !request.includes(AGNOSTIC_PAGE_MAP_PATH)) || request === null, - use: [ - options.defaultLoaders.babel, - { loader: 'nextra/loader', options: loaderOptions } - ] + use: defaultLoaderOptions }, { // Match pages (imports without an issuer request). @@ -117,6 +124,13 @@ const nextra: Nextra = nextraConfig => { options: { ...loaderOptions, isPageImport: true } } ] + }, + { + test: new RegExp( + `@typescript${RE_SEP}vfs${RE_SEP}dist${RE_SEP}vfs\\.` + ), + issuer: request => !!request, + use: defaultLoaderOptions } ) diff --git a/packages/nextra/src/server/loader.ts b/packages/nextra/src/server/loader.ts index 36a1b2a349..f853a492a5 100644 --- a/packages/nextra/src/server/loader.ts +++ b/packages/nextra/src/server/loader.ts @@ -67,6 +67,16 @@ export async function loader( path.join(resolveData.descriptionFileRoot, resolveData.relativePath) : this.resourcePath + const currentPath = slash(mdxPath) + + if (currentPath.includes('@typescript/vfs/dist/vfs.')) { + // Fixes https://github.com/microsoft/TypeScript-Website/pull/3022 + // Fixes https://github.com/shuding/nextra/issues/3322#issuecomment-2384046618 + return source + .replace(/String\.fromCharCode\(112, ?97, ?116, ?104\)/, '"path"') + .replace(/String\.fromCharCode\(102, ?115\)/, '"fs"') + } + if (!IS_PRODUCTION && isPageMapImport) { return compileMetadata(source, { filePath: mdxPath }) } diff --git a/packages/nextra/src/server/page-map.ts b/packages/nextra/src/server/page-map.ts index 38a3619b01..1e9ef59d4e 100644 --- a/packages/nextra/src/server/page-map.ts +++ b/packages/nextra/src/server/page-map.ts @@ -16,8 +16,7 @@ import { APP_DIR } from './file-system.js' import { createAstObject, normalizePageRoute, - pageTitleFromFilename, - truthy + pageTitleFromFilename } from './utils.js' const fs = gracefulFs.promises @@ -172,7 +171,7 @@ export async function collectFiles({ }) }) - const pageMap = (await Promise.all(promises)).filter(truthy) + const pageMap = (await Promise.all(promises)).filter(v => !!v) return { // @ts-expect-error -- fixme diff --git a/packages/nextra/src/server/remark-plugins/remark-static-image.ts b/packages/nextra/src/server/remark-plugins/remark-static-image.ts index 7e81bcf47f..5f5fa8d13c 100644 --- a/packages/nextra/src/server/remark-plugins/remark-static-image.ts +++ b/packages/nextra/src/server/remark-plugins/remark-static-image.ts @@ -5,7 +5,6 @@ import slash from 'slash' import type { Plugin } from 'unified' import { visit } from 'unist-util-visit' import { EXTERNAL_URL_REGEX, PUBLIC_DIR } from '../constants.js' -import { truthy } from '../utils.js' /** * @link https://github.com/vercel/next.js/blob/6cfebfb02c2a52a1f99fca59a2eac2d704d053db/packages/next/build/webpack/loaders/next-image-loader.js#L6 @@ -99,7 +98,7 @@ export const remarkStaticImage: Plugin<[], Root> = () => ast => { } } } - ].filter(truthy) + ].filter(v => !!v) }) } diff --git a/packages/nextra/src/server/utils.ts b/packages/nextra/src/server/utils.ts index 18c335f554..b8f5c5da0c 100644 --- a/packages/nextra/src/server/utils.ts +++ b/packages/nextra/src/server/utils.ts @@ -9,12 +9,6 @@ import slash from 'slash' import title from 'title' import { DEFAULT_PROPERTY_PROPS } from './constants.js' -type Truthy = T extends false | '' | 0 | null | undefined ? never : T // from lodash - -export function truthy(value: T): value is Truthy { - return !!value -} - export const logger = { info: console.log.bind(null, '-', '\x1b[36minfo\x1b[0m', '[nextra]'), warn: console.log.bind(null, '-', '\x1b[33mwarn\x1b[0m', '[nextra]'), diff --git a/packages/nextra/tsconfig.json b/packages/nextra/tsconfig.json index 132b8d54d9..1eb9fe3278 100644 --- a/packages/nextra/tsconfig.json +++ b/packages/nextra/tsconfig.json @@ -7,12 +7,10 @@ "esModuleInterop": true, "strict": true, "skipLibCheck": true, - "allowJs": true, "jsx": "react-jsx", "lib": ["es2023", "dom"], "moduleResolution": "node", "types": ["vitest/globals"], - "resolveJsonModule": true, "paths": { "unified": ["./node_modules/unified"] } diff --git a/packages/nextra/tsup.config.ts b/packages/nextra/tsup.config.ts index df901082cf..5f3f8f17bd 100644 --- a/packages/nextra/tsup.config.ts +++ b/packages/nextra/tsup.config.ts @@ -19,11 +19,6 @@ export default defineConfig([ // Fixes hydration errors in client apps due "type": "module" in root package.json const clientPackageJSON = path.join(CWD, 'dist', 'client', 'package.json') await fs.writeFile(clientPackageJSON, '{"sideEffects":false}') - - const jsxRuntimeFrom = path.join(CWD, 'src', 'client', 'jsx-runtime.cjs') - const jsxRuntimeTo = path.join(CWD, 'dist', 'client', 'jsx-runtime.cjs') - - await fs.copyFile(jsxRuntimeFrom, jsxRuntimeTo) }, plugins: [ {