Releases: souporserious/renoun
[email protected]
Minor Changes
-
abb441d: Improves error handling for the
CodeBlock
component when falsey values are provided. -
0b6e426: Adds
sort
method toDirectory
to allow sorting all entries within each directory:import { Directory, isFileWithExtension } from 'renoun' type PostType = { frontmatter: { title: string } } const posts = new Directory<{ mdx: PostType }>({ path: 'posts' }) .filter((entry) => isFileWithExtension(entry, 'mdx')) .sort(async (a, b) => { const aFrontmatter = await a.getExport('frontmatter').getRuntimeValue() const bFrontmatter = await b.getExport('frontmatter').getRuntimeValue() return aFrontmatter.title.localeCompare(bFrontmatter.title) }) const files = await posts.getEntries() // JavaScriptFile<PostType>[] sorted by front matter title
-
cac71c1: Improves
<VirtualFileSystem>.transpileFile
error handling. -
2c55b51: Adds
filter
method toDirectory
to allow filtering all entries within each directory:import { Directory, isFileWithExtension } from 'renoun' type PostType = { frontmatter: { title: string } } const posts = new Directory<{ mdx: PostType }>({ path: 'posts' }).filter( (entry) => isFileWithExtension(entry, 'mdx') ) const files = await posts.getEntries() // JavaScriptFile<PostType>[]
-
40c6cdd: Scopes
VirtualFileSystem
using aprojectId
added to the baseFileSystem
class. This ensures the TypeScript project is unique to the virtual file system it is instantiated with.
Patch Changes
- 1c77620: Fixes the
<Directory>.getEntries
methodrecursive
option to only recurse ingetEntries
instead of the file system.
[email protected]
Minor Changes
-
e71de2f: Adds
shouldFormat
prop toCodeBlock
component to allow disabling code formatting. This is useful for MDX code blocks that are already formatted by an IDE or CI environment.export function useMDXComponents() { return { pre: (props) => { return <CodeBlock shouldFormat={false} {...restProps} /> }, } }
-
f44b9c5: Adds support for passing an array to
isFileWithExtension
and<File>.hasExtension
.
Patch Changes
[email protected]
[email protected]
Minor Changes
-
9d67bdf: Add
getFiles
andgetDirectories
toDirectory
. -
1bd1de3: Adds
hasExtension
method toFile
to help constrain the type:import { Directory } from 'renoun/file-system' const posts = new Directory<{ mdx: { frontmatter: { title: string } } }>({ path: 'posts', }) const mdxFiles = await posts .getFiles() .filter((post) => post.hasExtension('mdx'))
-
4d263fe: Add
includeIndexAndReadme
option togetEntries
for controlling default filtering ofindex
andreadme
files. -
e09a837: Adds
isFileWithExtension
utility:const fileSystem = new VirtualFileSystem({ 'Button.tsx': '', }) const directory = new Directory<{ tsx: { metadata: {} } }>({ fileSystem, }) const file = await directory.getFileOrThrow('Button') if (isFileWithExtension(file, 'tsx')) { // file is typed as File<{ tsx: { metadata: {} } }> }
-
a36058f: Add
getEditPath
method toJavaScriptFileExport
.
[email protected]
Minor Changes
-
16a475f: Adds javascript file export metadata to
renoun/file-system
:import { VirtualFileSystem, Directory } from 'renoun/file-system' const fileSystem = new VirtualFileSystem({ 'index.ts': `/**\n * Say hello.\n * @category greetings\n */\nexport default function hello() {}`, }) const directory = new Directory({ fileSystem }) const file = await directory.getFileOrThrow('index', 'ts') const fileExport = file.getExport('default') await fileExport.getName() // 'hello' await fileExport.getDescription() // 'Say hello.' await fileExport.getTags() // [{ name: 'category', value: 'greetings' }]
Patch Changes
- e1b908e: Removes
async
modifier forCodeInline
component to prevent type errors.
[email protected]
Major Changes
-
90bbe5b: Simplifies how
baseDirectory
works forCollection
. This was from a legacy implementation that was not well thought out and caused confusion. This change makes it more explicit and easier to understand.Breaking Changes
The
baseDirectory
option forCollection
is now required to be separate fromfilePattern
:import { Collection } from 'renoun/collections' const components = new Collection({ -- filePattern: 'src/components/**/*.ts', ++ filePattern: '**/*.ts', -- baseDirectory: 'components', ++ baseDirectory: 'src/components', })
-
93da61f: Introduces more performant, type-safe file system from utilities exported from
renoun/file-system
to replace therenoun/collections
API, which will be removed in a future major release.- New Classes:
NodeFileSystem
,VirtualFileSystem
,Directory
,File
,JavaScriptFile
, andJavaScriptFileExport
.
- Improvements:
- Optimized performance, stronger TypeScript support, and in-memory support with
VirtualFileSystem
.
- Optimized performance, stronger TypeScript support, and in-memory support with
Migration Example
Before:
const collection = new Collection({ filePattern: 'src/**/*.{ts,tsx}', baseDirectory: 'src', }) const sources = await collection.getSources()
After:
const directory = new Directory({ path: 'src' }) const entries = await directory.getEntries()
The new file system utilities offer clearer APIs, better performance, and improved developer experience. This is still experimental and API parity with the old collections API is still in progress. Please report any issues you encounter.
- New Classes:
-
7cbb112: Updates the
<Collection>.getSource
method to be asynchronous and return aPromise
that resolves to the source. This allows for more flexibility for a source to communicate with the web socket server.Breaking Changes
The
getSource
method for aCollection
andCompositeCollection
now returns aPromise
that resolves to the source. This means that you will need toawait
the result when calling this method:import { Collection } from 'renoun/collections' const posts = new Collection({ filePattern: 'posts/*.mdx', }) export default async function Page({ params }: { params: Promise<{ slug: string }> }) { -- const post = posts.getSource(params.slug) ++ const post = await posts.getSource(params.slug) if (!post) { return <div>Post not found</div> } const Content = await post.getExport('default').getValue() return <Content /> }
Minor Changes
-
b2ba1e4: Adds
renoun/server
export for more control of running the WebSocket server. For example, in Next.js this can be used with theinstrumentation.ts
file:import { createServer } from 'renoun/server' export async function register() { if ( process.env.NODE_ENV === 'development' && process.env.NEXT_RUNTIME === 'nodejs' ) { createServer() } }
Patch Changes
- 359e5e7: Fixes
APIReference
component not allowingFileSystemSource
. - ef4448e: Fixes client and server collections getting out of sync causing an error when resolving types from updated files.
- 7020585: Updates all dependencies to latest version.
- Updated dependencies [7020585]
- @renoun/[email protected]
@renoun/[email protected]
Patch Changes
- 7020585: Updates all dependencies to latest version.
[email protected]
Minor Changes
- cd963a0: Marks pseudo-private methods in collection classes as these are not meant to be used publicly and will not adhere to semver.
- 7642f56: Filters out private class members that start with
#
or_
when using<Export>.getType()
.
Patch Changes
- 72a2e98: Fixes specifying a
language
for inline MDX code. - eca091b: Fixes constraint text in generated generics text.
- 6753e12: Waits for any active refreshing source files before resolving types.
- 9ac5434: Fixes bug in
CodeBlock
when targeting renoun filenames. TheCodeBlock
source files now use a unique identifier that does not clash with renoun exports. - 619abd9: Fixes class type resolution not accounting for filter and file dependencies.
- Updated dependencies [72a2e98]
- @renoun/[email protected]
@renoun/[email protected]
Minor Changes
- 72a2e98: Fixes specifying a
language
for inline MDX code.
[email protected]
Major Changes
-
0e6279a: Removes the deprecated
collection
function.Breaking Changes
The
collection
function has been removed. You can now use theCollection
class directly to create a collection:import { Collection } from 'renoun/collections' const posts = new Collection({ filePattern: 'posts/*.mdx', })
Minor Changes
-
ebdfb16: Adds
getFileSystemPath
method toFileSystemSource
andExportSource
to allow getting types for a file inAPIReference
. -
489960a: Adds the ability to specify the set of languages loaded for syntax highlighting using the
languages
field in therenoun.json
configuration file. This allows you to reduce the bundle size by only loading the languages you need:{ "languages": ["sh", "ts", "tsx"] }
-
ed8fb6a: Adds support for formatting the
CodeBlock
component source text usingprettier
if it is available to the workspace.
Patch Changes
- cab837b: Fixes issue with trying to format dynamic imports added to collections from CLI causing issues with linters. Now, formatting will only occur if the workspace has access to
prettier
.