Skip to content
Open
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
1 change: 0 additions & 1 deletion packages/solutions/app-tools/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,6 @@
"@babel/parser": "^7.28.5",
"@babel/traverse": "^7.28.5",
"@babel/types": "^7.28.5",
"@modern-js/node-bundle-require": "workspace:*",
"@modern-js/plugin-data-loader": "workspace:*",
"@modern-js/i18n-utils": "workspace:*",
"@modern-js/plugin": "workspace:*",
Expand Down
1 change: 0 additions & 1 deletion packages/solutions/app-tools/src/commands/dev.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import {
} from '@modern-js/utils';
import type { ConfigChain } from '@rsbuild/core';
import type { AppNormalizedConfig, AppTools } from '../types';
import { buildServerConfig } from '../utils/config';
import { setServer } from '../utils/createServer';
import { loadServerPlugins } from '../utils/loadPlugins';
import { printInstructions } from '../utils/printInstructions';
Expand Down
2 changes: 0 additions & 2 deletions packages/solutions/app-tools/src/exports/server.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1 @@
export type { ServerPlugin } from '@modern-js/server-core';

export { defineServerConfig as defineConfig } from '../utils/config';
63 changes: 0 additions & 63 deletions packages/solutions/app-tools/src/utils/config.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import * as path from 'path';
import { bundle } from '@modern-js/node-bundle-require';
import type { ServerConfig } from '@modern-js/server-core';
import {
fs,
Expand All @@ -11,68 +10,6 @@ import {
import { stringify } from 'flatted';
import type { AppNormalizedConfig } from '../types';

export const defineServerConfig = (config: ServerConfig): ServerConfig =>
config;

export const buildServerConfig = async ({
appDirectory,
distDirectory,
configFile,
options,
watch,
}: {
appDirectory: string;
distDirectory: string;
configFile: string;
options?: Parameters<typeof bundle>[1];
watch?: boolean;
}) => {
const configFilePath = await getServerConfig(appDirectory, configFile);

const getOutputFile = async (filepath: string) =>
path.resolve(
distDirectory,
`${filepath.replace(
new RegExp(CONFIG_FILE_EXTENSIONS.join('|')),
'',
)}.cjs`,
);

if (configFilePath) {
const configHelperFilePath = path.normalize(
path.join(distDirectory, './config-helper.js'),
);
const helperCode = `
export const defineConfig = (config) => config;
`;

await fs.ensureDir(distDirectory);
await fs.writeFile(configHelperFilePath, helperCode);
await bundle(configFilePath, {
...options,
watch,
getOutputFile,
esbuildPlugins: [
{
name: 'native-build-config',
setup(ctx) {
ctx.onResolve(
{
filter: /app-tools\/server/,
},
() => {
return {
path: configHelperFilePath,
};
},
);
},
},
],
});
}
};

export const emitResolvedConfig = async (
appDirectory: string,
resolvedConfig: AppNormalizedConfig,
Expand Down
31 changes: 0 additions & 31 deletions packages/toolkit/node-bundle-require/.npmignore

This file was deleted.

Loading