Upgrading unctx 1 to 2
Breaking1.2.0 → 2.5.0Breaking2New6Changed3Fixed6Other4
BreakingUpgrade verdict
2 breaking changes.
In plain terms
- deps: update estree-walker to v3.
- strict ctx.use and new ctx.tryUse.
Must act 2 items need code or config changes
Installs 12 packages in all (was 22).
What you must change
Breaking2
deps: update estree-walker to v3.
strict ctx.use and new ctx.tryUse.
ctx.usectx.tryUseAPI changes
Generated by DepDelta from published .d.ts files. Not mixed with prose notes.
- changed:
const getContext: <T>(key: string) => UseContext<T> → const getContext: <T>(key: string, opts?: ContextOptions) => UseContext<T> - changed:
const useContext: <T>(key: string) => () => T → const useContext: <T>(key: string, opts?: ContextOptions) => () => T - changed:
function createContext<T = any>(): UseContext<T> → function createContext<T = any>(opts?: ContextOptions): UseContext<T> - changed:
function createNamespace(): { get(key: any): UseContext<any> } → function createNamespace<T = any>(defaultOpts?: ContextOptions): { get(key: string, opts?: ContextOptions): UseContext<T> } - changed:
function executeAsync<T>(fn: AsyncFn<T>): [Promise<T>, () => void] → function executeAsync<T>(function_: AsyncFunction<T>): [Promise<T>, () => void] - changed:
function withAsyncContext<T = any>(fn: AsyncFn<T>, transformed?: boolean): AsyncFn<T> → function withAsyncContext<T = any>(function_: AsyncFunction<T>, transformed?: boolean): AsyncFunction<T> - changed:
property ContextNamespace.get: <T>(key: string) => UseContext<T> → property ContextNamespace.get: <T>(key: string, opts?: ContextOptions) => UseContext<T> - changed:
property UseContext.call: <R>(instance: T, cb: () => R) => R → property UseContext.call: <R>(instance: T, callback: () => R) => R - changed:
property UseContext.callAsync: <R>(instance: T, cb: () => R | Promise<R>) => Promise<R> → property UseContext.callAsync: <R>(instance: T, callback: () => R | Promise<R>) => Promise<R> - changed:
property UseContext.set: (instance?: T, replace?: Boolean) => void → property UseContext.set: (instance?: T, replace?: boolean) => void - changed:
property UseContext.use: () => T | null → property UseContext.use: () => T - added:
interface ContextOptions - added:
property ContextOptions.AsyncLocalStorage?: typeof AsyncLocalStorage - added:
property ContextOptions.asyncContext?: boolean
- changed:
const unctxPlugin: unplugin.UnpluginInstance<UnctxPluginOptions> → const unctxPlugin: unplugin.UnpluginInstance<UnctxPluginOptions, boolean> - added:
property UnctxPluginOptions.transformFilter?: HookFilter
- changed:
function createTransformer(options?: TransformerOptions): { transform: (code: string, opts?: { force?: false }) => { code: string; magicString: MagicString }; shouldTransform: (code: string) => boolean } → function createTransformer(options?: TransformerOptions): { transform: (code: string, options_?: { force?: false }) => { code: string; magicString: MagicString } | undefined; filter: { code: RegExp }; shouldTransform: (code: string) => boolean } - added:
property TransformerOptions.objectDefinitions?: Record<string, string[]>