Skip to content

Commit

Permalink
fix(optimizer): hooks refactor stragglers (QwikDev#6769)
Browse files Browse the repository at this point in the history
  • Loading branch information
wmertens authored Aug 5, 2024
1 parent 8091284 commit 410e84e
Show file tree
Hide file tree
Showing 8 changed files with 11 additions and 9 deletions.
2 changes: 1 addition & 1 deletion packages/docs/src/repl/repl-options.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ const StoreOption = (props: StoreOptionProps) => {
export const BUILD_MODE_OPTIONS = ['development', 'production'];

// We don't support `inline` and `hoist` for client bundles
export const ENTRY_STRATEGY_OPTIONS = ['component', 'hook', 'single', 'smart'];
export const ENTRY_STRATEGY_OPTIONS = ['component', 'segment', 'single', 'smart'];

interface StoreOptionProps {
label: string;
Expand Down
6 changes: 3 additions & 3 deletions packages/docs/src/repl/repl-output-symbols.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,19 +28,19 @@ export const ReplOutputSymbols = component$(({ outputs }: ReplOutputSymbolsProps
class={{ 'in-view': selectedPath.value === o.path }}
preventdefault:click
>
{o.hook?.canonicalFilename}
{o.segment?.canonicalFilename}
</a>
</div>
))}
</div>
</div>
<div class="file-modules" id={FILE_MODULE_DIV_ID}>
{outputs
.filter((o) => !!o.hook)
.filter((o) => !!o.segment)
.map((o, i) => (
<div class="file-item" data-symbol-item={i} key={o.path}>
<div class="file-info">
<span>{o.hook?.canonicalFilename}</span>
<span>{o.segment?.canonicalFilename}</span>
</div>
<div class="file-text">
<CodeBlock
Expand Down
2 changes: 1 addition & 1 deletion packages/docs/src/repl/repl-share-url.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { deflateSync, inflateSync, strFromU8, strToU8 } from 'fflate';
const dataDefaults: PlaygroundShareUrl = {
version: '',
buildMode: 'development',
entryStrategy: 'hook',
entryStrategy: 'segment',
files: [],
};
export const parsePlaygroundShareUrl = (shareable: string) => {
Expand Down
2 changes: 1 addition & 1 deletion packages/docs/src/repl/repl-share-url.unit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { strFromU8 } from 'fflate';
const data = {
version: '1.2.3',
buildMode: 'development',
entryStrategy: 'hook',
entryStrategy: 'segment',
files: [
{
path: 'foo.js',
Expand Down
2 changes: 1 addition & 1 deletion packages/docs/src/routes/examples/[...id]/index!.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export default component$(() => {
appId: app ? app.id : '',
buildId: 0,
buildMode: 'development',
entryStrategy: 'hook',
entryStrategy: 'segment',
files: app?.inputs || [],
version: '',
shareUrlTmr: undefined,
Expand Down
2 changes: 1 addition & 1 deletion packages/docs/src/routes/playground/index!.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export default component$(() => {
files: playgroundApp.inputs,
version: '',
buildMode: 'development',
entryStrategy: 'hook',
entryStrategy: 'segment',
colResizeActive: false,
colLeft: 50,
shareUrlTmr: null,
Expand Down
2 changes: 1 addition & 1 deletion packages/docs/src/routes/tutorial/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export default component$(() => {
next: t.next,
buildId: 0,
buildMode: 'development',
entryStrategy: 'hook',
entryStrategy: 'segment',
files: ensureDefaultFiles(t.app.problemInputs),
version: '',
};
Expand Down
2 changes: 2 additions & 0 deletions packages/qwik/src/optimizer/core/src/entry_strategy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ pub enum EntryStrategy {
Inline,
Hoist,
Single,
Hook,
Segment,
Component,
Smart,
Expand Down Expand Up @@ -180,6 +181,7 @@ pub fn parse_entry_strategy(
) -> Box<dyn EntryPolicy> {
match strategy {
EntryStrategy::Inline | EntryStrategy::Hoist => Box::<InlineStrategy>::default(),
EntryStrategy::Hook => Box::new(PerSegmentStrategy::new(manual_chunks)),
EntryStrategy::Segment => Box::new(PerSegmentStrategy::new(manual_chunks)),
EntryStrategy::Single => Box::new(SingleStrategy::new(manual_chunks)),
EntryStrategy::Component => Box::new(PerComponentStrategy::new(manual_chunks)),
Expand Down

0 comments on commit 410e84e

Please sign in to comment.