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

expose unstable builder constants and functions #1314

Merged
merged 2 commits into from
Mar 23, 2025
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
2 changes: 1 addition & 1 deletion packages/waku/src/lib/builder/build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import { INTERNAL_setAllEnv, unstable_getBuildOptions } from '../../server.js';
import type { EntriesPrd } from '../types.js';
import type { ConfigDev } from '../config.js';
import { resolveConfigDev } from '../config.js';
import { EXTENSIONS } from '../constants.js';
import type { PathSpec } from '../utils/path.js';
import {
decodeFilePathFromAbsolute,
Expand Down Expand Up @@ -49,6 +48,7 @@ import { rscEnvPlugin } from '../plugins/vite-plugin-rsc-env.js';
import { rscPrivatePlugin } from '../plugins/vite-plugin-rsc-private.js';
import { rscManagedPlugin } from '../plugins/vite-plugin-rsc-managed.js';
import {
EXTENSIONS,
DIST_ENTRIES_JS,
DIST_PUBLIC,
DIST_ASSETS,
Expand Down
4 changes: 4 additions & 0 deletions packages/waku/src/lib/builder/constants.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
export const EXTENSIONS = ['.js', '.ts', '.tsx', '.jsx', '.mjs', '.cjs'];
export const SRC_MAIN = 'main';
export const SRC_ENTRIES = 'entries';

// Some file and dir names for dist
// We may change this in the future
export const DIST_ENTRIES_JS = 'entries.js';
Expand Down
3 changes: 0 additions & 3 deletions packages/waku/src/lib/constants.ts

This file was deleted.

2 changes: 1 addition & 1 deletion packages/waku/src/lib/middleware/dev-server-impl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import viteReact from '@vitejs/plugin-react';

import type { EntriesDev } from '../types.js';
import { resolveConfigDev } from '../config.js';
import { SRC_MAIN, SRC_ENTRIES } from '../constants.js';
import { SRC_MAIN, SRC_ENTRIES } from '../builder/constants.js';
import {
decodeFilePathFromAbsolute,
joinPath,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,12 @@ import path from 'node:path';
import { writeFileSync } from 'node:fs';
import type { Plugin } from 'vite';

import { unstable_getBuildOptions } from '../../server.js';
import { SRC_ENTRIES } from '../constants.js';
import { DIST_PUBLIC } from '../builder/constants.js';
import {
unstable_getBuildOptions,
unstable_builderConstants,
} from '../../server.js';

const { SRC_ENTRIES, DIST_PUBLIC } = unstable_builderConstants;
const SERVE_JS = 'serve-aws-lambda.js';

const lambdaStreaming = process.env.DEPLOY_AWS_LAMBDA_STREAMING === 'true';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,12 @@ import path from 'node:path';
import type { Plugin } from 'vite';

import { emitPlatformData } from '../builder/platform-data.js';
import { unstable_getBuildOptions } from '../../server.js';
import { DIST_PUBLIC } from '../builder/constants.js';
import { SRC_ENTRIES } from '../constants.js';
import {
unstable_getBuildOptions,
unstable_builderConstants,
} from '../../server.js';

const { SRC_ENTRIES, DIST_PUBLIC } = unstable_builderConstants;
const SERVE_JS = 'serve-cloudflare.js';

const getServeJsContent = (srcEntriesFile: string) => `
Expand Down
8 changes: 5 additions & 3 deletions packages/waku/src/lib/plugins/vite-plugin-deploy-deno.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import type { Plugin } from 'vite';

import { unstable_getBuildOptions } from '../../server.js';
import { SRC_ENTRIES } from '../constants.js';
import { DIST_PUBLIC } from '../builder/constants.js';
import {
unstable_getBuildOptions,
unstable_builderConstants,
} from '../../server.js';

const { SRC_ENTRIES, DIST_PUBLIC } = unstable_builderConstants;
const SERVE_JS = 'serve-deno.js';

const getServeJsContent = (
Expand Down
8 changes: 5 additions & 3 deletions packages/waku/src/lib/plugins/vite-plugin-deploy-netlify.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,12 @@ import path from 'node:path';
import { existsSync, mkdirSync, readFileSync, writeFileSync } from 'node:fs';
import type { Plugin } from 'vite';

import { unstable_getBuildOptions } from '../../server.js';
import { SRC_ENTRIES } from '../constants.js';
import { DIST_PUBLIC } from '../builder/constants.js';
import {
unstable_getBuildOptions,
unstable_builderConstants,
} from '../../server.js';

const { SRC_ENTRIES, DIST_PUBLIC } = unstable_builderConstants;
const SERVE_JS = 'serve-netlify.js';

const getServeJsContent = (srcEntriesFile: string) => `
Expand Down
8 changes: 5 additions & 3 deletions packages/waku/src/lib/plugins/vite-plugin-deploy-partykit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,12 @@ import path from 'node:path';
import { existsSync, writeFileSync } from 'node:fs';
import type { Plugin } from 'vite';

import { unstable_getBuildOptions } from '../../server.js';
import { SRC_ENTRIES } from '../constants.js';
import { DIST_PUBLIC } from '../builder/constants.js';
import {
unstable_getBuildOptions,
unstable_builderConstants,
} from '../../server.js';

const { SRC_ENTRIES, DIST_PUBLIC } = unstable_builderConstants;
const SERVE_JS = 'serve-partykit.js';

const getServeJsContent = (srcEntriesFile: string) => `
Expand Down
8 changes: 5 additions & 3 deletions packages/waku/src/lib/plugins/vite-plugin-deploy-vercel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,13 @@ import path from 'node:path';
import { cpSync, existsSync, mkdirSync, writeFileSync } from 'node:fs';
import type { Plugin } from 'vite';

import { unstable_getBuildOptions } from '../../server.js';
import { SRC_ENTRIES } from '../constants.js';
import { DIST_PUBLIC } from '../builder/constants.js';
import { emitPlatformData } from '../builder/platform-data.js';
import {
unstable_getBuildOptions,
unstable_builderConstants,
} from '../../server.js';

const { SRC_ENTRIES, DIST_PUBLIC } = unstable_builderConstants;
const SERVE_JS = 'serve-vercel.js';

const getServeJsContent = (
Expand Down
2 changes: 1 addition & 1 deletion packages/waku/src/lib/plugins/vite-plugin-dev-commonjs.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { transformWithEsbuild } from 'vite';
import type { Plugin } from 'vite';

import { EXTENSIONS } from '../constants.js';
import { EXTENSIONS } from '../builder/constants.js';
import { extname } from '../utils/path.js';

// https://github.com/vite-plugin/vite-plugin-commonjs/blob/5e3294e78fabb037e12aab75433908fbee17192a/src/utils.ts#L9-L15
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type { Plugin } from 'vite';
import { readdir, writeFile } from 'node:fs/promises';
import { existsSync, readFileSync } from 'node:fs';
import { SRC_ENTRIES, EXTENSIONS } from '../constants.js';
import { SRC_ENTRIES, EXTENSIONS } from '../builder/constants.js';
import { joinPath } from '../utils/path.js';
import { isIgnoredPath } from '../utils/fs-router.js';
import { getGrouplessPath } from '../utils/create-pages.js';
Expand Down
2 changes: 1 addition & 1 deletion packages/waku/src/lib/plugins/vite-plugin-nonjs-resolve.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { Plugin } from 'vite';

import { EXTENSIONS } from '../constants.js';
import { EXTENSIONS } from '../builder/constants.js';
import { extname } from '../utils/path.js';

export function nonjsResolvePlugin(): Plugin {
Expand Down
2 changes: 1 addition & 1 deletion packages/waku/src/lib/plugins/vite-plugin-rsc-analyze.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type { Plugin } from 'vite';
import * as swc from '@swc/core';

import { EXTENSIONS } from '../constants.js';
import { EXTENSIONS } from '../builder/constants.js';
import { extname } from '../utils/path.js';
import { parseOpts } from '../utils/swc.js';
// HACK: Is it common to depend on another plugin like this?
Expand Down
2 changes: 1 addition & 1 deletion packages/waku/src/lib/plugins/vite-plugin-rsc-delegate.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type { Plugin, ViteDevServer } from 'vite';
import * as swc from '@swc/core';

import { EXTENSIONS } from '../constants.js';
import { EXTENSIONS } from '../builder/constants.js';
import { extname } from '../utils/path.js';
import { parseOpts } from '../utils/swc.js';
import type { HotUpdatePayload } from './vite-plugin-rsc-hmr.js';
Expand Down
2 changes: 1 addition & 1 deletion packages/waku/src/lib/plugins/vite-plugin-rsc-entries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import path from 'node:path';
import { normalizePath } from 'vite';
import type { Plugin } from 'vite';

import { SRC_ENTRIES } from '../constants.js';
import { SRC_ENTRIES } from '../builder/constants.js';
import { extname, joinPath } from '../utils/path.js';
import { treeshake, removeObjectProperty } from '../utils/treeshake.js';

Expand Down
2 changes: 1 addition & 1 deletion packages/waku/src/lib/plugins/vite-plugin-rsc-index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { Plugin } from 'vite';

import { SRC_MAIN } from '../constants.js';
import { SRC_MAIN } from '../builder/constants.js';

export function rscIndexPlugin(opts: {
basePath: string;
Expand Down
2 changes: 1 addition & 1 deletion packages/waku/src/lib/plugins/vite-plugin-rsc-managed.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { Plugin } from 'vite';

import { EXTENSIONS, SRC_MAIN, SRC_ENTRIES } from '../constants.js';
import { EXTENSIONS, SRC_MAIN, SRC_ENTRIES } from '../builder/constants.js';
import { extname, joinPath, filePathToFileURL } from '../utils/path.js';

const stripExt = (fname: string) => {
Expand Down
2 changes: 1 addition & 1 deletion packages/waku/src/lib/plugins/vite-plugin-rsc-transform.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type { Plugin } from 'vite';
import * as swc from '@swc/core';

import { EXTENSIONS } from '../constants.js';
import { EXTENSIONS } from '../builder/constants.js';
import { extname, joinPath } from '../utils/path.js';
import { parseOpts } from '../utils/swc.js';

Expand Down
2 changes: 1 addition & 1 deletion packages/waku/src/lib/renderers/html.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { injectRSCPayload } from 'rsc-html-stream/server';

import type * as WakuMinimalClientType from '../../minimal/client.js';
import type { ConfigDev, ConfigPrd } from '../config.js';
import { SRC_MAIN } from '../constants.js';
import { SRC_MAIN } from '../builder/constants.js';
import { concatUint8Arrays } from '../utils/stream.js';
import { filePathToFileURL } from '../utils/path.js';
import { encodeRscPath } from './utils.js';
Expand Down
2 changes: 1 addition & 1 deletion packages/waku/src/router/fs-router.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
import { createPages, METHODS } from './create-pages.js';
import type { Method } from './create-pages.js';

import { EXTENSIONS } from '../lib/constants.js';
import { EXTENSIONS } from '../lib/builder/constants.js';
import { isIgnoredPath } from '../lib/utils/fs-router.js';

const DO_NOT_BUNDLE = '';
Expand Down
3 changes: 3 additions & 0 deletions packages/waku/src/server.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
import { getContext } from './middleware/context.js';

export * as unstable_builderConstants from './lib/builder/constants.js';
export { emitPlatformData as unstable_emitPlatfromData } from './lib/builder/platform-data.js';

// The use of `globalThis` in this file is more or less a hack.
// It should be revisited with a better solution.

Expand Down
Loading