Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

breaking(minimal): handleBuild API for build #1093

Merged
merged 20 commits into from
Dec 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions e2e/fixtures/define-router/src/entries.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,8 @@ const entries: ReturnType<typeof defineEntries> = defineEntries({
}
return router.handleRequest(input, utils);
},
getBuildConfig: (utils) => {
return router.getBuildConfig(utils);
handleBuild: (utils) => {
return router.handleBuild(utils);
},
});

Expand Down
2 changes: 1 addition & 1 deletion e2e/fixtures/rsc-basic/src/entries.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const entries: ReturnType<typeof defineEntries> = defineEntries({
return renderRsc({ _value: value });
}
},
getBuildConfig: async () => [{ pathSpec: [], entries: [{ rscPath: '' }] }],
handleBuild: () => null,
});

export default entries;
2 changes: 1 addition & 1 deletion e2e/fixtures/rsc-css-modules/src/entries.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const entries: ReturnType<typeof defineEntries> = defineEntries({
return renderRsc({ _value: value });
}
},
getBuildConfig: async () => [{ pathSpec: [], entries: [{ rscPath: '' }] }],
handleBuild: () => null,
});

export default entries;
12 changes: 11 additions & 1 deletion e2e/fixtures/ssr-basic/src/entries.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { unstable_defineEntries as defineEntries } from 'waku/minimal/server';
import { Slot } from 'waku/minimal/client';
import { unstable_createAsyncIterable as createAsyncIterable } from 'waku/server';

import App from './components/App.js';

Expand All @@ -18,7 +19,16 @@ const entries: ReturnType<typeof defineEntries> = defineEntries({
});
}
},
getBuildConfig: async () => [{ pathSpec: [], entries: [{ rscPath: '' }] }],
handleBuild: () =>
createAsyncIterable(async () => {
const tasks = [
async () => ({
type: 'htmlHead' as const,
pathSpec: [],
}),
];
return tasks;
}),
});

export default entries;
12 changes: 11 additions & 1 deletion e2e/fixtures/ssr-context-provider/src/entries.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { unstable_defineEntries as defineEntries } from 'waku/minimal/server';
import { Slot } from 'waku/minimal/client';
import { unstable_createAsyncIterable as createAsyncIterable } from 'waku/server';

import App from './components/app.js';

Expand All @@ -16,7 +17,16 @@ const entries: ReturnType<typeof defineEntries> = defineEntries({
return renderHtml({ App: <App /> }, <Slot id="App" />, { rscPath: '' });
}
},
getBuildConfig: async () => [{ pathSpec: [], entries: [{ rscPath: '' }] }],
handleBuild: () =>
createAsyncIterable(async () => {
const tasks = [
async () => ({
type: 'htmlHead' as const,
pathSpec: [],
}),
];
return tasks;
}),
});

export default entries;
12 changes: 11 additions & 1 deletion e2e/fixtures/ssr-swr/src/entries.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { unstable_defineEntries as defineEntries } from 'waku/minimal/server';
import { Slot } from 'waku/minimal/client';
import { unstable_createAsyncIterable as createAsyncIterable } from 'waku/server';

import App from './components/App.js';

Expand All @@ -18,7 +19,16 @@ const entries: ReturnType<typeof defineEntries> = defineEntries({
});
}
},
getBuildConfig: async () => [{ pathSpec: [], entries: [{ rscPath: '' }] }],
handleBuild: () =>
createAsyncIterable(async () => {
const tasks = [
async () => ({
type: 'htmlHead' as const,
pathSpec: [],
}),
];
return tasks;
}),
});

export default entries;
12 changes: 11 additions & 1 deletion e2e/fixtures/ssr-target-bundle/src/entries.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { unstable_defineEntries as defineEntries } from 'waku/minimal/server';
import { Slot } from 'waku/minimal/client';
import { unstable_createAsyncIterable as createAsyncIterable } from 'waku/server';

import App from './components/App.js';

Expand All @@ -18,7 +19,16 @@ const entries: ReturnType<typeof defineEntries> = defineEntries({
});
}
},
getBuildConfig: async () => [{ pathSpec: [], entries: [{ rscPath: '' }] }],
handleBuild: () =>
createAsyncIterable(async () => {
const tasks = [
async () => ({
type: 'htmlHead' as const,
pathSpec: [],
}),
];
return tasks;
}),
});

export default entries;
4 changes: 2 additions & 2 deletions examples/12_nossr/src/entries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export default defineEntries({
}
return router.handleRequest(input, utils);
},
getBuildConfig: (utils) => {
return router.getBuildConfig(utils);
handleBuild: (utils) => {
return router.handleBuild(utils);
},
});
40 changes: 39 additions & 1 deletion examples/31_minimal/src/entries.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { unstable_defineEntries as defineEntries } from 'waku/minimal/server';
import { Slot } from 'waku/minimal/client';
import { unstable_createAsyncIterable as createAsyncIterable } from 'waku/server';

import App from './components/App';

Expand All @@ -14,5 +15,42 @@ export default defineEntries({
});
}
},
getBuildConfig: async () => [{ pathSpec: [], entries: [{ rscPath: '' }] }],
handleBuild: ({
// renderRsc,
// renderHtml,
// rscPath2pathname,
unstable_generatePrefetchCode,
}) =>
createAsyncIterable(async () => {
const moduleIds = new Set<string>();
const generateHtmlHead = () =>
`<script type="module" async>${unstable_generatePrefetchCode(
[''],
moduleIds,
)}</script>`;
const tasks = [
async () => ({
type: 'htmlHead' as const,
pathSpec: [],
head: generateHtmlHead(),
}),
// async () => ({
// type: 'file' as const,
// pathname: rscPath2pathname(''),
// body: renderRsc(
// { App: <App name="Waku" /> },
// { moduleIdCallback: (id) => moduleIds.add(id) },
// ),
// }),
// async () => ({
// type: 'file' as const,
// pathname: '/',
// body: renderHtml({ App: <App name="Waku" /> }, <Slot id="App" />, {
// rscPath: '',
// htmlHead: generateHtmlHead(),
// }).then(({ body }) => body),
// }),
];
return tasks;
}),
});
40 changes: 39 additions & 1 deletion examples/32_minimal_js/src/entries.jsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { unstable_defineEntries as defineEntries } from 'waku/minimal/server';
import { Slot } from 'waku/minimal/client';
import { unstable_createAsyncIterable as createAsyncIterable } from 'waku/server';

import App from './components/app';

Expand All @@ -14,5 +15,42 @@ export default defineEntries({
});
}
},
getBuildConfig: async () => [{ pathSpec: [], entries: [{ rscPath: '' }] }],
handleBuild: ({
// renderRsc,
// renderHtml,
// rscPath2pathname,
unstable_generatePrefetchCode,
}) =>
createAsyncIterable(async () => {
const moduleIds = new Set();
const generateHtmlHead = () =>
`<script type="module" async>${unstable_generatePrefetchCode(
[''],
moduleIds,
)}</script>`;
const tasks = [
async () => ({
type: 'htmlHead',
pathSpec: [],
head: generateHtmlHead(),
}),
// async () => ({
// type: 'file',
// pathname: rscPath2pathname(''),
// body: await renderRsc(
// { App: <App name="Waku" /> },
// { moduleIdCallback: (id) => moduleIds.add(id) },
// ),
// }),
// async () => ({
// type: 'file',
// pathname: '/',
// body: renderHtml({ App: <App name="Waku" /> }, <Slot id="App" />, {
// rscPath: '',
// htmlHead: generateHtmlHead(),
// }).then(({ body }) => body),
// }),
];
return tasks;
}),
});
40 changes: 39 additions & 1 deletion examples/33_promise/src/entries.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { unstable_defineEntries as defineEntries } from 'waku/minimal/server';
import { Children, Slot } from 'waku/minimal/client';
import { unstable_createAsyncIterable as createAsyncIterable } from 'waku/server';

import App from './components/App';

Expand Down Expand Up @@ -30,5 +31,42 @@ export default defineEntries({
);
}
},
getBuildConfig: async () => [{ pathSpec: [], entries: [{ rscPath: '' }] }],
handleBuild: ({
// renderRsc,
// renderHtml,
// rscPath2pathname,
unstable_generatePrefetchCode,
}) =>
createAsyncIterable(async () => {
const moduleIds = new Set<string>();
const generateHtmlHead = () =>
`<script type="module" async>${unstable_generatePrefetchCode(
[''],
moduleIds,
)}</script>`;
const tasks = [
async () => ({
type: 'htmlHead' as const,
pathSpec: [],
head: generateHtmlHead(),
}),
// async () => ({
// type: 'file' as const,
// pathname: rscPath2pathname(''),
// body: await renderRsc(
// { App: <App name="Waku" /> },
// { moduleIdCallback: (id) => moduleIds.add(id) },
// ),
// }),
// async () => ({
// type: 'file' as const,
// pathname: '/',
// body: renderHtml({ App: <App name="Waku" /> }, <Slot id="App" />, {
// rscPath: '',
// htmlHead: generateHtmlHead(),
// }).then(({ body }) => body),
// }),
];
return tasks;
}),
});
40 changes: 39 additions & 1 deletion examples/34_functions/src/entries.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { unstable_defineEntries as defineEntries } from 'waku/minimal/server';
import { Slot } from 'waku/minimal/client';
import { unstable_createAsyncIterable as createAsyncIterable } from 'waku/server';

import App from './components2/App';
import { runWithRerender } from './als';
Expand All @@ -25,5 +26,42 @@ export default defineEntries({
});
}
},
getBuildConfig: async () => [{ pathSpec: [], entries: [{ rscPath: '' }] }],
handleBuild: ({
// renderRsc,
// renderHtml,
// rscPath2pathname,
unstable_generatePrefetchCode,
}) =>
createAsyncIterable(async () => {
const moduleIds = new Set<string>();
const generateHtmlHead = () =>
`<script type="module" async>${unstable_generatePrefetchCode(
[''],
moduleIds,
)}</script>`;
const tasks = [
async () => ({
type: 'htmlHead' as const,
pathSpec: [],
head: generateHtmlHead(),
}),
// async () => ({
// type: 'file' as const,
// pathname: rscPath2pathname(''),
// body: await renderRsc(
// { App: <App name="Waku" /> },
// { moduleIdCallback: (id) => moduleIds.add(id) },
// ),
// }),
// async () => ({
// type: 'file' as const,
// pathname: '/',
// body: renderHtml({ App: <App name="Waku" /> }, <Slot id="App" />, {
// rscPath: '',
// htmlHead: generateHtmlHead(),
// }).then(({ body }) => body),
// }),
];
return tasks;
}),
});
Loading
Loading