Skip to content

Commit 46216c1

Browse files
committed
blog updates
1 parent ba7a020 commit 46216c1

File tree

1 file changed

+39
-0
lines changed

1 file changed

+39
-0
lines changed

src/blog/directives-the-new-framework-lock-in.md

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,45 @@ Why are we walking into the same trap again?
5959

6060
---
6161

62+
### “Isn’t this just a Babel plugin/macro with different syntax?”
63+
64+
Functionally, yes — both directives and custom transforms can change behavior at compile time. The issue isn’t capability; it’s surface and optics.
65+
66+
- Directives look like the platform. No import, no owner, no explicit source. They signal “this is JavaScript.”
67+
- APIs/macros point to an owner. Imports provide provenance, versioning, and discoverability.
68+
69+
At best, a directive is equivalent to calling a global, importless function like `window.useCache()` at the top of your file. That’s exactly why it’s risky: it hides the provider and smuggles framework semantics into what looks like language.
70+
71+
Examples:
72+
73+
```js
74+
'use cache'
75+
const fn = () => 'value'
76+
```
77+
78+
```js
79+
// explicit API (imported, ownable, discoverable)
80+
import { createServerFn } from '@acme/runtime'
81+
export const fn = createServerFn(() => 'value')
82+
```
83+
84+
```js
85+
// global magic (importless, hidden provider)
86+
window.useCache()
87+
const fn = () => 'value'
88+
```
89+
90+
Why this matters:
91+
92+
- Ownership and provenance: imports tell you who provides the behavior; directives do not.
93+
- Tooling ergonomics: APIs live in package space; directives require ecosystem-wide special-casing.
94+
- Portability and migration: replacing an imported API is straightforward; unwinding directive semantics across files is costly and ambiguous.
95+
- Education and expectations: directives blur the platform boundary; APIs make the boundary explicit.
96+
97+
So while a custom Babel plugin or macro can implement the same underlying feature, the import-based API keeps it clearly in framework space. Directives move that same behavior into what looks like language space, which is the core concern of this post.
98+
99+
---
100+
62101
### Directives Create an Ecosystem Arms Race
63102

64103
Once directives become a competitive surface, the incentives shift:

0 commit comments

Comments
 (0)