@zenithbuild/core 1.3.19 → 1.3.21
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/cli/commands/dev.ts +24 -8
- package/package.json +2 -2
package/cli/commands/dev.ts
CHANGED
|
@@ -219,14 +219,15 @@ export async function dev(options: DevOptions = {}): Promise<void> {
|
|
|
219
219
|
// Remove lines from top that are imports, whitespace, or comments
|
|
220
220
|
while (jsLines.length > 0 && jsLines[0] !== undefined) {
|
|
221
221
|
const line = jsLines[0].trim()
|
|
222
|
-
if (
|
|
223
|
-
line.startsWith('import ') ||
|
|
224
|
-
line === '' ||
|
|
225
|
-
line.startsWith('//') ||
|
|
226
|
-
line.startsWith('/*') ||
|
|
227
|
-
line.startsWith('*')
|
|
228
|
-
) {
|
|
222
|
+
if (line === '' || line.startsWith('//') || line.startsWith('/*') || line.startsWith('*')) {
|
|
229
223
|
jsLines.shift()
|
|
224
|
+
} else if (line.startsWith('import ')) {
|
|
225
|
+
// Handle multiline imports: consume until we find a semicolon or empty line
|
|
226
|
+
let currentLine = jsLines.shift() || ''
|
|
227
|
+
while (!currentLine.trim().endsWith(';') && jsLines.length > 0) {
|
|
228
|
+
const nextPart = jsLines.shift() || ''
|
|
229
|
+
currentLine += ' ' + nextPart
|
|
230
|
+
}
|
|
230
231
|
} else {
|
|
231
232
|
break
|
|
232
233
|
}
|
|
@@ -234,8 +235,23 @@ export async function dev(options: DevOptions = {}): Promise<void> {
|
|
|
234
235
|
|
|
235
236
|
let jsWithoutImports = jsLines.join('\n')
|
|
236
237
|
|
|
238
|
+
const ZEN_RUNTIME_IMPORTS = [
|
|
239
|
+
'import {',
|
|
240
|
+
' signal as zenSignal,',
|
|
241
|
+
' state as zenState,',
|
|
242
|
+
' effect as zenEffect,',
|
|
243
|
+
' memo as zenMemo,',
|
|
244
|
+
' ref as zenRef,',
|
|
245
|
+
' onMount as zenOnMount,',
|
|
246
|
+
' onUnmount as zenOnUnmount,',
|
|
247
|
+
' batch as zenBatch,',
|
|
248
|
+
' untrack as zenUntrack',
|
|
249
|
+
'} from "@zenithbuild/runtime";'
|
|
250
|
+
].join('\n');
|
|
251
|
+
|
|
237
252
|
// Combine: structured imports first, then cleaned script body
|
|
238
|
-
|
|
253
|
+
// We inject runtime imports manually because npmImports excludes them
|
|
254
|
+
const fullScript = ZEN_RUNTIME_IMPORTS + '\n\n' + (result.finalized.npmImports || '') + '\n\n' + jsWithoutImports
|
|
239
255
|
|
|
240
256
|
logger.debug(`Page Imports: ${result.finalized.npmImports ? result.finalized.npmImports.split('\n').length : 0} lines`)
|
|
241
257
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zenithbuild/core",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.21",
|
|
4
4
|
"description": "Core library for the Zenith framework",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -67,4 +67,4 @@
|
|
|
67
67
|
"@zenithbuild/router": "^1.3.18"
|
|
68
68
|
},
|
|
69
69
|
"types": "./dist/index.d.ts"
|
|
70
|
-
}
|
|
70
|
+
}
|