Skip to content
Merged
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
// Local folder barrel — same conflation risk as a package barrel.
export { useLocalLight } from './local-light';
export { useLocalHeavy } from './local-heavy';
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { runHeavy } from 'heavy-runtime';

export type LocalHeavyType = { tag: 'local-heavy' };

export function useLocalHeavy(): { tag: 'heavy' } {
return runHeavy();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { runLight } from 'light-helper';

export type LocalLightOptions = { mode: 'light' };

export function useLocalLight(opts?: LocalLightOptions): void {
runLight(opts);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { useLocalHeavy } from './local-heavy';

export function useLocalTrigger(): { tag: 'heavy' } {
return useLocalHeavy();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { runLight } from 'light-helper';

export function useCleanExport(): void {
runLight();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { runHeavy } from 'heavy-runtime';

export function useDirtyExport(): { tag: 'heavy' } {
return runHeavy();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
// Barrel exposing one clean and one forbidden-runtime-dependent export. Importing the clean one
// must not inherit the dependencies of its sibling.
export { useCleanExport } from './clean';
export { useDirtyExport } from './dirty';
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export { Widget } from './widget';
export type { WidgetHostProps, WidgetSlots } from './types';
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import type { Widget } from './widget';

// `typeof Widget` extracts the component's type; it does not consume its runtime.
export type WidgetSlots = { widget: typeof Widget };

export type WidgetHostProps = { slots: WidgetSlots };
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { runHeavy } from 'heavy-runtime';

export type WidgetProps = { tag: 'widget' };

// A component whose implementation is dirty but whose type surface is not.
export const Widget = (props: WidgetProps): { tag: 'heavy' } => {
return runHeavy();
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export function runHeavySub(): { tag: 'heavy-sub' } {
return { tag: 'heavy-sub' };
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { useBenign } from 'wrapper-pkg';

// Mirrors `useActiveDescendant`: an intermediate package that consumes only the benign export of
// the wrapper package.
export function useRelay(): void {
useBenign();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import type { HeavyOptions } from 'heavy-runtime';

// Stands in for a package linted against built output rather than source.
export declare type DistHeavy = { tag: 'dist-heavy'; options: HeavyOptions };

export declare type DistClean = { tag: 'dist-clean' };

export declare function useDistClean(): DistClean;
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { runHeavy } from 'heavy-runtime';

export function useUnlisted(): { tag: 'heavy' } {
return runHeavy();
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
import { runHeavy } from 'heavy-runtime';
import type { HeavyOptions } from 'heavy-runtime';

export type HeavyType = { tag: 'heavy' };
// Coupled to the forbidden runtime through its own shape, not merely through a sibling export.
export type HeavyType = { tag: 'heavy'; options?: HeavyOptions };

export function useHeavy(): HeavyType {
// Clean sibling living in the very same file as the forbidden import above.
export type CleanTag = { tag: 'clean' };

export function useHeavy(): { tag: 'heavy' } {
return runHeavy();
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,6 @@ export { useLight } from './light';
export type { LightOptions } from './light';
// Re-export of a type-only thing from the heavy module — must not count as a runtime reach.
export type { HeavyType } from './heavy';
export type { CleanTag } from './heavy';

export type HeavyWrapper = { tag: 'heavy-wrapper'; inner: HeavyType };
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
// Wrapper package standing in for `@fluentui/react-tabster`: not forbidden itself, but some of
// its exports reach the forbidden runtime and some do not.
export { useBenign } from './useBenign';
export { useDeep } from './useDeep';
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { useBenignRef } from './useBenignRef';

// Mirrors `useOnKeyboardNavigationChange`: lives in the wrapper package but bottoms out in a
// benign dependency, never in the forbidden runtime.
export function useBenign(): void {
useBenignRef();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { runLight } from 'light-helper';

export function useBenignRef(): void {
runLight();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { useDeepInner } from './useDeepInner';

// Mirrors `useTabsterAttributes`: same wrapper package as `useBenign`, but its implementation
// reaches the forbidden runtime two hops down.
export function useDeep(): { tag: 'heavy' } {
return useDeepInner();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { runHeavy } from 'heavy-runtime';

export function useDeepInner(): { tag: 'heavy' } {
return runHeavy();
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,14 @@
"paths": {
"watched-pkg": ["./stubs/watched-pkg/index.ts"],
"watched-pkg/*": ["./stubs/watched-pkg/*"],
"unlisted-pkg": ["./stubs/unlisted-pkg/index.ts"],
"barrel-pkg": ["./stubs/barrel-pkg/index.ts"],
"wrapper-pkg": ["./stubs/wrapper-pkg/index.ts"],
"relay-pkg": ["./stubs/relay-pkg/index.ts"],
"component-pkg": ["./stubs/component-pkg/index.ts"],
"typed-dist-pkg": ["./stubs/typed-dist-pkg/index.d.ts"],
"heavy-runtime": ["./stubs/heavy-runtime/index.ts"],
"heavy-runtime/*": ["./stubs/heavy-runtime/*"],
"light-helper": ["./stubs/light-helper/index.ts"],
"cyclic-pkg": ["./stubs/cyclic-pkg/index.ts"],
"cyclic-heavy-pkg": ["./stubs/cyclic-heavy-pkg/index.ts"]
Expand Down
Loading
Loading