renoun@7.0.0
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() } }