You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/blog/directives-the-new-framework-lock-in.md
+39Lines changed: 39 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -59,6 +59,45 @@ Why are we walking into the same trap again?
59
59
60
60
---
61
61
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
+
constfn= () =>'value'
76
+
```
77
+
78
+
```js
79
+
// explicit API (imported, ownable, discoverable)
80
+
import { createServerFn } from'@acme/runtime'
81
+
exportconstfn=createServerFn(() =>'value')
82
+
```
83
+
84
+
```js
85
+
// global magic (importless, hidden provider)
86
+
window.useCache()
87
+
constfn= () =>'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
+
62
101
### Directives Create an Ecosystem Arms Race
63
102
64
103
Once directives become a competitive surface, the incentives shift:
0 commit comments