@hanzogui/static 4.3.1 → 7.0.0
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/dist/check-dep-versions.cjs +1 -1
- package/dist/checkDeps.cjs +11 -11
- package/dist/constants.cjs +2 -2
- package/dist/exports.cjs +2 -2
- package/dist/extractor/babelParse.cjs +1 -1
- package/dist/extractor/bundle.cjs +23 -39
- package/dist/extractor/bundleConfig.cjs +51 -48
- package/dist/extractor/createExtractor.cjs +39 -39
- package/dist/extractor/createLogger.cjs +1 -1
- package/dist/extractor/extractHelpers.cjs +1 -1
- package/dist/extractor/extractMediaStyle.cjs +7 -7
- package/dist/extractor/extractToClassNames.cjs +9 -9
- package/dist/extractor/extractToNative.cjs +7 -7
- package/dist/extractor/{getGuiConfigPathFromOptionsConfig.cjs → getHanzoguiConfigPathFromOptionsConfig.cjs} +5 -5
- package/dist/extractor/getPrefixLogs.cjs +1 -1
- package/dist/extractor/getStaticBindingsForScope.cjs +2 -2
- package/dist/extractor/hasTopLevelAwait.cjs +62 -0
- package/dist/extractor/{loadGui.cjs → loadHanzogui.cjs} +97 -141
- package/dist/extractor/regenerateConfig.cjs +20 -20
- package/dist/extractor/{watchGuiConfig.cjs → watchHanzoguiConfig.cjs} +15 -15
- package/dist/getPragmaOptions.cjs +6 -6
- package/dist/helpers/{requireGuiCore.cjs → requireHanzoguiCore.cjs} +12 -12
- package/dist/registerRequire.cjs +58 -20
- package/dist/worker.cjs +3 -3
- package/package.json +22 -22
- package/src/check-dep-versions.ts +1 -5
- package/src/checkDeps.ts +28 -30
- package/src/constants.ts +2 -2
- package/src/exports.ts +2 -2
- package/src/extractor/babelParse.ts +1 -0
- package/src/extractor/bundle.ts +16 -18
- package/src/extractor/bundleConfig.ts +62 -62
- package/src/extractor/createEvaluator.ts +2 -2
- package/src/extractor/createExtractor.ts +62 -55
- package/src/extractor/createLogger.ts +5 -3
- package/src/extractor/esbuildTsconfigPaths.ts +1 -1
- package/src/extractor/extractHelpers.ts +15 -12
- package/src/extractor/extractMediaStyle.ts +19 -13
- package/src/extractor/extractToClassNames.ts +11 -11
- package/src/extractor/extractToNative.ts +13 -13
- package/src/extractor/{getGuiConfigPathFromOptionsConfig.ts → getHanzoguiConfigPathFromOptionsConfig.ts} +3 -3
- package/src/extractor/getPrefixLogs.ts +3 -3
- package/src/extractor/getStaticBindingsForScope.ts +2 -2
- package/src/extractor/hasTopLevelAwait.ts +28 -0
- package/src/extractor/{loadGui.ts → loadHanzogui.ts} +86 -83
- package/src/extractor/regenerateConfig.ts +34 -24
- package/src/extractor/{watchGuiConfig.ts → watchHanzoguiConfig.ts} +10 -10
- package/src/getPragmaOptions.ts +6 -6
- package/src/helpers/requireHanzoguiCore.ts +28 -0
- package/src/registerRequire.ts +79 -34
- package/src/server.ts +2 -2
- package/src/types.ts +13 -10
- package/src/worker.ts +7 -7
- package/types/check-dep-versions.d.ts.map +1 -1
- package/types/checkDeps.d.ts.map +1 -1
- package/types/constants.d.ts.map +1 -1
- package/types/exports.d.ts +2 -2
- package/types/exports.d.ts.map +1 -1
- package/types/extractor/babelParse.d.ts.map +1 -1
- package/types/extractor/bundle.d.ts +2 -2
- package/types/extractor/bundle.d.ts.map +1 -1
- package/types/extractor/bundleConfig.d.ts +12 -12
- package/types/extractor/bundleConfig.d.ts.map +1 -1
- package/types/extractor/createEvaluator.d.ts +2 -2
- package/types/extractor/createEvaluator.d.ts.map +1 -1
- package/types/extractor/createExtractor.d.ts +5 -5
- package/types/extractor/createExtractor.d.ts.map +1 -1
- package/types/extractor/createLogger.d.ts +2 -2
- package/types/extractor/createLogger.d.ts.map +1 -1
- package/types/extractor/extractHelpers.d.ts +8 -8
- package/types/extractor/extractHelpers.d.ts.map +1 -1
- package/types/extractor/extractMediaStyle.d.ts +4 -4
- package/types/extractor/extractMediaStyle.d.ts.map +1 -1
- package/types/extractor/extractToClassNames.d.ts +2 -2
- package/types/extractor/extractToClassNames.d.ts.map +1 -1
- package/types/extractor/extractToNative.d.ts +3 -3
- package/types/extractor/extractToNative.d.ts.map +1 -1
- package/types/extractor/getHanzoguiConfigPathFromOptionsConfig.d.ts +3 -0
- package/types/extractor/getHanzoguiConfigPathFromOptionsConfig.d.ts.map +1 -0
- package/types/extractor/getPrefixLogs.d.ts +2 -2
- package/types/extractor/getPrefixLogs.d.ts.map +1 -1
- package/types/extractor/hasTopLevelAwait.d.ts +2 -0
- package/types/extractor/hasTopLevelAwait.d.ts.map +1 -0
- package/types/extractor/loadHanzogui.d.ts +22 -0
- package/types/extractor/loadHanzogui.d.ts.map +1 -0
- package/types/extractor/regenerateConfig.d.ts +4 -4
- package/types/extractor/regenerateConfig.d.ts.map +1 -1
- package/types/extractor/watchHanzoguiConfig.d.ts +5 -0
- package/types/extractor/watchHanzoguiConfig.d.ts.map +1 -0
- package/types/helpers/requireHanzoguiCore.d.ts +3 -0
- package/types/helpers/requireHanzoguiCore.d.ts.map +1 -0
- package/types/registerRequire.d.ts +3 -3
- package/types/registerRequire.d.ts.map +1 -1
- package/types/server.d.ts +2 -2
- package/types/server.d.ts.map +1 -1
- package/types/types.d.ts +10 -10
- package/types/types.d.ts.map +1 -1
- package/types/worker.d.ts +4 -4
- package/types/worker.d.ts.map +1 -1
- package/src/helpers/requireGuiCore.ts +0 -28
- package/types/extractor/getGuiConfigPathFromOptionsConfig.d.ts +0 -3
- package/types/extractor/getGuiConfigPathFromOptionsConfig.d.ts.map +0 -1
- package/types/extractor/loadGui.d.ts +0 -22
- package/types/extractor/loadGui.d.ts.map +0 -1
- package/types/extractor/watchGuiConfig.d.ts +0 -5
- package/types/extractor/watchGuiConfig.d.ts.map +0 -1
- package/types/helpers/requireGuiCore.d.ts +0 -3
- package/types/helpers/requireGuiCore.d.ts.map +0 -1
|
@@ -7,16 +7,17 @@ import { basename, dirname, extname, join, relative, sep } from 'node:path'
|
|
|
7
7
|
import { pathToFileURL } from 'node:url'
|
|
8
8
|
// @ts-ignore why
|
|
9
9
|
import { Color, colorLog } from '@hanzogui/cli-color'
|
|
10
|
-
import { type StaticConfig, type
|
|
10
|
+
import { type StaticConfig, type HanzoguiInternalConfig } from '@hanzogui/web'
|
|
11
11
|
import esbuild from 'esbuild'
|
|
12
12
|
import * as FS from 'fs-extra'
|
|
13
13
|
import { readFile } from 'node:fs/promises'
|
|
14
14
|
import { registerRequire, setRequireResult } from '../registerRequire'
|
|
15
|
-
import type {
|
|
15
|
+
import type { HanzoguiOptions } from '../types'
|
|
16
16
|
import { babelParse } from './babelParse'
|
|
17
|
-
import { esbuildLoaderConfig,
|
|
18
|
-
import {
|
|
19
|
-
import {
|
|
17
|
+
import { esbuildLoaderConfig, esbundleHanzoguiConfig } from './bundle'
|
|
18
|
+
import { getHanzoguiConfigPathFromOptionsConfig } from './getHanzoguiConfigPathFromOptionsConfig'
|
|
19
|
+
import { hasTopLevelAwait } from './hasTopLevelAwait'
|
|
20
|
+
import { requireHanzoguiCore } from '../helpers/requireHanzoguiCore'
|
|
20
21
|
import { detectModuleFormat } from './detectModuleFormat'
|
|
21
22
|
|
|
22
23
|
// track temp files for cleanup on exit
|
|
@@ -32,7 +33,7 @@ function getDynamicEvalOutfile(name: string, format: 'esm' | 'cjs', contents: st
|
|
|
32
33
|
.update(contents)
|
|
33
34
|
.digest('hex')
|
|
34
35
|
.slice(0, 10)
|
|
35
|
-
return join(process.cwd(), '.
|
|
36
|
+
return join(process.cwd(), '.hanzogui', `dynamic-eval-${hash}-${basename(name)}.${ext}`)
|
|
36
37
|
}
|
|
37
38
|
|
|
38
39
|
function getEsbuildStdinLoader(filePath: string): esbuild.Loader {
|
|
@@ -98,9 +99,9 @@ export type LoadedComponents = {
|
|
|
98
99
|
>
|
|
99
100
|
}
|
|
100
101
|
|
|
101
|
-
export type
|
|
102
|
+
export type HanzoguiProjectInfo = {
|
|
102
103
|
components?: LoadedComponents[]
|
|
103
|
-
|
|
104
|
+
hanzoguiConfig?: HanzoguiInternalConfig | null
|
|
104
105
|
nameToPaths?: NameToPaths
|
|
105
106
|
cached?: boolean
|
|
106
107
|
}
|
|
@@ -133,7 +134,7 @@ const handleEsmFeaturesPlugin: esbuild.Plugin = {
|
|
|
133
134
|
}
|
|
134
135
|
|
|
135
136
|
// skip most node_modules
|
|
136
|
-
if (args.path.includes('node_modules') && !args.path.includes('@
|
|
137
|
+
if (args.path.includes('node_modules') && !args.path.includes('@hanzogui')) {
|
|
137
138
|
return null
|
|
138
139
|
}
|
|
139
140
|
|
|
@@ -159,15 +160,14 @@ const handleEsmFeaturesPlugin: esbuild.Plugin = {
|
|
|
159
160
|
}
|
|
160
161
|
|
|
161
162
|
// stub files with top-level await - they're typically runtime-only
|
|
162
|
-
if (
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
) {
|
|
166
|
-
if (process.env.DEBUG?.startsWith('@hanzo/gui')) {
|
|
167
|
-
console.info(`[hanzo-gui] stubbing file with top-level await: ${args.path}`)
|
|
163
|
+
if (hasTopLevelAwait(contents, args.path)) {
|
|
164
|
+
if (process.env.DEBUG?.startsWith('hanzogui')) {
|
|
165
|
+
console.info(`[hanzogui] stubbing file with top-level await: ${args.path}`)
|
|
168
166
|
}
|
|
169
167
|
return {
|
|
170
|
-
|
|
168
|
+
// Keep this as an ESM-shaped stub so esbuild doesn't inline a top-level
|
|
169
|
+
// `module.exports = {}` into the parent bundle and wipe its exports.
|
|
170
|
+
contents: `// stubbed - contains top-level await\nexport default {}`,
|
|
171
171
|
loader: 'js',
|
|
172
172
|
}
|
|
173
173
|
}
|
|
@@ -226,11 +226,11 @@ export function hasBundledConfigChanged() {
|
|
|
226
226
|
return true
|
|
227
227
|
}
|
|
228
228
|
|
|
229
|
-
let loadedConfig:
|
|
229
|
+
let loadedConfig: HanzoguiInternalConfig | null = null
|
|
230
230
|
|
|
231
231
|
export const getLoadedConfig = () => loadedConfig
|
|
232
232
|
|
|
233
|
-
export async function getBundledConfig(props:
|
|
233
|
+
export async function getBundledConfig(props: HanzoguiOptions, rebuild = false) {
|
|
234
234
|
if (isBundling) {
|
|
235
235
|
await new Promise((res) => {
|
|
236
236
|
waitForBundle.add(res)
|
|
@@ -241,11 +241,11 @@ export async function getBundledConfig(props: GuiOptions, rebuild = false) {
|
|
|
241
241
|
return currentBundle
|
|
242
242
|
}
|
|
243
243
|
|
|
244
|
-
global.
|
|
244
|
+
global.hanzoguiLastLoaded ||= 0
|
|
245
245
|
|
|
246
246
|
function updateLastLoaded(config: any) {
|
|
247
|
-
global.
|
|
248
|
-
global.
|
|
247
|
+
global.hanzoguiLastLoaded = Date.now()
|
|
248
|
+
global.hanzoguiLastBundledConfig = config
|
|
249
249
|
}
|
|
250
250
|
|
|
251
251
|
let hasBundledOnce = false
|
|
@@ -255,24 +255,24 @@ let hasBundledOnce = false
|
|
|
255
255
|
// that's acceptable - better than nothing
|
|
256
256
|
let hasLoggedBuild = false
|
|
257
257
|
|
|
258
|
-
export async function bundleConfig(props:
|
|
258
|
+
export async function bundleConfig(props: HanzoguiOptions) {
|
|
259
259
|
// webpack is calling this a ton for no reason
|
|
260
|
-
if (global.
|
|
260
|
+
if (global.hanzoguiLastBundledConfig && Date.now() - global.hanzoguiLastLoaded < 3000) {
|
|
261
261
|
// just loaded recently
|
|
262
|
-
return global.
|
|
262
|
+
return global.hanzoguiLastBundledConfig
|
|
263
263
|
}
|
|
264
264
|
|
|
265
265
|
try {
|
|
266
266
|
isBundling = true
|
|
267
267
|
|
|
268
268
|
const configEntry = props.config
|
|
269
|
-
?
|
|
269
|
+
? getHanzoguiConfigPathFromOptionsConfig(props.config)
|
|
270
270
|
: ''
|
|
271
|
-
const tmpDir = join(process.cwd(), '.
|
|
271
|
+
const tmpDir = join(process.cwd(), '.hanzogui')
|
|
272
272
|
// detect module format from config entry point
|
|
273
273
|
const configFormat = configEntry ? detectModuleFormat(configEntry) : 'cjs'
|
|
274
274
|
const configExt = configFormat === 'esm' ? '.mjs' : '.cjs'
|
|
275
|
-
const configOutPath = join(tmpDir, `
|
|
275
|
+
const configOutPath = join(tmpDir, `hanzogui.config${configExt}`)
|
|
276
276
|
const baseComponents = (props.components || []).filter((x) => x !== '@hanzogui/core')
|
|
277
277
|
// detect format per component module
|
|
278
278
|
const componentFormats: Array<'esm' | 'cjs'> = baseComponents.map((mod) => {
|
|
@@ -297,7 +297,7 @@ export async function bundleConfig(props: GuiOptions) {
|
|
|
297
297
|
|
|
298
298
|
if (
|
|
299
299
|
process.env.NODE_ENV === 'development' &&
|
|
300
|
-
process.env.DEBUG?.startsWith('
|
|
300
|
+
process.env.DEBUG?.startsWith('hanzogui')
|
|
301
301
|
) {
|
|
302
302
|
console.info(`Building config entry`, configEntry)
|
|
303
303
|
}
|
|
@@ -336,7 +336,7 @@ export async function bundleConfig(props: GuiOptions) {
|
|
|
336
336
|
|
|
337
337
|
await Promise.all([
|
|
338
338
|
props.config
|
|
339
|
-
?
|
|
339
|
+
? esbundleHanzoguiConfig(
|
|
340
340
|
{
|
|
341
341
|
entryPoints: [configEntry],
|
|
342
342
|
external,
|
|
@@ -349,7 +349,7 @@ export async function bundleConfig(props: GuiOptions) {
|
|
|
349
349
|
)
|
|
350
350
|
: null,
|
|
351
351
|
...baseComponents.map((componentModule, i) => {
|
|
352
|
-
return
|
|
352
|
+
return esbundleHanzoguiConfig(
|
|
353
353
|
{
|
|
354
354
|
entryPoints: [componentModule],
|
|
355
355
|
resolvePlatformSpecificEntries: true,
|
|
@@ -371,10 +371,10 @@ export async function bundleConfig(props: GuiOptions) {
|
|
|
371
371
|
colorLog(
|
|
372
372
|
Color.FgYellow,
|
|
373
373
|
`
|
|
374
|
-
➡ [
|
|
374
|
+
➡ [hanzogui] built config, components, prompt (${Date.now() - start}ms)`
|
|
375
375
|
)
|
|
376
376
|
|
|
377
|
-
if (process.env.DEBUG?.startsWith('
|
|
377
|
+
if (process.env.DEBUG?.startsWith('hanzogui')) {
|
|
378
378
|
colorLog(
|
|
379
379
|
Color.Dim,
|
|
380
380
|
`
|
|
@@ -427,20 +427,20 @@ export async function bundleConfig(props: GuiOptions) {
|
|
|
427
427
|
// check for ProxyWorm - indicates a module loading error
|
|
428
428
|
if (config._isProxyWorm) {
|
|
429
429
|
throw new Error(
|
|
430
|
-
`Got a proxied config - likely a module loading error. Set DEBUG=
|
|
430
|
+
`Got a proxied config - likely a module loading error. Set DEBUG=hanzogui for details.`
|
|
431
431
|
)
|
|
432
432
|
}
|
|
433
433
|
|
|
434
434
|
loadedConfig = config
|
|
435
435
|
|
|
436
436
|
if (!config.parsed) {
|
|
437
|
-
const {
|
|
437
|
+
const { createHanzogui } = requireHanzoguiCore(props.platform || 'web')
|
|
438
438
|
// need to create it
|
|
439
|
-
config =
|
|
439
|
+
config = createHanzogui(config)
|
|
440
440
|
}
|
|
441
441
|
|
|
442
442
|
if (props.outputCSS) {
|
|
443
|
-
await
|
|
443
|
+
await writeHanzoguiCSS(props.outputCSS, config)
|
|
444
444
|
}
|
|
445
445
|
|
|
446
446
|
let components = await loadComponents({
|
|
@@ -459,7 +459,7 @@ export async function bundleConfig(props: GuiOptions) {
|
|
|
459
459
|
component.moduleName
|
|
460
460
|
|
|
461
461
|
if (!component.moduleName) {
|
|
462
|
-
if (process.env.DEBUG?.includes('
|
|
462
|
+
if (process.env.DEBUG?.includes('hanzogui') || process.env.IS_TAMAGUI_DEV) {
|
|
463
463
|
console.warn(
|
|
464
464
|
`⚠️ no module name found: ${component.moduleName} ${JSON.stringify(
|
|
465
465
|
baseComponents
|
|
@@ -471,7 +471,7 @@ export async function bundleConfig(props: GuiOptions) {
|
|
|
471
471
|
|
|
472
472
|
if (
|
|
473
473
|
process.env.NODE_ENV === 'development' &&
|
|
474
|
-
process.env.DEBUG?.startsWith('
|
|
474
|
+
process.env.DEBUG?.startsWith('hanzogui')
|
|
475
475
|
) {
|
|
476
476
|
console.info('Loaded components', components)
|
|
477
477
|
}
|
|
@@ -479,7 +479,7 @@ export async function bundleConfig(props: GuiOptions) {
|
|
|
479
479
|
const res = {
|
|
480
480
|
components,
|
|
481
481
|
nameToPaths: {},
|
|
482
|
-
|
|
482
|
+
hanzoguiConfig: config,
|
|
483
483
|
}
|
|
484
484
|
|
|
485
485
|
currentBundle = res
|
|
@@ -488,9 +488,9 @@ export async function bundleConfig(props: GuiOptions) {
|
|
|
488
488
|
return res
|
|
489
489
|
} catch (err: any) {
|
|
490
490
|
console.error(
|
|
491
|
-
`Error bundling
|
|
491
|
+
`Error bundling hanzogui config: ${err?.message} (run with DEBUG=hanzogui to see stack)`
|
|
492
492
|
)
|
|
493
|
-
if (process.env.DEBUG?.includes('
|
|
493
|
+
if (process.env.DEBUG?.includes('hanzogui')) {
|
|
494
494
|
console.error(err.stack)
|
|
495
495
|
}
|
|
496
496
|
} finally {
|
|
@@ -500,9 +500,9 @@ export async function bundleConfig(props: GuiOptions) {
|
|
|
500
500
|
}
|
|
501
501
|
}
|
|
502
502
|
|
|
503
|
-
export async function
|
|
503
|
+
export async function writeHanzoguiCSS(outputCSS: string, config: HanzoguiInternalConfig) {
|
|
504
504
|
const flush = async () => {
|
|
505
|
-
colorLog(Color.FgYellow, ` ➡ [
|
|
505
|
+
colorLog(Color.FgYellow, ` ➡ [hanzogui] output css: ${outputCSS}`)
|
|
506
506
|
await FS.writeFile(outputCSS, css)
|
|
507
507
|
}
|
|
508
508
|
|
|
@@ -521,19 +521,19 @@ export async function writeGuiCSS(outputCSS: string, config: GuiInternalConfig)
|
|
|
521
521
|
}
|
|
522
522
|
}
|
|
523
523
|
|
|
524
|
-
export async function loadComponents(props:
|
|
524
|
+
export async function loadComponents(props: HanzoguiOptions, forceExports = false) {
|
|
525
525
|
const coreComponents = getCoreComponentsSync(props)
|
|
526
526
|
const otherComponents = await loadComponentsInner(props, forceExports)
|
|
527
527
|
return [...coreComponents, ...(otherComponents || [])]
|
|
528
528
|
}
|
|
529
529
|
|
|
530
|
-
export function loadComponentsSync(props:
|
|
530
|
+
export function loadComponentsSync(props: HanzoguiOptions, forceExports = false) {
|
|
531
531
|
const coreComponents = getCoreComponentsSync(props)
|
|
532
532
|
const otherComponents = loadComponentsInnerSync(props, forceExports)
|
|
533
533
|
return [...coreComponents, ...(otherComponents || [])]
|
|
534
534
|
}
|
|
535
535
|
|
|
536
|
-
function getCoreComponentsSync(props:
|
|
536
|
+
function getCoreComponentsSync(props: HanzoguiOptions) {
|
|
537
537
|
const loaded = loadComponentsInnerSync({
|
|
538
538
|
...props,
|
|
539
539
|
components: ['@hanzogui/core'],
|
|
@@ -553,7 +553,7 @@ function getCoreComponentsSync(props: GuiOptions) {
|
|
|
553
553
|
}
|
|
554
554
|
|
|
555
555
|
export async function loadComponentsInner(
|
|
556
|
-
props:
|
|
556
|
+
props: HanzoguiOptions,
|
|
557
557
|
forceExports = false
|
|
558
558
|
): Promise<null | LoadedComponents[]> {
|
|
559
559
|
const componentsModules = props.components || []
|
|
@@ -624,7 +624,7 @@ export async function loadComponentsInner(
|
|
|
624
624
|
})
|
|
625
625
|
}
|
|
626
626
|
|
|
627
|
-
if (process.env.DEBUG === '
|
|
627
|
+
if (process.env.DEBUG === 'hanzogui') {
|
|
628
628
|
console.info(`loadModule`, loadModule, format)
|
|
629
629
|
}
|
|
630
630
|
|
|
@@ -666,16 +666,16 @@ export async function loadComponentsInner(
|
|
|
666
666
|
} catch (err) {
|
|
667
667
|
console.info('babel err', err, writtenContents)
|
|
668
668
|
writtenContents = fileContents
|
|
669
|
-
if (process.env.DEBUG?.startsWith('
|
|
669
|
+
if (process.env.DEBUG?.startsWith('hanzogui')) {
|
|
670
670
|
console.info(`Error parsing babel likely`, err)
|
|
671
671
|
}
|
|
672
672
|
|
|
673
673
|
try {
|
|
674
674
|
loaded = await attemptLoad({ forceExports: false })
|
|
675
675
|
} catch (err2) {
|
|
676
|
-
if (process.env.
|
|
676
|
+
if (process.env.TAMAGUI_ENABLE_WARN_DYNAMIC_LOAD) {
|
|
677
677
|
console.info(
|
|
678
|
-
`\
|
|
678
|
+
`\nHanzogui attempted but failed to dynamically optimize components in:\n ${name}\n`
|
|
679
679
|
)
|
|
680
680
|
console.info(err2)
|
|
681
681
|
console.info(
|
|
@@ -703,7 +703,7 @@ export async function loadComponentsInner(
|
|
|
703
703
|
cacheComponents[key] = results
|
|
704
704
|
return results
|
|
705
705
|
} catch (err: any) {
|
|
706
|
-
console.info(`
|
|
706
|
+
console.info(`Hanzogui error bundling components`, err.message, err.stack)
|
|
707
707
|
return null
|
|
708
708
|
} finally {
|
|
709
709
|
unregister()
|
|
@@ -712,7 +712,7 @@ export async function loadComponentsInner(
|
|
|
712
712
|
|
|
713
713
|
// sync version - uses cjs format for buildSync (no plugin support)
|
|
714
714
|
export function loadComponentsInnerSync(
|
|
715
|
-
props:
|
|
715
|
+
props: HanzoguiOptions,
|
|
716
716
|
forceExports = false
|
|
717
717
|
): null | LoadedComponents[] {
|
|
718
718
|
const componentsModules = props.components || []
|
|
@@ -779,7 +779,7 @@ export function loadComponentsInnerSync(
|
|
|
779
779
|
})
|
|
780
780
|
}
|
|
781
781
|
|
|
782
|
-
if (process.env.DEBUG === '
|
|
782
|
+
if (process.env.DEBUG === 'hanzogui') {
|
|
783
783
|
console.info(`loadModule`, loadModule, require.resolve(loadModule))
|
|
784
784
|
}
|
|
785
785
|
|
|
@@ -814,7 +814,7 @@ export function loadComponentsInnerSync(
|
|
|
814
814
|
} catch (err) {
|
|
815
815
|
console.info('babel err', err, writtenContents)
|
|
816
816
|
writtenContents = fileContents
|
|
817
|
-
if (process.env.DEBUG?.startsWith('
|
|
817
|
+
if (process.env.DEBUG?.startsWith('hanzogui')) {
|
|
818
818
|
console.info(`Error parsing babel likely`, err)
|
|
819
819
|
}
|
|
820
820
|
} finally {
|
|
@@ -824,9 +824,9 @@ export function loadComponentsInnerSync(
|
|
|
824
824
|
try {
|
|
825
825
|
return attemptLoad({ forceExports: false })
|
|
826
826
|
} catch (err) {
|
|
827
|
-
if (process.env.
|
|
827
|
+
if (process.env.TAMAGUI_ENABLE_WARN_DYNAMIC_LOAD) {
|
|
828
828
|
console.info(
|
|
829
|
-
`\
|
|
829
|
+
`\nHanzogui attempted but failed to dynamically optimize components in:\n ${name}\n`
|
|
830
830
|
)
|
|
831
831
|
console.info(err)
|
|
832
832
|
console.info(
|
|
@@ -846,7 +846,7 @@ export function loadComponentsInnerSync(
|
|
|
846
846
|
cacheComponents[key] = info
|
|
847
847
|
return info
|
|
848
848
|
} catch (err: any) {
|
|
849
|
-
console.info(`
|
|
849
|
+
console.info(`Hanzogui error bundling components`, err.message, err.stack)
|
|
850
850
|
return null
|
|
851
851
|
} finally {
|
|
852
852
|
unregister()
|
|
@@ -874,7 +874,7 @@ function getComponentStaticConfigByName(name: string, exported: any) {
|
|
|
874
874
|
}
|
|
875
875
|
|
|
876
876
|
for (const key in exported) {
|
|
877
|
-
const found =
|
|
877
|
+
const found = getHanzoguiComponent(key, exported[key])
|
|
878
878
|
if (found) {
|
|
879
879
|
// remove non-stringifyable
|
|
880
880
|
const { Component, ...sc } = found.staticConfig
|
|
@@ -882,9 +882,9 @@ function getComponentStaticConfigByName(name: string, exported: any) {
|
|
|
882
882
|
}
|
|
883
883
|
}
|
|
884
884
|
} catch (err) {
|
|
885
|
-
if (process.env.
|
|
885
|
+
if (process.env.TAMAGUI_ENABLE_WARN_DYNAMIC_LOAD) {
|
|
886
886
|
console.error(
|
|
887
|
-
`
|
|
887
|
+
`Hanzogui failed getting components from ${name} (Disable error by setting environment variable TAMAGUI_ENABLE_WARN_DYNAMIC_LOAD=1)`
|
|
888
888
|
)
|
|
889
889
|
console.error(err)
|
|
890
890
|
}
|
|
@@ -892,7 +892,7 @@ function getComponentStaticConfigByName(name: string, exported: any) {
|
|
|
892
892
|
return components
|
|
893
893
|
}
|
|
894
894
|
|
|
895
|
-
function
|
|
895
|
+
function getHanzoguiComponent(
|
|
896
896
|
name: string,
|
|
897
897
|
Component: any
|
|
898
898
|
): undefined | { staticConfig: StaticConfig } {
|
|
@@ -6,7 +6,7 @@ import * as t from '@babel/types'
|
|
|
6
6
|
import esbuild from 'esbuild'
|
|
7
7
|
|
|
8
8
|
import { FAILED_EVAL } from '../constants'
|
|
9
|
-
import type {
|
|
9
|
+
import type { HanzoguiOptionsWithFileInfo } from '../types'
|
|
10
10
|
import { evaluateAstNode } from './evaluateAstNode'
|
|
11
11
|
|
|
12
12
|
export function createEvaluator({
|
|
@@ -16,7 +16,7 @@ export function createEvaluator({
|
|
|
16
16
|
traversePath,
|
|
17
17
|
shouldPrintDebug,
|
|
18
18
|
}: {
|
|
19
|
-
props:
|
|
19
|
+
props: HanzoguiOptionsWithFileInfo
|
|
20
20
|
staticNamespace: Record<string, any>
|
|
21
21
|
sourcePath?: string
|
|
22
22
|
traversePath?: NodePath<t.JSXElement>
|