From 3dce46790768e333c5c9f972b9eebdd94551b868 Mon Sep 17 00:00:00 2001 From: comicallynathan <195125394+comicallynathan@users.noreply.github.com> Date: Thu, 25 Jun 2026 13:57:05 -0500 Subject: [PATCH 1/4] Enhance documentation on granular imports Expanded the summary and design sections, added examples for granular imports, and outlined drawbacks and alternatives. --- docs/granular-imports.md | 71 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 71 insertions(+) create mode 100644 docs/granular-imports.md diff --git a/docs/granular-imports.md b/docs/granular-imports.md new file mode 100644 index 00000000..d67ad120 --- /dev/null +++ b/docs/granular-imports.md @@ -0,0 +1,71 @@ +# Granular Imports + +## Summary + +Allow developers to directly import only necessary parts of libraries or modules as a first-class variable. + +## Motivation + +- Less boilerplate for importing commonly used methods; repeated prefixing methods with module names (e.g. `Fusion.Computed()`, `Fusion.Observer()`) creates visual noise +- People who work with React, Fusion, and other components-based toolings +- Consistency with the incoming [`export`](https://github.com/luau-lang/rfcs/pull/42) keyword. +- Reinforced with relative imports +- Potentially enabling any optimization through static and read-only bindings + +## Design + +### Syntax + +Given that this is the module utilizing incoming RFC features + +```lua +export class Dog + private const Sound = "Bark"; + + function New(sound: string): Animal + local self = Animal(); + return self; + end + + function Taunt(self: Animal): () + print(self.Sound); + end +end +``` + +Selectively import objects, methods, and other values from a module + +```luau +import { Dog } from "./Animals"; +``` + +Federalize the import + +```luau +import * as Animals from "./Animals"; +const Dog = Animals.Dog; +``` + +Granular imports applied in practice + +```luau +import { Computed, Observer, Tween, Spring } from "@ReplicatedStorage/Packages/Fusion"; +``` + +## Drawbacks + +- Lua already has `require()` that can be done in one line. However, it is not too ergonomic, and it can cause visual strain with repeated mentions of the module name or the keyword. +- This is a huge change that can go against Lua's design philosophy. Though, we must weigh utiliarian and identity. +- Adding a new import keyword alongside `require()` may cause inconsistencies in the collaborative environments. + +## Alternatives + +## "Lua" approach + +In a more unique Lua approach while maintaining less boilerplate without the keyword, we can use the syntax: + +``` +const { Dog } = require("./Animals"); +``` + +Though, this implies a limited opportunity for developers to be able to rename values to their namespace needs. From 6d3d7b1daead2ab385e357c5a11b674733877563 Mon Sep 17 00:00:00 2001 From: comicallynathan <195125394+comicallynathan@users.noreply.github.com> Date: Thu, 25 Jun 2026 13:57:51 -0500 Subject: [PATCH 2/4] Update wording on granular imports documentation Clarified the phrasing regarding first-class variables in imports. --- docs/granular-imports.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/granular-imports.md b/docs/granular-imports.md index d67ad120..f6f2b54e 100644 --- a/docs/granular-imports.md +++ b/docs/granular-imports.md @@ -2,7 +2,7 @@ ## Summary -Allow developers to directly import only necessary parts of libraries or modules as a first-class variable. +Allow developers to directly import only necessary parts of libraries or modules as first-class variables. ## Motivation From e5c8b867e08581f3a33cac989e124eefa2071ff6 Mon Sep 17 00:00:00 2001 From: comicallynathan <195125394+comicallynathan@users.noreply.github.com> Date: Thu, 25 Jun 2026 13:59:48 -0500 Subject: [PATCH 3/4] Fix formatting and clarity in drawbacks section --- docs/granular-imports.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/granular-imports.md b/docs/granular-imports.md index f6f2b54e..b8b52427 100644 --- a/docs/granular-imports.md +++ b/docs/granular-imports.md @@ -56,7 +56,7 @@ import { Computed, Observer, Tween, Spring } from "@ReplicatedStorage/Packages/F - Lua already has `require()` that can be done in one line. However, it is not too ergonomic, and it can cause visual strain with repeated mentions of the module name or the keyword. - This is a huge change that can go against Lua's design philosophy. Though, we must weigh utiliarian and identity. -- Adding a new import keyword alongside `require()` may cause inconsistencies in the collaborative environments. +- Adding a new import keyword alongside `require()` may cause inconsistencies in collaborative environments. ## Alternatives From fd0b4dbe94cd7021b608c6a35eec85505aacde62 Mon Sep 17 00:00:00 2001 From: comicallynathan <195125394+comicallynathan@users.noreply.github.com> Date: Fri, 26 Jun 2026 15:29:58 -0500 Subject: [PATCH 4/4] Fix typo in granular imports documentation Corrected the phrasing from 'repeated prefixing' to 'repeatedly prefixing'. --- docs/granular-imports.md | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/docs/granular-imports.md b/docs/granular-imports.md index b8b52427..e95197ba 100644 --- a/docs/granular-imports.md +++ b/docs/granular-imports.md @@ -6,7 +6,7 @@ Allow developers to directly import only necessary parts of libraries or modules ## Motivation -- Less boilerplate for importing commonly used methods; repeated prefixing methods with module names (e.g. `Fusion.Computed()`, `Fusion.Observer()`) creates visual noise +- Less boilerplate for importing commonly used methods; repeatedly prefixing methods with module names (e.g. `Fusion.Computed()`, `Fusion.Observer()`) creates visual noise - People who work with React, Fusion, and other components-based toolings - Consistency with the incoming [`export`](https://github.com/luau-lang/rfcs/pull/42) keyword. - Reinforced with relative imports @@ -39,6 +39,12 @@ Selectively import objects, methods, and other values from a module import { Dog } from "./Animals"; ``` +Selectively import objects, methods, and other values from a module under different names + +```luau +import { Dog as dog } from "./Animals"; +``` + Federalize the import ```luau