octane 0.1.12 → 0.1.13

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.
@@ -14,17 +14,14 @@ import * as nodeFs from 'node:fs';
14
14
  import * as nodeModule from 'node:module';
15
15
  import * as nodePath from 'node:path';
16
16
  import { parseModule } from '@tsrx/core';
17
- import { compile, hasOnlyLowerableNullishExits, isVoidJsxCodeBlockFunction } from './compile.js';
18
17
  import {
19
- addSourceMapNeedles,
20
- composeSourceMaps,
21
- validateRendererModuleSource,
22
- } from './compile-universal.js';
23
- import {
24
- hydrateBoundaryPathFromId,
25
- prepareHydrateBoundaries,
26
- prepareServerHydrateBoundaries,
27
- } from './hydrate-boundaries.js';
18
+ compile,
19
+ compileForBundler,
20
+ hasOnlyLowerableNullishExits,
21
+ isVoidJsxCodeBlockFunction,
22
+ } from './compile.js';
23
+ import { validateRendererModuleSource } from './compile-universal.js';
24
+ import { HYDRATE_QUERY_PARAM, hydrateBoundaryPathFromId } from './hydrate-boundaries.js';
28
25
  import {
29
26
  DOM_RENDERER_MODULE,
30
27
  normalizeRendererConfig,
@@ -32,10 +29,7 @@ import {
32
29
  } from './renderers.js';
33
30
  import { findLeadingJsxImportSourcePragma } from './pragma.js';
34
31
  import { normalizeUniversalRuntime } from './universal-runtime.js';
35
- import {
36
- analyzeNativeChangeDiagnostics,
37
- formatCompileDiagnostic,
38
- } from './native-change-diagnostics.js';
32
+ import { formatCompileDiagnostic } from './native-change-diagnostics.js';
39
33
  import { findVoidComponentImports, findVoidRootImports, slotHooks } from './slot-hooks.js';
40
34
  import {
41
35
  assertNoLiveClientOnlyImports,
@@ -883,36 +877,11 @@ class OctaneBundlerCompiler {
883
877
  };
884
878
  }
885
879
  const hasRendererBoundaries = Object.keys(this.renderers.boundaries).length > 0;
886
- const nativeChangeAnalysis = analyzeNativeChangeDiagnostics(
887
- parseModule(code, filename),
888
- code,
889
- filename,
890
- {
891
- dom: renderer.target === 'dom',
892
- renderer,
893
- rendererBoundaries: this.renderers.boundaries,
894
- rendererRegistry: this.renderers.registry,
895
- },
896
- );
897
- const nativeChangeDiagnostics = nativeChangeAnalysis.diagnostics;
898
- const hydratePreparation =
899
- environment === 'client'
900
- ? prepareHydrateBoundaries(code, filename, hydrateBoundaryPath)
901
- : prepareServerHydrateBoundaries(code, filename);
902
- const compileSource = hydratePreparation?.source ?? code;
903
- const out = compile(compileSource, filename, {
904
- __hydratePrepared: true,
905
- __hydrateBoundaryModule: typeof hydratePreparation?.boundaryPath === 'string',
906
- __nativeChangeDiagnostics: nativeChangeDiagnostics,
907
- ...(hydratePreparation === null && !hasRendererBoundaries
908
- ? { __nativeChangeAnalysis: nativeChangeAnalysis }
909
- : null),
910
- // Scoped-style hashes are position-derived; after the extraction
911
- // rewrite the compiler restamps them from these authored
912
- // coordinates so client and server compiles agree (compile.js).
913
- ...(hydratePreparation?.origins != null
914
- ? { __styleRemap: { authored: code, origins: hydratePreparation.origins } }
915
- : null),
880
+ const compileFilename =
881
+ hydrateBoundaryPath === null
882
+ ? filename
883
+ : `${filename}?${HYDRATE_QUERY_PARAM}=${encodeURIComponent(hydrateBoundaryPath)}`;
884
+ const compileOptions = {
916
885
  hmr,
917
886
  mode: environment,
918
887
  dev,
@@ -933,10 +902,17 @@ class OctaneBundlerCompiler {
933
902
  ...(environment === 'client' && typeof options.isVoidComponentImport === 'function'
934
903
  ? { isVoidComponentImport: options.isVoidComponentImport }
935
904
  : null),
936
- });
937
- if (hydratePreparation?.map && out.map) {
938
- out.map = composeSourceMaps(out.map, hydratePreparation.map);
939
- out.map = addSourceMapNeedles(out.map, out.code, code, hydratePreparation.mappingNeedles);
905
+ };
906
+ const collectVoidComponentExports =
907
+ environment === 'client' && options.collectVoidComponentExports === true;
908
+ let out;
909
+ let voidComponentSource = null;
910
+ if (collectVoidComponentExports) {
911
+ const compilation = compileForBundler(code, compileFilename, compileOptions);
912
+ out = compilation.result;
913
+ voidComponentSource = compilation.hydrateSource;
914
+ } else {
915
+ out = compile(code, compileFilename, compileOptions);
940
916
  }
941
917
  this._forwardCompileDiagnostics(out.diagnostics);
942
918
  return {
@@ -947,9 +923,11 @@ class OctaneBundlerCompiler {
947
923
  renderer,
948
924
  ...(out.universalRuntime === undefined ? null : { universalRuntime: out.universalRuntime }),
949
925
  ...(clientReference === null ? null : { clientReference }),
950
- ...(environment === 'client' && options.collectVoidComponentExports === true
951
- ? { voidComponentExports: findVoidComponentExports(compileSource, filename) }
952
- : {}),
926
+ ...(voidComponentSource === null
927
+ ? null
928
+ : {
929
+ voidComponentExports: findVoidComponentExports(voidComponentSource, filename),
930
+ }),
953
931
  ...finishMetadata(collected),
954
932
  };
955
933
  }