lopata 0.5.0 → 0.5.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/config.ts +1 -45
- package/src/env.ts +0 -3
- package/src/generation-manager.ts +10 -8
package/package.json
CHANGED
package/src/config.ts
CHANGED
|
@@ -80,8 +80,7 @@ export async function loadConfig(path: string, envName?: string): Promise<Wrangl
|
|
|
80
80
|
if (path.endsWith('.toml')) {
|
|
81
81
|
config = parseTOML(raw) as unknown as WranglerConfig
|
|
82
82
|
} else {
|
|
83
|
-
|
|
84
|
-
config = JSON.parse(stripJsoncComments(raw))
|
|
83
|
+
config = Bun.JSONC.parse(raw) as WranglerConfig
|
|
85
84
|
}
|
|
86
85
|
return applyEnvOverrides(config, envName)
|
|
87
86
|
}
|
|
@@ -120,46 +119,3 @@ function applyEnvOverrides(config: WranglerConfig, envName?: string): WranglerCo
|
|
|
120
119
|
}
|
|
121
120
|
return merged
|
|
122
121
|
}
|
|
123
|
-
|
|
124
|
-
// ─── JSONC Comment Stripping ───────────────────────────────────────────────
|
|
125
|
-
|
|
126
|
-
function stripJsoncComments(input: string): string {
|
|
127
|
-
let result = ''
|
|
128
|
-
let i = 0
|
|
129
|
-
while (i < input.length) {
|
|
130
|
-
// String literal — copy as-is
|
|
131
|
-
if (input[i] === '"') {
|
|
132
|
-
result += '"'
|
|
133
|
-
i++
|
|
134
|
-
while (i < input.length && input[i] !== '"') {
|
|
135
|
-
if (input[i] === '\\') {
|
|
136
|
-
result += input[i]! + (input[i + 1] ?? '')
|
|
137
|
-
i += 2
|
|
138
|
-
} else {
|
|
139
|
-
result += input[i]!
|
|
140
|
-
i++
|
|
141
|
-
}
|
|
142
|
-
}
|
|
143
|
-
if (i < input.length) {
|
|
144
|
-
result += '"'
|
|
145
|
-
i++
|
|
146
|
-
}
|
|
147
|
-
continue
|
|
148
|
-
}
|
|
149
|
-
// Single-line comment
|
|
150
|
-
if (input[i] === '/' && input[i + 1] === '/') {
|
|
151
|
-
while (i < input.length && input[i] !== '\n') i++
|
|
152
|
-
continue
|
|
153
|
-
}
|
|
154
|
-
// Block comment
|
|
155
|
-
if (input[i] === '/' && input[i + 1] === '*') {
|
|
156
|
-
i += 2
|
|
157
|
-
while (i < input.length && !(input[i] === '*' && input[i + 1] === '/')) i++
|
|
158
|
-
i += 2
|
|
159
|
-
continue
|
|
160
|
-
}
|
|
161
|
-
result += input[i]!
|
|
162
|
-
i++
|
|
163
|
-
}
|
|
164
|
-
return result
|
|
165
|
-
}
|
package/src/env.ts
CHANGED
|
@@ -146,10 +146,7 @@ export class GenerationManager {
|
|
|
146
146
|
}
|
|
147
147
|
|
|
148
148
|
private async _doReload(): Promise<Generation> {
|
|
149
|
-
// 1.
|
|
150
|
-
const workerModule = await import(`${this.workerPath}?v=${Date.now()}`)
|
|
151
|
-
|
|
152
|
-
// 1b. Configure executor factory with module/config paths (for isolated mode)
|
|
149
|
+
// 1. Configure executor factory with module/config paths (for isolated mode)
|
|
153
150
|
if (this.executorFactory && 'configure' in this.executorFactory) {
|
|
154
151
|
;(this.executorFactory as any).configure(this.workerPath, this._configPath)
|
|
155
152
|
}
|
|
@@ -157,14 +154,19 @@ export class GenerationManager {
|
|
|
157
154
|
// 2. Build new env with fresh binding instances (same underlying DB)
|
|
158
155
|
const { env, registry } = buildEnv(this.config, this.baseDir, this.executorFactory, this.browserConfig)
|
|
159
156
|
|
|
160
|
-
// 3.
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
// 4. Update globalEnv for cloudflare:workers env export (main worker only)
|
|
157
|
+
// 3. Update globalEnv BEFORE importing the worker module so that
|
|
158
|
+
// top-level `import { env } from "cloudflare:workers"` sees bindings
|
|
159
|
+
// during module evaluation (main worker only).
|
|
164
160
|
if (this.isMain) {
|
|
165
161
|
setGlobalEnv(env)
|
|
166
162
|
}
|
|
167
163
|
|
|
164
|
+
// 4. Import fresh worker module using cache-busting query string
|
|
165
|
+
const workerModule = await import(`${this.workerPath}?v=${Date.now()}`)
|
|
166
|
+
|
|
167
|
+
// 5. Wire DO and Workflow class references
|
|
168
|
+
wireClassRefs(registry, workerModule, env, this.workerRegistry)
|
|
169
|
+
|
|
168
170
|
// 5. Validate default export (or service worker fetch handler)
|
|
169
171
|
const defaultExport = workerModule.default
|
|
170
172
|
const classBasedExport = isEntrypointClass(defaultExport)
|