nuclie 1.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/LICENSE +21 -0
- package/README.md +516 -0
- package/dist/ai/analyzer.d.ts +29 -0
- package/dist/ai/analyzer.js +202 -0
- package/dist/ai/chat/cli.d.ts +3 -0
- package/dist/ai/chat/cli.js +38 -0
- package/dist/ai/client.d.ts +17 -0
- package/dist/ai/client.js +68 -0
- package/dist/ai/cloud/api.d.ts +28 -0
- package/dist/ai/cloud/api.js +118 -0
- package/dist/ai/cloud/modelSync.d.ts +18 -0
- package/dist/ai/cloud/modelSync.js +104 -0
- package/dist/ai/cloud/telemetry.d.ts +14 -0
- package/dist/ai/cloud/telemetry.js +23 -0
- package/dist/ai/config.d.ts +14 -0
- package/dist/ai/config.js +9 -0
- package/dist/ai/core/errorMemory.d.ts +14 -0
- package/dist/ai/core/errorMemory.js +36 -0
- package/dist/ai/dashboard/cli.d.ts +3 -0
- package/dist/ai/dashboard/cli.js +32 -0
- package/dist/ai/healer/applier.d.ts +9 -0
- package/dist/ai/healer/applier.js +74 -0
- package/dist/ai/healer/cli.d.ts +3 -0
- package/dist/ai/healer/cli.js +57 -0
- package/dist/ai/healer/collector.d.ts +16 -0
- package/dist/ai/healer/collector.js +41 -0
- package/dist/ai/healer/fixer.d.ts +12 -0
- package/dist/ai/healer/fixer.js +40 -0
- package/dist/ai/healer/llm.d.ts +9 -0
- package/dist/ai/healer/llm.js +20 -0
- package/dist/ai/healer/parser.d.ts +16 -0
- package/dist/ai/healer/parser.js +67 -0
- package/dist/ai/learning/evolver.d.ts +8 -0
- package/dist/ai/learning/evolver.js +24 -0
- package/dist/ai/llm/fixGenerator.d.ts +9 -0
- package/dist/ai/llm/fixGenerator.js +21 -0
- package/dist/ai/llm/ollama.d.ts +10 -0
- package/dist/ai/llm/ollama.js +56 -0
- package/dist/ai/local/fixStore.d.ts +19 -0
- package/dist/ai/local/fixStore.js +105 -0
- package/dist/ai/optimizer/analyzer.d.ts +9 -0
- package/dist/ai/optimizer/analyzer.js +65 -0
- package/dist/ai/optimizer/engine.d.ts +16 -0
- package/dist/ai/optimizer/engine.js +51 -0
- package/dist/ai/optimizer/llm.d.ts +8 -0
- package/dist/ai/optimizer/llm.js +14 -0
- package/dist/ai/optimizer/profiler.d.ts +11 -0
- package/dist/ai/optimizer/profiler.js +111 -0
- package/dist/ai/optimizer/rules.d.ts +12 -0
- package/dist/ai/optimizer/rules.js +37 -0
- package/dist/ai/patterns/common.d.ts +8 -0
- package/dist/ai/patterns/common.js +181 -0
- package/dist/ai/reporter/assembler.d.ts +11 -0
- package/dist/ai/reporter/assembler.js +10 -0
- package/dist/ai/reporter/generator.d.ts +4 -0
- package/dist/ai/reporter/generator.js +42 -0
- package/dist/ai/reporter/narrator.d.ts +8 -0
- package/dist/ai/reporter/narrator.js +29 -0
- package/dist/ai/schema.d.ts +104 -0
- package/dist/ai/schema.js +45 -0
- package/dist/ai/telemetry.d.ts +14 -0
- package/dist/ai/telemetry.js +96 -0
- package/dist/audit/a11y.d.ts +5 -0
- package/dist/audit/a11y.js +123 -0
- package/dist/audit/best-practices.d.ts +5 -0
- package/dist/audit/best-practices.js +68 -0
- package/dist/audit/build-integration.d.ts +59 -0
- package/dist/audit/build-integration.js +138 -0
- package/dist/audit/core.d.ts +62 -0
- package/dist/audit/core.js +327 -0
- package/dist/audit/index.d.ts +4 -0
- package/dist/audit/index.js +60 -0
- package/dist/audit/perf.d.ts +5 -0
- package/dist/audit/perf.js +69 -0
- package/dist/audit/seo.d.ts +5 -0
- package/dist/audit/seo.js +63 -0
- package/dist/audit/types.d.ts +35 -0
- package/dist/audit/types.js +1 -0
- package/dist/audit-stub/types.d.ts +25 -0
- package/dist/audit-stub/types.js +1 -0
- package/dist/build/bundle-stats.d.ts +2 -0
- package/dist/build/bundle-stats.js +42 -0
- package/dist/build/bundler.d.ts +46 -0
- package/dist/build/bundler.js +31 -0
- package/dist/build/index.d.ts +36 -0
- package/dist/build/index.js +69 -0
- package/dist/build/pipeline.d.ts +31 -0
- package/dist/build/pipeline.js +68 -0
- package/dist/builder/server.d.ts +11 -0
- package/dist/builder/server.js +253 -0
- package/dist/cache/incremental.d.ts +75 -0
- package/dist/cache/incremental.js +200 -0
- package/dist/cache/index.d.ts +17 -0
- package/dist/cache/index.js +186 -0
- package/dist/cache/rocksdb.d.ts +18 -0
- package/dist/cache/rocksdb.js +63 -0
- package/dist/cli/css-cli.d.ts +5 -0
- package/dist/cli/css-cli.js +112 -0
- package/dist/cli/inspect.d.ts +1 -0
- package/dist/cli/inspect.js +94 -0
- package/dist/cli.d.ts +2 -0
- package/dist/cli.js +586 -0
- package/dist/commands/analyze.d.ts +1 -0
- package/dist/commands/analyze.js +295 -0
- package/dist/commands/doctor.d.ts +21 -0
- package/dist/commands/doctor.js +364 -0
- package/dist/commands/ssr.d.ts +12 -0
- package/dist/commands/ssr.js +30 -0
- package/dist/commands/verify.d.ts +38 -0
- package/dist/commands/verify.js +459 -0
- package/dist/config/index.d.ts +145 -0
- package/dist/config/index.js +227 -0
- package/dist/config/live-config.d.ts +22 -0
- package/dist/config/live-config.js +88 -0
- package/dist/core/__tests__/permissions.test.d.ts +1 -0
- package/dist/core/__tests__/permissions.test.js +16 -0
- package/dist/core/__tests__/universal-transformer.test.d.ts +1 -0
- package/dist/core/__tests__/universal-transformer.test.js +27 -0
- package/dist/core/build/globalOptimizer.d.ts +8 -0
- package/dist/core/build/globalOptimizer.js +21 -0
- package/dist/core/build/incremental.d.ts +13 -0
- package/dist/core/build/incremental.js +29 -0
- package/dist/core/bundler-rolldown.d.ts +42 -0
- package/dist/core/bundler-rolldown.js +100 -0
- package/dist/core/cache/lazy-init.d.ts +50 -0
- package/dist/core/cache/lazy-init.js +153 -0
- package/dist/core/cache-manager.d.ts +51 -0
- package/dist/core/cache-manager.js +149 -0
- package/dist/core/css/engine.d.ts +37 -0
- package/dist/core/css/engine.js +113 -0
- package/dist/core/css-framework-detector.d.ts +10 -0
- package/dist/core/css-framework-detector.js +169 -0
- package/dist/core/detection/files.d.ts +2 -0
- package/dist/core/detection/files.js +77 -0
- package/dist/core/detection/index.d.ts +8 -0
- package/dist/core/detection/index.js +39 -0
- package/dist/core/detection/resolver.d.ts +2 -0
- package/dist/core/detection/resolver.js +116 -0
- package/dist/core/detection/scanner.d.ts +4 -0
- package/dist/core/detection/scanner.js +145 -0
- package/dist/core/detection/types.d.ts +33 -0
- package/dist/core/detection/types.js +12 -0
- package/dist/core/engine/cache.d.ts +18 -0
- package/dist/core/engine/cache.js +72 -0
- package/dist/core/engine/config.d.ts +11 -0
- package/dist/core/engine/config.js +158 -0
- package/dist/core/engine/emit.d.ts +8 -0
- package/dist/core/engine/emit.js +60 -0
- package/dist/core/engine/events.d.ts +13 -0
- package/dist/core/engine/events.js +35 -0
- package/dist/core/engine/execute.d.ts +5 -0
- package/dist/core/engine/execute.js +226 -0
- package/dist/core/engine/hash.d.ts +8 -0
- package/dist/core/engine/hash.js +39 -0
- package/dist/core/engine/index.d.ts +49 -0
- package/dist/core/engine/index.js +156 -0
- package/dist/core/engine/optimize.d.ts +2 -0
- package/dist/core/engine/optimize.js +99 -0
- package/dist/core/engine/plan.d.ts +9 -0
- package/dist/core/engine/plan.js +196 -0
- package/dist/core/engine/types.d.ts +120 -0
- package/dist/core/engine/types.js +1 -0
- package/dist/core/errors/hero-errors.d.ts +57 -0
- package/dist/core/errors/hero-errors.js +269 -0
- package/dist/core/framework-detector.d.ts +20 -0
- package/dist/core/framework-detector.js +148 -0
- package/dist/core/graph/js-graph-analyzer.d.ts +51 -0
- package/dist/core/graph/js-graph-analyzer.js +178 -0
- package/dist/core/graph/serializer.d.ts +7 -0
- package/dist/core/graph/serializer.js +24 -0
- package/dist/core/interop/analyze.d.ts +8 -0
- package/dist/core/interop/analyze.js +82 -0
- package/dist/core/interop/analyze_ast.d.ts +9 -0
- package/dist/core/interop/analyze_ast.js +174 -0
- package/dist/core/interop/index.d.ts +19 -0
- package/dist/core/interop/index.js +36 -0
- package/dist/core/interop/resolve.d.ts +9 -0
- package/dist/core/interop/resolve.js +55 -0
- package/dist/core/interop/types.d.ts +28 -0
- package/dist/core/interop/types.js +2 -0
- package/dist/core/interop/wrapper.d.ts +11 -0
- package/dist/core/interop/wrapper.js +50 -0
- package/dist/core/parser-bun.d.ts +54 -0
- package/dist/core/parser-bun.js +86 -0
- package/dist/core/permissions.d.ts +16 -0
- package/dist/core/permissions.js +47 -0
- package/dist/core/pipeline/framework-pipeline.d.ts +71 -0
- package/dist/core/pipeline/framework-pipeline.js +113 -0
- package/dist/core/plugins/index.d.ts +5 -0
- package/dist/core/plugins/index.js +5 -0
- package/dist/core/plugins/manager.d.ts +30 -0
- package/dist/core/plugins/manager.js +123 -0
- package/dist/core/plugins/sandbox_js.d.ts +9 -0
- package/dist/core/plugins/sandbox_js.js +37 -0
- package/dist/core/plugins/sandbox_wasm.d.ts +10 -0
- package/dist/core/plugins/sandbox_wasm.js +68 -0
- package/dist/core/plugins/types.d.ts +37 -0
- package/dist/core/plugins/types.js +2 -0
- package/dist/core/plugins/validation.d.ts +8 -0
- package/dist/core/plugins/validation.js +30 -0
- package/dist/core/sandbox.d.ts +9 -0
- package/dist/core/sandbox.js +79 -0
- package/dist/core/steps/css-optimization.d.ts +65 -0
- package/dist/core/steps/css-optimization.js +318 -0
- package/dist/core/steps.d.ts +7 -0
- package/dist/core/steps.js +17 -0
- package/dist/core/transform/batchTransformer.d.ts +12 -0
- package/dist/core/transform/batchTransformer.js +24 -0
- package/dist/core/transform/transformer.d.ts +9 -0
- package/dist/core/transform/transformer.js +189 -0
- package/dist/core/universal-transformer.d.ts +81 -0
- package/dist/core/universal-transformer.js +780 -0
- package/dist/create/index.d.ts +25 -0
- package/dist/create/index.js +584 -0
- package/dist/create/ui.d.ts +13 -0
- package/dist/create/ui.js +218 -0
- package/dist/create-nuclie/cli.d.ts +7 -0
- package/dist/create-nuclie/cli.js +73 -0
- package/dist/create-nuclie/templates.d.ts +18 -0
- package/dist/create-nuclie/templates.js +73 -0
- package/dist/create-nuclie.d.ts +2 -0
- package/dist/create-nuclie.js +7 -0
- package/dist/dashboard/metrics.d.ts +31 -0
- package/dist/dashboard/metrics.js +59 -0
- package/dist/dashboard/server/router.d.ts +52 -0
- package/dist/dashboard/server/router.js +36 -0
- package/dist/dev/__tests__/preBundler.test.d.ts +1 -0
- package/dist/dev/__tests__/preBundler.test.js +51 -0
- package/dist/dev/configWatcher.d.ts +10 -0
- package/dist/dev/configWatcher.js +42 -0
- package/dist/dev/devServer.d.ts +2 -0
- package/dist/dev/devServer.js +1398 -0
- package/dist/dev/devServer.minimal.d.ts +8 -0
- package/dist/dev/devServer.minimal.js +122 -0
- package/dist/dev/federation-dev.d.ts +14 -0
- package/dist/dev/federation-dev.js +69 -0
- package/dist/dev/hmr-engine.d.ts +12 -0
- package/dist/dev/hmr-engine.js +66 -0
- package/dist/dev/hmr-v2.d.ts +40 -0
- package/dist/dev/hmr-v2.js +87 -0
- package/dist/dev/hmrThrottle.d.ts +13 -0
- package/dist/dev/hmrThrottle.js +56 -0
- package/dist/dev/overlay/overlay-client.d.ts +7 -0
- package/dist/dev/overlay/overlay-client.js +53 -0
- package/dist/dev/overlay/overlay-ui.d.ts +17 -0
- package/dist/dev/overlay/overlay-ui.js +133 -0
- package/dist/dev/preBundler.d.ts +17 -0
- package/dist/dev/preBundler.js +343 -0
- package/dist/dev/statusHandler.d.ts +11 -0
- package/dist/dev/statusHandler.js +44 -0
- package/dist/dev/types.d.ts +30 -0
- package/dist/dev/types.js +1 -0
- package/dist/dev/watcher.d.ts +11 -0
- package/dist/dev/watcher.js +40 -0
- package/dist/dev-server-manual.d.ts +5 -0
- package/dist/dev-server-manual.js +24 -0
- package/dist/dev-server.d.ts +25 -0
- package/dist/dev-server.js +255 -0
- package/dist/env/api.d.ts +27 -0
- package/dist/env/api.js +36 -0
- package/dist/fix/ast-transforms.d.ts +81 -0
- package/dist/fix/ast-transforms.js +449 -0
- package/dist/hmr/classifier.d.ts +51 -0
- package/dist/hmr/classifier.js +232 -0
- package/dist/hmr/index.d.ts +5 -0
- package/dist/hmr/index.js +5 -0
- package/dist/hmr/overlay.d.ts +39 -0
- package/dist/hmr/overlay.js +285 -0
- package/dist/index.d.ts +46 -0
- package/dist/index.js +57 -0
- package/dist/init/bootstrap.d.ts +1 -0
- package/dist/init/bootstrap.js +106 -0
- package/dist/init/index.d.ts +1 -0
- package/dist/init/index.js +74 -0
- package/dist/init/templates.d.ts +2 -0
- package/dist/init/templates.js +227 -0
- package/dist/main.d.ts +1 -0
- package/dist/main.js +3 -0
- package/dist/marketplace/client.d.ts +25 -0
- package/dist/marketplace/client.js +73 -0
- package/dist/marketplace/db.d.ts +24 -0
- package/dist/marketplace/db.js +57 -0
- package/dist/marketplace/plugin-adapter.d.ts +14 -0
- package/dist/marketplace/plugin-adapter.js +85 -0
- package/dist/marketplace/server.d.ts +66 -0
- package/dist/marketplace/server.js +97 -0
- package/dist/meta-frameworks/base-router.d.ts +63 -0
- package/dist/meta-frameworks/base-router.js +259 -0
- package/dist/meta-frameworks/index.d.ts +8 -0
- package/dist/meta-frameworks/index.js +8 -0
- package/dist/meta-frameworks/nextjs/router.d.ts +35 -0
- package/dist/meta-frameworks/nextjs/router.js +176 -0
- package/dist/meta-frameworks/nuxt/router.d.ts +22 -0
- package/dist/meta-frameworks/nuxt/router.js +84 -0
- package/dist/meta-frameworks/remix/router.d.ts +28 -0
- package/dist/meta-frameworks/remix/router.js +136 -0
- package/dist/meta-frameworks/ssr/react-renderer.d.ts +24 -0
- package/dist/meta-frameworks/ssr/react-renderer.js +53 -0
- package/dist/meta-frameworks/ssr/server.d.ts +92 -0
- package/dist/meta-frameworks/ssr/server.js +312 -0
- package/dist/meta-frameworks/ssr/vue-renderer.d.ts +11 -0
- package/dist/meta-frameworks/ssr/vue-renderer.js +35 -0
- package/dist/meta-frameworks/types.d.ts +76 -0
- package/dist/meta-frameworks/types.js +5 -0
- package/dist/migrate/analyzer.d.ts +46 -0
- package/dist/migrate/analyzer.js +254 -0
- package/dist/migrate/cli.d.ts +10 -0
- package/dist/migrate/cli.js +63 -0
- package/dist/migrate/generator.d.ts +32 -0
- package/dist/migrate/generator.js +214 -0
- package/dist/native/cache.d.ts +86 -0
- package/dist/native/cache.js +154 -0
- package/dist/native/index.d.ts +4 -0
- package/dist/native/index.js +56 -0
- package/dist/native/orchestrator.d.ts +78 -0
- package/dist/native/orchestrator.js +107 -0
- package/dist/native/wasm.d.ts +22 -0
- package/dist/native/wasm.js +33 -0
- package/dist/nuclie_native.node +0 -0
- package/dist/plugins/assets.d.ts +2 -0
- package/dist/plugins/assets.js +50 -0
- package/dist/plugins/compat/adapter.d.ts +33 -0
- package/dist/plugins/compat/adapter.js +102 -0
- package/dist/plugins/compat/deferred.d.ts +17 -0
- package/dist/plugins/compat/deferred.js +28 -0
- package/dist/plugins/compat/index.d.ts +11 -0
- package/dist/plugins/compat/index.js +11 -0
- package/dist/plugins/compat/rollup.d.ts +19 -0
- package/dist/plugins/compat/rollup.js +76 -0
- package/dist/plugins/compat/tier-a.d.ts +60 -0
- package/dist/plugins/compat/tier-a.js +132 -0
- package/dist/plugins/compat/tier-b.d.ts +34 -0
- package/dist/plugins/compat/tier-b.js +90 -0
- package/dist/plugins/compat/tier-c.d.ts +48 -0
- package/dist/plugins/compat/tier-c.js +49 -0
- package/dist/plugins/compat/webpack.d.ts +26 -0
- package/dist/plugins/compat/webpack.js +77 -0
- package/dist/plugins/core/linker.d.ts +8 -0
- package/dist/plugins/core/linker.js +51 -0
- package/dist/plugins/css/bootstrap.d.ts +25 -0
- package/dist/plugins/css/bootstrap.js +110 -0
- package/dist/plugins/css/bulma.d.ts +23 -0
- package/dist/plugins/css/bulma.js +75 -0
- package/dist/plugins/css/css-modules.d.ts +19 -0
- package/dist/plugins/css/css-modules.js +96 -0
- package/dist/plugins/css/css-optimizer.d.ts +43 -0
- package/dist/plugins/css/css-optimizer.js +155 -0
- package/dist/plugins/css/emotion.d.ts +35 -0
- package/dist/plugins/css/emotion.js +109 -0
- package/dist/plugins/css/less.d.ts +6 -0
- package/dist/plugins/css/less.js +33 -0
- package/dist/plugins/css/material.d.ts +24 -0
- package/dist/plugins/css/material.js +97 -0
- package/dist/plugins/css/postcss.d.ts +2 -0
- package/dist/plugins/css/postcss.js +96 -0
- package/dist/plugins/css/sass.d.ts +6 -0
- package/dist/plugins/css/sass.js +36 -0
- package/dist/plugins/css/styled-components.d.ts +33 -0
- package/dist/plugins/css/styled-components.js +94 -0
- package/dist/plugins/css/stylus.d.ts +6 -0
- package/dist/plugins/css/stylus.js +41 -0
- package/dist/plugins/css/tailwind.d.ts +9 -0
- package/dist/plugins/css/tailwind.js +132 -0
- package/dist/plugins/css-in-js.d.ts +10 -0
- package/dist/plugins/css-in-js.js +24 -0
- package/dist/plugins/edge.d.ts +7 -0
- package/dist/plugins/edge.js +38 -0
- package/dist/plugins/esbuildAdapter.d.ts +3 -0
- package/dist/plugins/esbuildAdapter.js +77 -0
- package/dist/plugins/federation_next.d.ts +16 -0
- package/dist/plugins/federation_next.js +78 -0
- package/dist/plugins/framework-plugins.d.ts +3 -0
- package/dist/plugins/framework-plugins.js +40 -0
- package/dist/plugins/frameworks/index.d.ts +8 -0
- package/dist/plugins/frameworks/index.js +10 -0
- package/dist/plugins/frameworks/lit.d.ts +36 -0
- package/dist/plugins/frameworks/lit.js +114 -0
- package/dist/plugins/frameworks/react.d.ts +38 -0
- package/dist/plugins/frameworks/react.js +144 -0
- package/dist/plugins/frameworks/solid.d.ts +36 -0
- package/dist/plugins/frameworks/solid.js +108 -0
- package/dist/plugins/frameworks/svelte.d.ts +43 -0
- package/dist/plugins/frameworks/svelte.js +144 -0
- package/dist/plugins/frameworks/vue.d.ts +43 -0
- package/dist/plugins/frameworks/vue.js +240 -0
- package/dist/plugins/governance.d.ts +36 -0
- package/dist/plugins/governance.js +50 -0
- package/dist/plugins/html.d.ts +2 -0
- package/dist/plugins/html.js +49 -0
- package/dist/plugins/implementations/analytics.d.ts +7 -0
- package/dist/plugins/implementations/analytics.js +15 -0
- package/dist/plugins/implementations/apollo.d.ts +7 -0
- package/dist/plugins/implementations/apollo.js +15 -0
- package/dist/plugins/implementations/audit.d.ts +7 -0
- package/dist/plugins/implementations/audit.js +30 -0
- package/dist/plugins/implementations/auto-fix.d.ts +7 -0
- package/dist/plugins/implementations/auto-fix.js +15 -0
- package/dist/plugins/implementations/avif.d.ts +7 -0
- package/dist/plugins/implementations/avif.js +27 -0
- package/dist/plugins/implementations/babel.d.ts +7 -0
- package/dist/plugins/implementations/babel.js +15 -0
- package/dist/plugins/implementations/bundle-analyzer.d.ts +7 -0
- package/dist/plugins/implementations/bundle-analyzer.js +21 -0
- package/dist/plugins/implementations/bundle-size.d.ts +7 -0
- package/dist/plugins/implementations/bundle-size.js +21 -0
- package/dist/plugins/implementations/checker.d.ts +7 -0
- package/dist/plugins/implementations/checker.js +15 -0
- package/dist/plugins/implementations/chromatic.d.ts +7 -0
- package/dist/plugins/implementations/chromatic.js +15 -0
- package/dist/plugins/implementations/cloudflare.d.ts +7 -0
- package/dist/plugins/implementations/cloudflare.js +15 -0
- package/dist/plugins/implementations/code-split.d.ts +7 -0
- package/dist/plugins/implementations/code-split.js +21 -0
- package/dist/plugins/implementations/compression.d.ts +7 -0
- package/dist/plugins/implementations/compression.js +21 -0
- package/dist/plugins/implementations/copy.d.ts +7 -0
- package/dist/plugins/implementations/copy.js +15 -0
- package/dist/plugins/implementations/critical-css.d.ts +7 -0
- package/dist/plugins/implementations/critical-css.js +25 -0
- package/dist/plugins/implementations/crypto-sign.d.ts +7 -0
- package/dist/plugins/implementations/crypto-sign.js +30 -0
- package/dist/plugins/implementations/css-framework.d.ts +7 -0
- package/dist/plugins/implementations/css-framework.js +25 -0
- package/dist/plugins/implementations/css.d.ts +7 -0
- package/dist/plugins/implementations/css.js +25 -0
- package/dist/plugins/implementations/cypress.d.ts +7 -0
- package/dist/plugins/implementations/cypress.js +15 -0
- package/dist/plugins/implementations/determinism.d.ts +7 -0
- package/dist/plugins/implementations/determinism.js +21 -0
- package/dist/plugins/implementations/edge.d.ts +8 -0
- package/dist/plugins/implementations/edge.js +35 -0
- package/dist/plugins/implementations/env-validation.d.ts +7 -0
- package/dist/plugins/implementations/env-validation.js +30 -0
- package/dist/plugins/implementations/eslint.d.ts +7 -0
- package/dist/plugins/implementations/eslint.js +15 -0
- package/dist/plugins/implementations/federation.d.ts +7 -0
- package/dist/plugins/implementations/federation.js +15 -0
- package/dist/plugins/implementations/file.d.ts +7 -0
- package/dist/plugins/implementations/file.js +27 -0
- package/dist/plugins/implementations/font-subset.d.ts +7 -0
- package/dist/plugins/implementations/font-subset.js +27 -0
- package/dist/plugins/implementations/fonts.d.ts +7 -0
- package/dist/plugins/implementations/fonts.js +27 -0
- package/dist/plugins/implementations/formatjs.d.ts +7 -0
- package/dist/plugins/implementations/formatjs.js +18 -0
- package/dist/plugins/implementations/graphql.d.ts +7 -0
- package/dist/plugins/implementations/graphql.js +15 -0
- package/dist/plugins/implementations/hmr-classify.d.ts +7 -0
- package/dist/plugins/implementations/hmr-classify.js +21 -0
- package/dist/plugins/implementations/html.d.ts +7 -0
- package/dist/plugins/implementations/html.js +15 -0
- package/dist/plugins/implementations/i18n.d.ts +7 -0
- package/dist/plugins/implementations/i18n.js +15 -0
- package/dist/plugins/implementations/icon.d.ts +7 -0
- package/dist/plugins/implementations/icon.js +27 -0
- package/dist/plugins/implementations/imagemin.d.ts +7 -0
- package/dist/plugins/implementations/imagemin.js +27 -0
- package/dist/plugins/implementations/inspect.d.ts +7 -0
- package/dist/plugins/implementations/inspect.js +15 -0
- package/dist/plugins/implementations/jest.d.ts +7 -0
- package/dist/plugins/implementations/jest.js +19 -0
- package/dist/plugins/implementations/jotai.d.ts +8 -0
- package/dist/plugins/implementations/jotai.js +35 -0
- package/dist/plugins/implementations/lazy-load.d.ts +7 -0
- package/dist/plugins/implementations/lazy-load.js +21 -0
- package/dist/plugins/implementations/legacy.d.ts +7 -0
- package/dist/plugins/implementations/legacy.js +15 -0
- package/dist/plugins/implementations/lighthouse.d.ts +7 -0
- package/dist/plugins/implementations/lighthouse.js +21 -0
- package/dist/plugins/implementations/manifest.d.ts +7 -0
- package/dist/plugins/implementations/manifest.js +15 -0
- package/dist/plugins/implementations/markdown.d.ts +7 -0
- package/dist/plugins/implementations/markdown.js +15 -0
- package/dist/plugins/implementations/md.d.ts +7 -0
- package/dist/plugins/implementations/md.js +15 -0
- package/dist/plugins/implementations/mdx.d.ts +7 -0
- package/dist/plugins/implementations/mdx.js +15 -0
- package/dist/plugins/implementations/meta-tags.d.ts +7 -0
- package/dist/plugins/implementations/meta-tags.js +15 -0
- package/dist/plugins/implementations/mini-css-extract-plugin.d.ts +7 -0
- package/dist/plugins/implementations/mini-css-extract-plugin.js +25 -0
- package/dist/plugins/implementations/mobx.d.ts +8 -0
- package/dist/plugins/implementations/mobx.js +35 -0
- package/dist/plugins/implementations/mock.d.ts +7 -0
- package/dist/plugins/implementations/mock.js +15 -0
- package/dist/plugins/implementations/msw.d.ts +7 -0
- package/dist/plugins/implementations/msw.js +19 -0
- package/dist/plugins/implementations/nanostores.d.ts +7 -0
- package/dist/plugins/implementations/nanostores.js +18 -0
- package/dist/plugins/implementations/netlify.d.ts +7 -0
- package/dist/plugins/implementations/netlify.js +15 -0
- package/dist/plugins/implementations/observability.d.ts +7 -0
- package/dist/plugins/implementations/observability.js +15 -0
- package/dist/plugins/implementations/og-image.d.ts +7 -0
- package/dist/plugins/implementations/og-image.js +15 -0
- package/dist/plugins/implementations/pages.d.ts +7 -0
- package/dist/plugins/implementations/pages.js +15 -0
- package/dist/plugins/implementations/pinia.d.ts +8 -0
- package/dist/plugins/implementations/pinia.js +35 -0
- package/dist/plugins/implementations/plausible.d.ts +7 -0
- package/dist/plugins/implementations/plausible.js +18 -0
- package/dist/plugins/implementations/playwright.d.ts +7 -0
- package/dist/plugins/implementations/playwright.js +15 -0
- package/dist/plugins/implementations/postcss.d.ts +7 -0
- package/dist/plugins/implementations/postcss.js +25 -0
- package/dist/plugins/implementations/posthog.d.ts +7 -0
- package/dist/plugins/implementations/posthog.js +18 -0
- package/dist/plugins/implementations/prebundle.d.ts +7 -0
- package/dist/plugins/implementations/prebundle.js +21 -0
- package/dist/plugins/implementations/prefetch.d.ts +7 -0
- package/dist/plugins/implementations/prefetch.js +21 -0
- package/dist/plugins/implementations/preload.d.ts +7 -0
- package/dist/plugins/implementations/preload.js +21 -0
- package/dist/plugins/implementations/prisma.d.ts +7 -0
- package/dist/plugins/implementations/prisma.js +15 -0
- package/dist/plugins/implementations/pwa.d.ts +7 -0
- package/dist/plugins/implementations/pwa.js +15 -0
- package/dist/plugins/implementations/qr-code.d.ts +7 -0
- package/dist/plugins/implementations/qr-code.js +19 -0
- package/dist/plugins/implementations/razorpay.d.ts +7 -0
- package/dist/plugins/implementations/razorpay.js +19 -0
- package/dist/plugins/implementations/react-i18next.d.ts +7 -0
- package/dist/plugins/implementations/react-i18next.js +18 -0
- package/dist/plugins/implementations/react-query.d.ts +8 -0
- package/dist/plugins/implementations/react-query.js +35 -0
- package/dist/plugins/implementations/react.d.ts +8 -0
- package/dist/plugins/implementations/react.js +35 -0
- package/dist/plugins/implementations/recoil.d.ts +8 -0
- package/dist/plugins/implementations/recoil.js +35 -0
- package/dist/plugins/implementations/redux.d.ts +8 -0
- package/dist/plugins/implementations/redux.js +35 -0
- package/dist/plugins/implementations/relay.d.ts +7 -0
- package/dist/plugins/implementations/relay.js +15 -0
- package/dist/plugins/implementations/repro.d.ts +7 -0
- package/dist/plugins/implementations/repro.js +15 -0
- package/dist/plugins/implementations/robots.d.ts +7 -0
- package/dist/plugins/implementations/robots.js +15 -0
- package/dist/plugins/implementations/root-cause.d.ts +7 -0
- package/dist/plugins/implementations/root-cause.js +15 -0
- package/dist/plugins/implementations/rss.d.ts +7 -0
- package/dist/plugins/implementations/rss.js +15 -0
- package/dist/plugins/implementations/sass.d.ts +7 -0
- package/dist/plugins/implementations/sass.js +25 -0
- package/dist/plugins/implementations/sentry.d.ts +7 -0
- package/dist/plugins/implementations/sentry.js +15 -0
- package/dist/plugins/implementations/sitemap.d.ts +7 -0
- package/dist/plugins/implementations/sitemap.js +15 -0
- package/dist/plugins/implementations/solid.d.ts +8 -0
- package/dist/plugins/implementations/solid.js +35 -0
- package/dist/plugins/implementations/sprite.d.ts +7 -0
- package/dist/plugins/implementations/sprite.js +27 -0
- package/dist/plugins/implementations/ssr.d.ts +8 -0
- package/dist/plugins/implementations/ssr.js +35 -0
- package/dist/plugins/implementations/storybook.d.ts +7 -0
- package/dist/plugins/implementations/storybook.js +15 -0
- package/dist/plugins/implementations/stripe.d.ts +7 -0
- package/dist/plugins/implementations/stripe.js +19 -0
- package/dist/plugins/implementations/style.d.ts +7 -0
- package/dist/plugins/implementations/style.js +25 -0
- package/dist/plugins/implementations/svelte.d.ts +8 -0
- package/dist/plugins/implementations/svelte.js +35 -0
- package/dist/plugins/implementations/tailwind.d.ts +7 -0
- package/dist/plugins/implementations/tailwind.js +25 -0
- package/dist/plugins/implementations/tanstack-query.d.ts +7 -0
- package/dist/plugins/implementations/tanstack-query.js +18 -0
- package/dist/plugins/implementations/terser.d.ts +7 -0
- package/dist/plugins/implementations/terser.js +21 -0
- package/dist/plugins/implementations/testing-library-react.d.ts +7 -0
- package/dist/plugins/implementations/testing-library-react.js +19 -0
- package/dist/plugins/implementations/testing-library.d.ts +7 -0
- package/dist/plugins/implementations/testing-library.js +15 -0
- package/dist/plugins/implementations/tree-shake.d.ts +7 -0
- package/dist/plugins/implementations/tree-shake.js +21 -0
- package/dist/plugins/implementations/trpc.d.ts +7 -0
- package/dist/plugins/implementations/trpc.js +15 -0
- package/dist/plugins/implementations/ts.d.ts +7 -0
- package/dist/plugins/implementations/ts.js +15 -0
- package/dist/plugins/implementations/typescript.d.ts +7 -0
- package/dist/plugins/implementations/typescript.js +15 -0
- package/dist/plugins/implementations/unocss.d.ts +7 -0
- package/dist/plugins/implementations/unocss.js +25 -0
- package/dist/plugins/implementations/upi-payment.d.ts +7 -0
- package/dist/plugins/implementations/upi-payment.js +19 -0
- package/dist/plugins/implementations/url.d.ts +7 -0
- package/dist/plugins/implementations/url.js +27 -0
- package/dist/plugins/implementations/vercel.d.ts +7 -0
- package/dist/plugins/implementations/vercel.js +15 -0
- package/dist/plugins/implementations/visualizer.d.ts +7 -0
- package/dist/plugins/implementations/visualizer.js +15 -0
- package/dist/plugins/implementations/vite-svg-loader.d.ts +7 -0
- package/dist/plugins/implementations/vite-svg-loader.js +27 -0
- package/dist/plugins/implementations/vitest.d.ts +7 -0
- package/dist/plugins/implementations/vitest.js +15 -0
- package/dist/plugins/implementations/vue-i18n-next.d.ts +7 -0
- package/dist/plugins/implementations/vue-i18n-next.js +18 -0
- package/dist/plugins/implementations/vue-i18n.d.ts +7 -0
- package/dist/plugins/implementations/vue-i18n.js +15 -0
- package/dist/plugins/implementations/vue-layouts.d.ts +8 -0
- package/dist/plugins/implementations/vue-layouts.js +35 -0
- package/dist/plugins/implementations/vue.d.ts +8 -0
- package/dist/plugins/implementations/vue.js +35 -0
- package/dist/plugins/implementations/vuex.d.ts +8 -0
- package/dist/plugins/implementations/vuex.js +35 -0
- package/dist/plugins/implementations/wasm-sandbox.d.ts +7 -0
- package/dist/plugins/implementations/wasm-sandbox.js +30 -0
- package/dist/plugins/implementations/webp.d.ts +7 -0
- package/dist/plugins/implementations/webp.js +27 -0
- package/dist/plugins/implementations/windicss.d.ts +7 -0
- package/dist/plugins/implementations/windicss.js +25 -0
- package/dist/plugins/implementations/workbox.d.ts +7 -0
- package/dist/plugins/implementations/workbox.js +15 -0
- package/dist/plugins/implementations/xstate.d.ts +7 -0
- package/dist/plugins/implementations/xstate.js +18 -0
- package/dist/plugins/implementations/zod.d.ts +7 -0
- package/dist/plugins/implementations/zod.js +15 -0
- package/dist/plugins/implementations/zustand-devtools.d.ts +7 -0
- package/dist/plugins/implementations/zustand-devtools.js +18 -0
- package/dist/plugins/implementations/zustand.d.ts +8 -0
- package/dist/plugins/implementations/zustand.js +35 -0
- package/dist/plugins/index.d.ts +49 -0
- package/dist/plugins/index.js +117 -0
- package/dist/plugins/js-transform.d.ts +2 -0
- package/dist/plugins/js-transform.js +49 -0
- package/dist/plugins/json.d.ts +2 -0
- package/dist/plugins/json.js +34 -0
- package/dist/plugins/pluginWorker.mjs +95 -0
- package/dist/plugins/ported/adapter.d.ts +92 -0
- package/dist/plugins/ported/adapter.js +226 -0
- package/dist/plugins/registry.d.ts +51 -0
- package/dist/plugins/registry.js +151 -0
- package/dist/plugins/reporter.d.ts +5 -0
- package/dist/plugins/reporter.js +47 -0
- package/dist/plugins/samplePlugin.mjs +4 -0
- package/dist/plugins/sandbox.d.ts +12 -0
- package/dist/plugins/sandbox.js +126 -0
- package/dist/plugins/signer.d.ts +53 -0
- package/dist/plugins/signer.js +109 -0
- package/dist/plugins/static.d.ts +2 -0
- package/dist/plugins/static.js +47 -0
- package/dist/plugins/svelte.d.ts +7 -0
- package/dist/plugins/svelte.js +27 -0
- package/dist/plugins/testSandbox.d.ts +1 -0
- package/dist/plugins/testSandbox.js +14 -0
- package/dist/plugins/verify.d.ts +3 -0
- package/dist/plugins/verify.js +113 -0
- package/dist/plugins/vue.d.ts +7 -0
- package/dist/plugins/vue.js +86 -0
- package/dist/plugins/wasm-runtime.d.ts +15 -0
- package/dist/plugins/wasm-runtime.js +33 -0
- package/dist/plugins/wasm.d.ts +5 -0
- package/dist/plugins/wasm.js +44 -0
- package/dist/polyfills/corejs.d.ts +9 -0
- package/dist/polyfills/corejs.js +18 -0
- package/dist/presets/core.d.ts +111 -0
- package/dist/presets/core.js +239 -0
- package/dist/presets/frameworks.d.ts +34 -0
- package/dist/presets/frameworks.js +270 -0
- package/dist/presets/index.d.ts +8 -0
- package/dist/presets/index.js +3 -0
- package/dist/presets/infrastructure.d.ts +2 -0
- package/dist/presets/infrastructure.js +33 -0
- package/dist/presets/spa.d.ts +2 -0
- package/dist/presets/spa.js +15 -0
- package/dist/presets/ssg.d.ts +2 -0
- package/dist/presets/ssg.js +9 -0
- package/dist/presets/ssr.d.ts +2 -0
- package/dist/presets/ssr.js +13 -0
- package/dist/repro/dashboard.d.ts +83 -0
- package/dist/repro/dashboard.js +251 -0
- package/dist/repro/github.d.ts +26 -0
- package/dist/repro/github.js +73 -0
- package/dist/resolve/css-precedence.d.ts +16 -0
- package/dist/resolve/css-precedence.js +56 -0
- package/dist/resolve/graph.d.ts +48 -0
- package/dist/resolve/graph.js +232 -0
- package/dist/resolve/utils.d.ts +13 -0
- package/dist/resolve/utils.js +53 -0
- package/dist/runtime/client.d.ts +9 -0
- package/dist/runtime/client.js +218 -0
- package/dist/runtime/error-overlay.d.ts +15 -0
- package/dist/runtime/error-overlay.js +327 -0
- package/dist/runtime/federation-fallback.d.ts +67 -0
- package/dist/runtime/federation-fallback.js +225 -0
- package/dist/runtime/federation.d.ts +27 -0
- package/dist/runtime/federation.js +210 -0
- package/dist/runtime/federation_runtime.js +90 -0
- package/dist/runtime/hmr-client.d.ts +5 -0
- package/dist/runtime/hmr-client.js +70 -0
- package/dist/security/anomaly.d.ts +41 -0
- package/dist/security/anomaly.js +77 -0
- package/dist/server/security-headers.d.ts +37 -0
- package/dist/server/security-headers.js +110 -0
- package/dist/ssr/adapters/edge.d.ts +12 -0
- package/dist/ssr/adapters/edge.js +26 -0
- package/dist/ssr/adapters/index.d.ts +23 -0
- package/dist/ssr/adapters/index.js +58 -0
- package/dist/ssr/app-router.d.ts +24 -0
- package/dist/ssr/app-router.js +70 -0
- package/dist/ssr/edge/handlers.d.ts +24 -0
- package/dist/ssr/edge/handlers.js +48 -0
- package/dist/ssr/image.d.ts +24 -0
- package/dist/ssr/image.js +38 -0
- package/dist/ssr/isr.d.ts +14 -0
- package/dist/ssr/isr.js +29 -0
- package/dist/ssr/rsc.d.ts +19 -0
- package/dist/ssr/rsc.js +33 -0
- package/dist/ssr/streaming.d.ts +31 -0
- package/dist/ssr/streaming.js +78 -0
- package/dist/ssr/universal-engine.d.ts +36 -0
- package/dist/ssr/universal-engine.js +139 -0
- package/dist/templates/manager.d.ts +28 -0
- package/dist/templates/manager.js +162 -0
- package/dist/templates/starters/angular-spa.d.ts +6 -0
- package/dist/templates/starters/angular-spa.js +149 -0
- package/dist/templates/starters/edge.d.ts +6 -0
- package/dist/templates/starters/edge.js +93 -0
- package/dist/templates/starters/fintech.d.ts +6 -0
- package/dist/templates/starters/fintech.js +211 -0
- package/dist/templates/starters/monorepo.d.ts +6 -0
- package/dist/templates/starters/monorepo.js +133 -0
- package/dist/templates/starters/nextjs-app.d.ts +13 -0
- package/dist/templates/starters/nextjs-app.js +116 -0
- package/dist/templates/starters/preact-spa.d.ts +6 -0
- package/dist/templates/starters/preact-spa.js +97 -0
- package/dist/templates/starters/premium-dashboard.d.ts +6 -0
- package/dist/templates/starters/premium-dashboard.js +762 -0
- package/dist/templates/starters/react-spa.d.ts +6 -0
- package/dist/templates/starters/react-spa.js +152 -0
- package/dist/templates/starters/react-ssr.d.ts +6 -0
- package/dist/templates/starters/react-ssr.js +190 -0
- package/dist/templates/starters/remix-app.d.ts +12 -0
- package/dist/templates/starters/remix-app.js +108 -0
- package/dist/templates/starters/solid-spa.d.ts +6 -0
- package/dist/templates/starters/solid-spa.js +158 -0
- package/dist/templates/starters/svelte-spa.d.ts +6 -0
- package/dist/templates/starters/svelte-spa.js +147 -0
- package/dist/templates/starters/vue-spa.d.ts +6 -0
- package/dist/templates/starters/vue-spa.js +136 -0
- package/dist/test/api.d.ts +58 -0
- package/dist/test/api.js +154 -0
- package/dist/test/coverage.d.ts +1 -0
- package/dist/test/coverage.js +134 -0
- package/dist/test/determinism.d.ts +1 -0
- package/dist/test/determinism.js +122 -0
- package/dist/test/regression.d.ts +1 -0
- package/dist/test/regression.js +30 -0
- package/dist/test/runner.d.ts +1 -0
- package/dist/test/runner.js +159 -0
- package/dist/test-server.d.ts +1 -0
- package/dist/test-server.js +22 -0
- package/dist/ui/terminal-warnings.d.ts +10 -0
- package/dist/ui/terminal-warnings.js +26 -0
- package/dist/ui/types.d.ts +13 -0
- package/dist/ui/types.js +5 -0
- package/dist/ui/warning-detector.d.ts +46 -0
- package/dist/ui/warning-detector.js +178 -0
- package/dist/ui/warning-library.d.ts +51 -0
- package/dist/ui/warning-library.js +283 -0
- package/dist/utils/interactive.d.ts +2 -0
- package/dist/utils/interactive.js +37 -0
- package/dist/utils/logger.d.ts +26 -0
- package/dist/utils/logger.js +130 -0
- package/dist/utils/path-normalize.d.ts +24 -0
- package/dist/utils/path-normalize.js +37 -0
- package/dist/visual/chart-generator.d.ts +11 -0
- package/dist/visual/chart-generator.js +30 -0
- package/dist/visual/client/renderer.d.ts +31 -0
- package/dist/visual/client/renderer.js +98 -0
- package/dist/visual/federation-editor.d.ts +1 -0
- package/dist/visual/federation-editor.js +231 -0
- package/dist/visual/graph-engine.d.ts +38 -0
- package/dist/visual/graph-engine.js +64 -0
- package/dist/visual/graph-ui.d.ts +2 -0
- package/dist/visual/graph-ui.js +119 -0
- package/dist/visual/graph-visualizer.d.ts +69 -0
- package/dist/visual/graph-visualizer.js +282 -0
- package/dist/visual/root-cause.d.ts +83 -0
- package/dist/visual/root-cause.js +265 -0
- package/package.json +169 -0
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Engine Configuration and Initialization
|
|
3
|
+
*
|
|
4
|
+
* @internal - This is part of the core engine and NOT a public API.
|
|
5
|
+
*/
|
|
6
|
+
import { InMemoryBuildCache, PersistentBuildCache } from './cache.js';
|
|
7
|
+
import { DependencyGraph } from '../../resolve/graph.js';
|
|
8
|
+
import { explainReporter } from './events.js';
|
|
9
|
+
import { canonicalHash } from './hash.js';
|
|
10
|
+
import fs from 'fs/promises';
|
|
11
|
+
import path from 'path';
|
|
12
|
+
import { PluginManager } from '../plugins/manager.js';
|
|
13
|
+
import { getInfrastructurePreset } from '../../presets/infrastructure.js';
|
|
14
|
+
// Stage 1: Initialization
|
|
15
|
+
export async function initBuild(userConfig, mode, rootDir) {
|
|
16
|
+
explainReporter.report('init', 'initialize', 'Starting build initialization');
|
|
17
|
+
const engine = {
|
|
18
|
+
name: "Nuclie",
|
|
19
|
+
version: "0.1.3", // Should normally come from package.json
|
|
20
|
+
buildTime: new Date().toISOString()
|
|
21
|
+
};
|
|
22
|
+
const config = resolveConfig(userConfig, rootDir, mode);
|
|
23
|
+
const useCache = userConfig.cache !== false;
|
|
24
|
+
const cache = useCache ? new PersistentBuildCache(rootDir) : new InMemoryBuildCache();
|
|
25
|
+
const pluginManager = new PluginManager();
|
|
26
|
+
// 1. Register Infrastructure (Phase B2)
|
|
27
|
+
const infraPlugins = getInfrastructurePreset(rootDir, config.outputDir, config);
|
|
28
|
+
for (const p of infraPlugins) {
|
|
29
|
+
await pluginManager.register(p);
|
|
30
|
+
}
|
|
31
|
+
// 2. Register User Plugins (Phase F2)
|
|
32
|
+
if (userConfig.plugins) {
|
|
33
|
+
for (const p of userConfig.plugins) {
|
|
34
|
+
await pluginManager.register(p);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
explainReporter.report('init', 'config_resolved', 'Config frozen', { config });
|
|
38
|
+
return {
|
|
39
|
+
engine,
|
|
40
|
+
mode,
|
|
41
|
+
rootDir,
|
|
42
|
+
env: process.env,
|
|
43
|
+
target: userConfig.platform || 'browser',
|
|
44
|
+
graph: new DependencyGraph(), // Empty initially
|
|
45
|
+
graphHash: '', // Placeholder
|
|
46
|
+
cache,
|
|
47
|
+
config,
|
|
48
|
+
pluginManager
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
function resolveConfig(userConfig, rootDir, mode) {
|
|
52
|
+
const sourcemap = userConfig.build?.sourcemap;
|
|
53
|
+
return {
|
|
54
|
+
entryPoints: userConfig.entry,
|
|
55
|
+
outputDir: path.isAbsolute(userConfig.outDir || 'dist')
|
|
56
|
+
? userConfig.outDir
|
|
57
|
+
: path.resolve(rootDir, userConfig.outDir || 'dist'),
|
|
58
|
+
publicPath: '/',
|
|
59
|
+
splittingStrategy: userConfig.build?.splitting ? 'module' : 'route',
|
|
60
|
+
hashing: 'content',
|
|
61
|
+
sourceMaps: sourcemap === 'none' ? false : (sourcemap === undefined ? 'external' : sourcemap),
|
|
62
|
+
minify: userConfig.build?.minify ?? (mode === 'production' || mode === 'build'),
|
|
63
|
+
cssModules: userConfig.build?.cssModules ?? false,
|
|
64
|
+
federation: userConfig.federation,
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
// Stage 2: Input Fingerprinting
|
|
68
|
+
export async function computeInputFingerprint(ctx) {
|
|
69
|
+
explainReporter.report('fingerprint', 'start', 'Computing input fingerprint');
|
|
70
|
+
// 1. Hash Config
|
|
71
|
+
// Normalize absolute paths to ensure deterministic hash across environments (CI vs Local)
|
|
72
|
+
const normalizedConfig = {
|
|
73
|
+
...ctx.config,
|
|
74
|
+
outputDir: path.relative(ctx.rootDir, ctx.config.outputDir)
|
|
75
|
+
};
|
|
76
|
+
const configHash = canonicalHash(normalizedConfig);
|
|
77
|
+
// 2. Hash Engine
|
|
78
|
+
// We strictly use version/name, NOT buildTime for semantic hash
|
|
79
|
+
const engineFingerprint = canonicalHash({ name: ctx.engine.name, version: ctx.engine.version });
|
|
80
|
+
// 3. Hash Source Files (Entry points initially, full graph later?
|
|
81
|
+
// SPEC SAYS: "Hash all source files".
|
|
82
|
+
// However, we haven't built the graph yet in the main flow?
|
|
83
|
+
// Actually Stage 2 is "Input Fingerprinting", Stage 3 is "Attach Graph".
|
|
84
|
+
// Usually we need the graph to know *which* files are source files.
|
|
85
|
+
// If the spec implies we fingerprint the *entry* concept or the *entire repo*,
|
|
86
|
+
// let's assume for now we fingerprint the Configuration + Environment + Entry file paths.
|
|
87
|
+
// Real source content hashing usually happens *during* graph build or *after* graph build.
|
|
88
|
+
// BUT the spec says Stage 2 -> Stage 3. This implies we might scan the directory or just fingerprint known inputs.
|
|
89
|
+
// Let's fingerprint the config and entry points for now. The graph content hash comes later.
|
|
90
|
+
// Correction: In a pure build system, "Inputs" are files. If we don't have the graph, we don't know the inputs.
|
|
91
|
+
// Maybe "InputFingerprint" at this stage is just "Configuration & Environment"?
|
|
92
|
+
// Or maybe we treat *all* files in src as inputs?
|
|
93
|
+
// Let's stick to Config + Entry Paths for the 'Input' definition at this precise millisecond.
|
|
94
|
+
// We will update it if we move this stage after graph.
|
|
95
|
+
// Wait, the spec says: "Hash all source files" inside `computeInputFingerprint`.
|
|
96
|
+
// Valid implementation: We might need to walk the tree *now* or defer this until after graph?
|
|
97
|
+
// Spec Order: Init -> Fingerprint -> Attach Graph.
|
|
98
|
+
// This implies we fingerprint based on *what we know*.
|
|
99
|
+
// Let's fingerprint the Entry Files themselves if they exist.
|
|
100
|
+
// 3. Hash Source Files (High-Parallelism Scan)
|
|
101
|
+
const excludes = new Set(['node_modules', '.git', 'dist', 'build_output', 'coverage', '.DS_Store', '.nuclie_cache']);
|
|
102
|
+
if (ctx.config.outputDir)
|
|
103
|
+
excludes.add(path.basename(ctx.config.outputDir));
|
|
104
|
+
const sourceFiles = [];
|
|
105
|
+
const tasks = [];
|
|
106
|
+
async function scan(dir) {
|
|
107
|
+
const entries = await fs.readdir(dir, { withFileTypes: true });
|
|
108
|
+
for (const dirent of entries) {
|
|
109
|
+
if (excludes.has(dirent.name))
|
|
110
|
+
continue;
|
|
111
|
+
const fullPath = path.join(dir, dirent.name);
|
|
112
|
+
if (dirent.isDirectory()) {
|
|
113
|
+
tasks.push(scan(fullPath));
|
|
114
|
+
}
|
|
115
|
+
else if (/\.(ts|tsx|js|jsx|json|css|html|vue|svelte)$/i.test(dirent.name)) {
|
|
116
|
+
tasks.push((async () => {
|
|
117
|
+
const content = await fs.readFile(fullPath);
|
|
118
|
+
sourceFiles.push({ path: path.relative(ctx.rootDir, fullPath), contentHash: canonicalHash(content) });
|
|
119
|
+
})());
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
await scan(ctx.rootDir);
|
|
124
|
+
await Promise.all(tasks);
|
|
125
|
+
sourceFiles.sort((a, b) => a.path.localeCompare(b.path));
|
|
126
|
+
const inputsToHash = {
|
|
127
|
+
config: configHash,
|
|
128
|
+
engine: engineFingerprint,
|
|
129
|
+
sources: sourceFiles
|
|
130
|
+
};
|
|
131
|
+
const inputHash = canonicalHash(inputsToHash);
|
|
132
|
+
explainReporter.report('fingerprint', 'computed', 'Input fingerprint ready', { inputHash });
|
|
133
|
+
return {
|
|
134
|
+
sourceFiles,
|
|
135
|
+
configHash,
|
|
136
|
+
engineFingerprint,
|
|
137
|
+
inputHash
|
|
138
|
+
};
|
|
139
|
+
}
|
|
140
|
+
// Stage 3: Attach Graph
|
|
141
|
+
export function attachGraph(ctx, graph) {
|
|
142
|
+
explainReporter.report('graph', 'attached', 'Dependency graph attached');
|
|
143
|
+
// Compute Graph Hash
|
|
144
|
+
const nodesObj = {};
|
|
145
|
+
for (const [key, val] of graph.nodes.entries()) {
|
|
146
|
+
const deps = val.edges.map(e => e.to).sort();
|
|
147
|
+
nodesObj[key] = {
|
|
148
|
+
id: val.id,
|
|
149
|
+
deps: deps
|
|
150
|
+
};
|
|
151
|
+
}
|
|
152
|
+
const graphHash = canonicalHash(nodesObj);
|
|
153
|
+
return {
|
|
154
|
+
...ctx,
|
|
155
|
+
graph,
|
|
156
|
+
graphHash
|
|
157
|
+
};
|
|
158
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Engine Emission and Fingerprinting Stage
|
|
3
|
+
*
|
|
4
|
+
* @internal - This handles FS writes and build auditing. Not for public use.
|
|
5
|
+
*/
|
|
6
|
+
import { BuildArtifact, BuildContext, BuildFingerprint, InputFingerprint, BuildPlan } from './types.js';
|
|
7
|
+
export declare function emit(artifacts: BuildArtifact[], ctx: BuildContext): Promise<BuildArtifact[]>;
|
|
8
|
+
export declare function computeBuildFingerprint(inputFingerprint: InputFingerprint, artifacts: BuildArtifact[], plan: BuildPlan, ctx: BuildContext): BuildFingerprint;
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Engine Emission and Fingerprinting Stage
|
|
3
|
+
*
|
|
4
|
+
* @internal - This handles FS writes and build auditing. Not for public use.
|
|
5
|
+
*/
|
|
6
|
+
import { explainReporter } from './events.js';
|
|
7
|
+
import { canonicalHash } from './hash.js';
|
|
8
|
+
import fs from 'fs/promises';
|
|
9
|
+
import path from 'path';
|
|
10
|
+
// Stage 8: Emit Artifacts
|
|
11
|
+
export async function emit(artifacts, ctx) {
|
|
12
|
+
explainReporter.report('emit', 'start', 'Starting emit phase');
|
|
13
|
+
await fs.mkdir(ctx.config.outputDir, { recursive: true });
|
|
14
|
+
const emitted = [];
|
|
15
|
+
for (const artifact of artifacts) {
|
|
16
|
+
if (artifact.source === undefined)
|
|
17
|
+
continue;
|
|
18
|
+
const outputPath = path.join(ctx.config.outputDir, artifact.fileName);
|
|
19
|
+
await fs.mkdir(path.dirname(outputPath), { recursive: true });
|
|
20
|
+
explainReporter.report('emit', 'writing', `Writing artifact: ${outputPath}`);
|
|
21
|
+
await fs.writeFile(outputPath, artifact.source);
|
|
22
|
+
// Final sanity check of what was written vs what was in memory?
|
|
23
|
+
// Skipped for performance.
|
|
24
|
+
emitted.push(artifact);
|
|
25
|
+
}
|
|
26
|
+
// Write build-manifest.json (Phase 4.3)
|
|
27
|
+
const manifest = {
|
|
28
|
+
timestamp: new Date().toISOString(),
|
|
29
|
+
target: ctx.target,
|
|
30
|
+
artifacts: emitted.map(a => ({
|
|
31
|
+
fileName: a.fileName,
|
|
32
|
+
hash: a.id,
|
|
33
|
+
type: a.type
|
|
34
|
+
}))
|
|
35
|
+
};
|
|
36
|
+
await fs.writeFile(path.join(ctx.config.outputDir, 'build-manifest.json'), JSON.stringify(manifest, null, 2));
|
|
37
|
+
// Write Explain Log
|
|
38
|
+
const explainLogPath = path.join(ctx.config.outputDir, 'build-explain.json');
|
|
39
|
+
await fs.writeFile(explainLogPath, JSON.stringify(explainReporter.getEvents(), null, 2));
|
|
40
|
+
explainReporter.report('emit', 'complete', `Emitted ${emitted.length} artifacts`);
|
|
41
|
+
return emitted;
|
|
42
|
+
}
|
|
43
|
+
// Stage 9: Output Fingerprinting
|
|
44
|
+
export function computeBuildFingerprint(inputFingerprint, artifacts, plan, ctx) {
|
|
45
|
+
explainReporter.report('audit', 'start', 'Computing build fingerprint');
|
|
46
|
+
// Output Hash = Hash of all artifact IDs (content hashes) in order
|
|
47
|
+
const outputIds = artifacts.map(a => a.id);
|
|
48
|
+
const outputHash = canonicalHash(outputIds);
|
|
49
|
+
const fingerprint = {
|
|
50
|
+
engineVersion: ctx.engine.version,
|
|
51
|
+
graphHash: ctx.graphHash,
|
|
52
|
+
planHash: plan.planId,
|
|
53
|
+
inputHash: inputFingerprint.inputHash,
|
|
54
|
+
outputHash: outputHash,
|
|
55
|
+
target: ctx.target,
|
|
56
|
+
buildTime: new Date().toISOString()
|
|
57
|
+
};
|
|
58
|
+
explainReporter.report('audit', 'complete', 'Build fingerprint computed', { outputHash: fingerprint.outputHash });
|
|
59
|
+
return fingerprint;
|
|
60
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { ExplainEvent } from './types.js';
|
|
2
|
+
declare class ExplainReporter {
|
|
3
|
+
private events;
|
|
4
|
+
record(event: ExplainEvent): void;
|
|
5
|
+
getEvents(): ExplainEvent[];
|
|
6
|
+
clear(): void;
|
|
7
|
+
report(stage: string, decision: string, reason: string, data?: any): void;
|
|
8
|
+
private marks;
|
|
9
|
+
startMark(name: string): void;
|
|
10
|
+
endMark(name: string, stage?: string): void;
|
|
11
|
+
}
|
|
12
|
+
export declare const explainReporter: ExplainReporter;
|
|
13
|
+
export {};
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
class ExplainReporter {
|
|
2
|
+
constructor() {
|
|
3
|
+
this.events = [];
|
|
4
|
+
// Performance profiling
|
|
5
|
+
this.marks = new Map();
|
|
6
|
+
}
|
|
7
|
+
record(event) {
|
|
8
|
+
this.events.push({
|
|
9
|
+
...event,
|
|
10
|
+
timestamp: event.timestamp || Date.now()
|
|
11
|
+
});
|
|
12
|
+
}
|
|
13
|
+
getEvents() {
|
|
14
|
+
return this.events;
|
|
15
|
+
}
|
|
16
|
+
clear() {
|
|
17
|
+
this.events = [];
|
|
18
|
+
}
|
|
19
|
+
// Helper for structured logging
|
|
20
|
+
report(stage, decision, reason, data) {
|
|
21
|
+
this.record({ stage, decision, reason, data, timestamp: Date.now() });
|
|
22
|
+
}
|
|
23
|
+
startMark(name) {
|
|
24
|
+
this.marks.set(name, performance.now());
|
|
25
|
+
}
|
|
26
|
+
endMark(name, stage = 'profile') {
|
|
27
|
+
const start = this.marks.get(name);
|
|
28
|
+
if (start !== undefined) {
|
|
29
|
+
const duration = performance.now() - start;
|
|
30
|
+
this.report(stage, 'performance', `${name} took ${duration.toFixed(2)}ms`, { duration });
|
|
31
|
+
this.marks.delete(name);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
export const explainReporter = new ExplainReporter();
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Engine Execution Stage - Optimized (v2.0.2 World Domination)
|
|
3
|
+
*/
|
|
4
|
+
import { BuildContext, BuildPlan, BuildArtifact, ExecutionPlan } from './types.js';
|
|
5
|
+
export declare function executeParallel(execPlan: ExecutionPlan, buildPlan: BuildPlan, ctx: BuildContext): Promise<BuildArtifact[]>;
|
|
@@ -0,0 +1,226 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Engine Execution Stage - Optimized (v2.0.2 World Domination)
|
|
3
|
+
*/
|
|
4
|
+
import { explainReporter } from './events.js';
|
|
5
|
+
import { canonicalHash } from './hash.js';
|
|
6
|
+
import fs from 'fs/promises';
|
|
7
|
+
import path from 'path';
|
|
8
|
+
import { generateModuleId, normalizePath } from '../../resolve/utils.js';
|
|
9
|
+
import { Transformer } from '../transform/transformer.js';
|
|
10
|
+
import { GlobalOptimizer } from '../build/globalOptimizer.js';
|
|
11
|
+
import { ShortIdMap } from '../graph/serializer.js';
|
|
12
|
+
export async function executeParallel(execPlan, buildPlan, ctx) {
|
|
13
|
+
explainReporter.report('execute', 'start', 'Starting optimized execution');
|
|
14
|
+
const artifacts = [];
|
|
15
|
+
const artifactMap = new Map();
|
|
16
|
+
const isProd = ctx.mode === 'production' || ctx.mode === 'build';
|
|
17
|
+
// Phase 2: Short Stable IDs (Persist across chunks for consistency)
|
|
18
|
+
const shortIdMap = new ShortIdMap();
|
|
19
|
+
const globalOptimizer = new GlobalOptimizer();
|
|
20
|
+
for (const group of execPlan.parallelGroups) {
|
|
21
|
+
const tasks = group.map(async (chunkId) => {
|
|
22
|
+
const chunk = buildPlan.chunks.find(c => c.id === chunkId);
|
|
23
|
+
if (!chunk)
|
|
24
|
+
return;
|
|
25
|
+
const pipelineHash = ctx.pluginManager.getPipelineHash();
|
|
26
|
+
const moduleHashes = {};
|
|
27
|
+
for (const modId of chunk.modules) {
|
|
28
|
+
const node = ctx.graph.nodes.get(modId);
|
|
29
|
+
if (node)
|
|
30
|
+
moduleHashes[modId] = node.contentHash;
|
|
31
|
+
}
|
|
32
|
+
const chunkKey = canonicalHash({
|
|
33
|
+
id: chunk.id,
|
|
34
|
+
moduleHashes,
|
|
35
|
+
configHash: canonicalHash(ctx.config),
|
|
36
|
+
pipelineHash,
|
|
37
|
+
mode: ctx.mode
|
|
38
|
+
});
|
|
39
|
+
// CACHE CHECK
|
|
40
|
+
const cached = await ctx.cache.get(chunkKey);
|
|
41
|
+
if (cached) {
|
|
42
|
+
artifactMap.set(chunk.id, cached.artifact);
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
45
|
+
let bundleContent = '';
|
|
46
|
+
const isCss = chunk.id.endsWith('_css');
|
|
47
|
+
// Phase 1: ULTRA-CONDENSED RUNTIME
|
|
48
|
+
if (!isCss) {
|
|
49
|
+
bundleContent += isProd
|
|
50
|
+
? `(function(g){const m={};g.d=(i,f)=>m[i]=f;g.r=i=>{if(m[i].z)return m[i].z;const o={e:{}};m[i](o,o.e,g.r);return m[i].z=o.e}})(globalThis);\n`
|
|
51
|
+
: `/* Nuclie Runtime */\n(function(g){const m={};g.d=(i,f)=>m[i]=f;g.r=i=>{if(m[i].z)return m[i].z;const o={e:{}};m[i](o,o.e,g.r);return m[i].z=o.e}})(globalThis);\n`;
|
|
52
|
+
}
|
|
53
|
+
const artifactModules = [];
|
|
54
|
+
const transformer = new Transformer();
|
|
55
|
+
const moduleResults = new Map();
|
|
56
|
+
const pendingTransform = [];
|
|
57
|
+
// Parallel Load (Respecting Plugins)
|
|
58
|
+
await Promise.all(chunk.modules.map(async (modId) => {
|
|
59
|
+
const node = ctx.graph.nodes.get(modId);
|
|
60
|
+
const path = node?.path || modId;
|
|
61
|
+
// Try Plugin LOAD hook first (for assets, etc.)
|
|
62
|
+
const loadResult = await ctx.pluginManager.runHook('load', { id: modId, path }, ctx);
|
|
63
|
+
let content;
|
|
64
|
+
if (loadResult && loadResult.code !== undefined) {
|
|
65
|
+
content = loadResult.code;
|
|
66
|
+
}
|
|
67
|
+
else {
|
|
68
|
+
content = await fs.readFile(path, 'utf-8');
|
|
69
|
+
}
|
|
70
|
+
pendingTransform.push({ id: modId, path, content });
|
|
71
|
+
}));
|
|
72
|
+
// Phase 3: NATIVE BATCH (SWC Fix applied in transform.rs)
|
|
73
|
+
if (pendingTransform.length > 0) {
|
|
74
|
+
const batchResults = await transformer.batchTransform(pendingTransform, ctx);
|
|
75
|
+
for (const res of batchResults) {
|
|
76
|
+
const p = pendingTransform.find(x => x.id === res.id);
|
|
77
|
+
moduleResults.set(res.id, { code: res.code, originalSize: Buffer.byteLength(p.content) });
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
// Phase 3.5: TREE SHAKING (Production Only - Before Bundling)
|
|
81
|
+
if (isProd && moduleResults.size > 0) {
|
|
82
|
+
const { AutoFixEngine } = await import('../../fix/ast-transforms.js');
|
|
83
|
+
const autoFix = new AutoFixEngine();
|
|
84
|
+
// Collect modules with REAL paths from dependency graph
|
|
85
|
+
const modulesForShaking = new Map();
|
|
86
|
+
const idToPath = new Map();
|
|
87
|
+
for (const [modId, result] of moduleResults) {
|
|
88
|
+
// Get actual file path from graph
|
|
89
|
+
const node = ctx.graph.nodes.get(modId);
|
|
90
|
+
if (node && node.path) {
|
|
91
|
+
modulesForShaking.set(node.path, result.code);
|
|
92
|
+
idToPath.set(modId, node.path);
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
if (modulesForShaking.size > 0) {
|
|
96
|
+
// Perform tree shaking with real paths
|
|
97
|
+
const shakenResults = autoFix.treeShake(modulesForShaking);
|
|
98
|
+
// Apply shaken code back to moduleResults using ID mapping
|
|
99
|
+
for (const [modId, result] of moduleResults) {
|
|
100
|
+
const realPath = idToPath.get(modId);
|
|
101
|
+
if (realPath) {
|
|
102
|
+
const shakenResult = shakenResults.get(realPath);
|
|
103
|
+
if (shakenResult?.success && shakenResult.code) {
|
|
104
|
+
const savings = result.code.length - shakenResult.code.length;
|
|
105
|
+
if (savings > 0) {
|
|
106
|
+
moduleResults.set(modId, {
|
|
107
|
+
code: shakenResult.code,
|
|
108
|
+
originalSize: result.originalSize
|
|
109
|
+
});
|
|
110
|
+
explainReporter.report('execute', 'tree-shake', `${realPath}: Removed ${shakenResult.changes.length} unused exports, saved ${savings} bytes`);
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
// Phase 2: Assemble with Short IDs
|
|
118
|
+
for (const modId of chunk.modules) {
|
|
119
|
+
const res = moduleResults.get(modId);
|
|
120
|
+
if (!res)
|
|
121
|
+
continue;
|
|
122
|
+
const shortId = shortIdMap.get(modId, isProd);
|
|
123
|
+
artifactModules.push({ id: modId, shortId, size: res.code.length, originalSize: res.originalSize });
|
|
124
|
+
if (isCss) {
|
|
125
|
+
bundleContent += `\n/* ${modId} */\n${res.code}`;
|
|
126
|
+
}
|
|
127
|
+
else {
|
|
128
|
+
// Convert any remaining ESM import statements to require calls
|
|
129
|
+
// This handles external libraries that may have hash-based imports
|
|
130
|
+
let moduleCode = res.code;
|
|
131
|
+
// Pattern: import React, { Suspense } from "hash16chars"
|
|
132
|
+
moduleCode = moduleCode.replace(/\bimport\s+(\w+)\s*,\s*\{([^}]+)\}\s+from\s+["']([a-f0-9]{16})["'];?/g, (match, defaultImport, namedImports, hash) => {
|
|
133
|
+
return `const ${defaultImport} = require("${hash}"); const {${namedImports}} = require("${hash}");`;
|
|
134
|
+
});
|
|
135
|
+
// Pattern: import { x, y } from "hash16chars"
|
|
136
|
+
moduleCode = moduleCode.replace(/\bimport\s+\{([^}]+)\}\s+from\s+["']([a-f0-9]{16})["'];?/g, 'const {$1} = require("$2");');
|
|
137
|
+
// Pattern: import x from "hash16chars"
|
|
138
|
+
moduleCode = moduleCode.replace(/\bimport\s+(\w+)\s+from\s+["']([a-f0-9]{16})["'];?/g, 'const $1 = require("$2");');
|
|
139
|
+
// Pattern: import * as x from "hash16chars"
|
|
140
|
+
moduleCode = moduleCode.replace(/\bimport\s+\*\s+as\s+(\w+)\s+from\s+["']([a-f0-9]{16})["'];?/g, 'const $1 = require("$2");');
|
|
141
|
+
// Pattern: import "hash16chars"
|
|
142
|
+
moduleCode = moduleCode.replace(/\bimport\s+["']([a-f0-9]{16})["'];?/g, 'require("$1");');
|
|
143
|
+
// Always use 'globalThis.d' as defined in condensed runtime
|
|
144
|
+
bundleContent += `\nglobalThis.d("${shortId}",function(module,exports,require,h){\n${moduleCode}\n});`;
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
// Entry Execution
|
|
148
|
+
if (!isCss && chunk.entry) {
|
|
149
|
+
const absEntry = path.isAbsolute(chunk.entry)
|
|
150
|
+
? chunk.entry
|
|
151
|
+
: path.resolve(ctx.rootDir, chunk.entry);
|
|
152
|
+
const entryId = generateModuleId('file', normalizePath(absEntry), ctx.rootDir);
|
|
153
|
+
const shortEntryId = shortIdMap.get(entryId, isProd);
|
|
154
|
+
bundleContent += `\n\nglobalThis.r("${shortEntryId}");`;
|
|
155
|
+
}
|
|
156
|
+
const artifact = {
|
|
157
|
+
id: canonicalHash(bundleContent).substring(0, 16),
|
|
158
|
+
type: isCss ? 'css' : 'js',
|
|
159
|
+
fileName: chunk.outputName,
|
|
160
|
+
dependencies: [...chunk.modules],
|
|
161
|
+
source: bundleContent,
|
|
162
|
+
modules: artifactModules
|
|
163
|
+
};
|
|
164
|
+
// Generate source map if enabled
|
|
165
|
+
if (!isCss && ctx.config.sourceMaps) {
|
|
166
|
+
const sourceMapContent = {
|
|
167
|
+
version: 3,
|
|
168
|
+
sources: chunk.modules.map(modId => {
|
|
169
|
+
const node = ctx.graph.nodes.get(modId);
|
|
170
|
+
return node?.path || modId;
|
|
171
|
+
}),
|
|
172
|
+
names: [],
|
|
173
|
+
mappings: '', // Basic mapping - can be enhanced later
|
|
174
|
+
file: chunk.outputName
|
|
175
|
+
};
|
|
176
|
+
const sourceMapJson = JSON.stringify(sourceMapContent);
|
|
177
|
+
if (ctx.config.sourceMaps === 'inline') {
|
|
178
|
+
// Inline source map
|
|
179
|
+
artifact.source += `\n//# sourceMappingURL=data:application/json;base64,${Buffer.from(sourceMapJson).toString('base64')}`;
|
|
180
|
+
}
|
|
181
|
+
else if (ctx.config.sourceMaps === 'external' || ctx.config.sourceMaps === true) {
|
|
182
|
+
// External source map file
|
|
183
|
+
const mapFileName = chunk.outputName + '.map';
|
|
184
|
+
artifact.source += `\n//# sourceMappingURL=${mapFileName}`;
|
|
185
|
+
// Create separate map artifact
|
|
186
|
+
const mapArtifact = {
|
|
187
|
+
id: canonicalHash(sourceMapJson).substring(0, 16),
|
|
188
|
+
type: 'map',
|
|
189
|
+
fileName: mapFileName,
|
|
190
|
+
dependencies: [],
|
|
191
|
+
source: sourceMapJson
|
|
192
|
+
};
|
|
193
|
+
artifactMap.set(chunk.id + '_map', mapArtifact);
|
|
194
|
+
}
|
|
195
|
+
// 'hidden' mode: generate map but don't add reference
|
|
196
|
+
}
|
|
197
|
+
ctx.cache.set(chunkKey, { hash: chunkKey, artifact });
|
|
198
|
+
artifactMap.set(chunk.id, artifact);
|
|
199
|
+
});
|
|
200
|
+
await Promise.all(tasks);
|
|
201
|
+
}
|
|
202
|
+
// Process Final Order
|
|
203
|
+
for (const id of buildPlan.executionOrder) {
|
|
204
|
+
const art = artifactMap.get(id);
|
|
205
|
+
if (art)
|
|
206
|
+
artifacts.push(art);
|
|
207
|
+
}
|
|
208
|
+
// Phase 1: GLOBAL NATIVE MINIFICATION
|
|
209
|
+
if (isProd) {
|
|
210
|
+
await globalOptimizer.optimize(artifacts);
|
|
211
|
+
}
|
|
212
|
+
// Assets
|
|
213
|
+
for (const asset of buildPlan.assets) {
|
|
214
|
+
const node = ctx.graph.nodes.get(asset.id);
|
|
215
|
+
if (node) {
|
|
216
|
+
artifacts.push({
|
|
217
|
+
id: node.contentHash,
|
|
218
|
+
type: 'asset',
|
|
219
|
+
fileName: asset.outputName,
|
|
220
|
+
dependencies: [],
|
|
221
|
+
source: await fs.readFile(node.path)
|
|
222
|
+
});
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
return artifacts;
|
|
226
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { fastHash } from '../../native/index.js';
|
|
2
|
+
/**
|
|
3
|
+
* Single Source of Truth for Hashing
|
|
4
|
+
*
|
|
5
|
+
* Guarantees:
|
|
6
|
+
* - Deterministic output via canonical stringify
|
|
7
|
+
* - Ultra-fast hashing via Native XXH3 (Phase 4.2)
|
|
8
|
+
*/
|
|
9
|
+
export function canonicalHash(value) {
|
|
10
|
+
const canonicalString = stableStringify(value);
|
|
11
|
+
return fastHash(canonicalString);
|
|
12
|
+
}
|
|
13
|
+
function stableStringify(value) {
|
|
14
|
+
if (value === null || value === undefined) {
|
|
15
|
+
return String(value);
|
|
16
|
+
}
|
|
17
|
+
if (typeof value === 'number' || typeof value === 'boolean') {
|
|
18
|
+
return String(value);
|
|
19
|
+
}
|
|
20
|
+
if (typeof value === 'string') {
|
|
21
|
+
return JSON.stringify(value);
|
|
22
|
+
}
|
|
23
|
+
if (Array.isArray(value)) {
|
|
24
|
+
return '[' + value.map(stableStringify).join(',') + ']';
|
|
25
|
+
}
|
|
26
|
+
if (typeof value === 'object') {
|
|
27
|
+
const keys = Object.keys(value).sort();
|
|
28
|
+
const parts = keys.map(k => {
|
|
29
|
+
const v = value[k];
|
|
30
|
+
// Skip undefined values to match JSON behavior or keep them unique?
|
|
31
|
+
// Usually explicit is better for hashing, but let's stick to standard strictness.
|
|
32
|
+
if (v === undefined)
|
|
33
|
+
return '';
|
|
34
|
+
return `${JSON.stringify(k)}:${stableStringify(v)}`;
|
|
35
|
+
}).filter(x => x !== '');
|
|
36
|
+
return '{' + parts.join(',') + '}';
|
|
37
|
+
}
|
|
38
|
+
return String(value);
|
|
39
|
+
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { DependencyGraph } from '../../resolve/graph.js';
|
|
2
|
+
import { BuildConfig } from '../../config/index.js';
|
|
3
|
+
import { BuildMode } from './types.js';
|
|
4
|
+
/**
|
|
5
|
+
* Core Build Engine
|
|
6
|
+
*
|
|
7
|
+
* PUBLIC: The main orchestrator for the Nuclie build pipeline.
|
|
8
|
+
* Use this class to run builds programmatically.
|
|
9
|
+
*
|
|
10
|
+
* @public
|
|
11
|
+
*/
|
|
12
|
+
export declare class CoreBuildEngine {
|
|
13
|
+
/** @internal */
|
|
14
|
+
private latestGraph;
|
|
15
|
+
/** @internal */
|
|
16
|
+
private ctx;
|
|
17
|
+
/** @public */
|
|
18
|
+
getGraph(): DependencyGraph | null;
|
|
19
|
+
/**
|
|
20
|
+
* Incremental Invalidation (Phase 10)
|
|
21
|
+
*/
|
|
22
|
+
invalidateFile(filePath: string): Promise<void>;
|
|
23
|
+
/**
|
|
24
|
+
* Shutdown and cleanup resources
|
|
25
|
+
*/
|
|
26
|
+
close(): Promise<void>;
|
|
27
|
+
/**
|
|
28
|
+
* Main Entry Point for the Build Engine (Pipeline Orchestrator)
|
|
29
|
+
*/
|
|
30
|
+
run(userConfig: BuildConfig, mode: BuildMode | undefined, rootDir: string, changedFiles?: string[]): Promise<{
|
|
31
|
+
success: boolean;
|
|
32
|
+
fingerprint: import("./types.js").BuildFingerprint;
|
|
33
|
+
artifacts: import("./types.js").BuildArtifact[];
|
|
34
|
+
events: import("./types.js").ExplainEvent[];
|
|
35
|
+
pluginMetrics: any;
|
|
36
|
+
error?: undefined;
|
|
37
|
+
} | {
|
|
38
|
+
success: boolean;
|
|
39
|
+
error: {
|
|
40
|
+
message: any;
|
|
41
|
+
code: any;
|
|
42
|
+
stage: any;
|
|
43
|
+
};
|
|
44
|
+
events: import("./types.js").ExplainEvent[];
|
|
45
|
+
fingerprint?: undefined;
|
|
46
|
+
artifacts?: undefined;
|
|
47
|
+
pluginMetrics?: undefined;
|
|
48
|
+
}>;
|
|
49
|
+
}
|