Skip to content

Commit 7a1e828

Browse files
committed
feat(nf): don't write files to disk in dev mode
1 parent 240c69f commit 7a1e828

File tree

12 files changed

+377
-120
lines changed

12 files changed

+377
-120
lines changed
Lines changed: 22 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,31 @@
11
import { MappedPath } from '../utils/mapped-paths';
2-
export type BuildKind = 'shared-package' | 'shared-mapping' | 'exposed' | 'mapping-or-exposed';
2+
export type BuildKind =
3+
| 'shared-package'
4+
| 'shared-mapping'
5+
| 'exposed'
6+
| 'mapping-or-exposed';
37
export interface EntryPoint {
4-
fileName: string;
5-
outName: string;
8+
fileName: string;
9+
outName: string;
610
}
711
export interface BuildAdapterOptions {
8-
entryPoints: EntryPoint[];
9-
tsConfigPath?: string;
10-
external: Array<string>;
11-
outdir: string;
12-
mappedPaths: MappedPath[];
13-
packageName?: string;
14-
esm?: boolean;
15-
dev?: boolean;
16-
watch?: boolean;
17-
kind: BuildKind;
18-
hash: boolean;
12+
entryPoints: EntryPoint[];
13+
tsConfigPath?: string;
14+
external: Array<string>;
15+
outdir: string;
16+
mappedPaths: MappedPath[];
17+
packageName?: string;
18+
esm?: boolean;
19+
dev?: boolean;
20+
watch?: boolean;
21+
kind: BuildKind;
22+
hash: boolean;
1923
}
2024
export interface BuildResult {
21-
fileName: string;
25+
fileName: string;
2226
}
23-
export type BuildAdapter = (options: BuildAdapterOptions) => Promise<BuildResult[]>;
27+
export type BuildAdapter = (
28+
options: BuildAdapterOptions
29+
) => Promise<BuildResult[]>;
2430
export declare function setBuildAdapter(buildAdapter: BuildAdapter): void;
2531
export declare function getBuildAdapter(): BuildAdapter;

libs/native-federation-core/src/lib/core/build-adapter.js

Lines changed: 10 additions & 9 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
import { LogLevels } from 'npmlog';
22
export declare const logger: {
3-
error: (msg: any) => void;
4-
warn: (msg: any) => void;
5-
notice: (msg: any) => void;
6-
info: (msg: any) => void;
7-
verbose: (msg: any) => void;
8-
debug: (msg: any) => void;
3+
error: (msg: any) => void;
4+
warn: (msg: any) => void;
5+
notice: (msg: any) => void;
6+
info: (msg: any) => void;
7+
verbose: (msg: any) => void;
8+
debug: (msg: any) => void;
99
};
1010
export declare const setLogLevel: (level: LogLevels | 'debug') => void;

libs/native-federation-core/src/lib/utils/logger.js

Lines changed: 48 additions & 18 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,14 @@
11
export interface MappedPath {
2-
key: string;
3-
path: string;
2+
key: string;
3+
path: string;
44
}
55
export interface GetMappedPathsOptions {
6-
rootTsConfigPath: string;
7-
sharedMappings?: string[];
8-
rootPath?: string;
6+
rootTsConfigPath: string;
7+
sharedMappings?: string[];
8+
rootPath?: string;
99
}
10-
export declare function getMappedPaths({ rootTsConfigPath, sharedMappings, rootPath, }: GetMappedPathsOptions): Array<MappedPath>;
10+
export declare function getMappedPaths({
11+
rootTsConfigPath,
12+
sharedMappings,
13+
rootPath,
14+
}: GetMappedPathsOptions): Array<MappedPath>;

libs/native-federation-core/src/lib/utils/mapped-paths.js

Lines changed: 44 additions & 34 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

libs/native-federation-esbuild/src/lib/adapter.ts

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -43,13 +43,12 @@ export function createEsBuildAdapter(config: EsBuildAdapterConfig) {
4343
const { entryPoints, external, outdir, hash } = options;
4444

4545
// TODO: Do we need to prepare packages anymore as esbuild has evolved?
46-
4746

4847
for (const entryPoint of entryPoints) {
4948
const isPkg = entryPoint.fileName.includes('node_modules');
5049
const pkgName = isPkg ? inferePkgName(entryPoint.fileName) : '';
5150
const tmpFolder = `node_modules/.tmp/${pkgName}`;
52-
51+
5352
if (isPkg) {
5453
await prepareNodePackage(
5554
entryPoint.fileName,
@@ -61,12 +60,8 @@ export function createEsBuildAdapter(config: EsBuildAdapterConfig) {
6160

6261
entryPoint.fileName = tmpFolder;
6362
}
64-
65-
66-
6763
}
6864

69-
7065
const ctx = await esbuild.context({
7166
entryPoints: entryPoints.map((ep) => ({
7267
in: ep.fileName,

0 commit comments

Comments
 (0)