-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
feat(bundler): define BundlerConfig public API #5882
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
base: split/10-bundler-generate-manifest
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -1 +1,46 @@ | ||||||||||||||||||||
| export {}; | ||||||||||||||||||||
| export { ExternalsResolver, type ExternalsConfig, type ExternalsResolverOptions } from './lib/ExternalsResolver.ts'; | ||||||||||||||||||||
| export { ManifestLoader, type ManifestLoaderOptions } from './lib/ManifestLoader.ts'; | ||||||||||||||||||||
|
|
||||||||||||||||||||
| export interface BundlerExternalsConfig { | ||||||||||||||||||||
| /** Package names to always mark as external, in addition to auto-detected ones. */ | ||||||||||||||||||||
| readonly force?: readonly string[]; | ||||||||||||||||||||
| /** Package names to never mark as external (force inline), overriding auto-detection. */ | ||||||||||||||||||||
| readonly inline?: readonly string[]; | ||||||||||||||||||||
| } | ||||||||||||||||||||
|
|
||||||||||||||||||||
| export interface BundlerPackConfig { | ||||||||||||||||||||
| /** Override for the monorepo workspace root. Defaults to auto-detection. */ | ||||||||||||||||||||
| readonly rootPath?: string; | ||||||||||||||||||||
| } | ||||||||||||||||||||
|
|
||||||||||||||||||||
| export interface BundlerConfig { | ||||||||||||||||||||
| /** Application root directory. Required. */ | ||||||||||||||||||||
| readonly baseDir: string; | ||||||||||||||||||||
| /** Output directory for the bundled artifact. Required. */ | ||||||||||||||||||||
| readonly outputDir: string; | ||||||||||||||||||||
| /** Path to manifest.json. Defaults to `<baseDir>/.egg/manifest.json`. */ | ||||||||||||||||||||
| readonly manifestPath?: string; | ||||||||||||||||||||
| /** Framework name or absolute path. Defaults to `'egg'`. */ | ||||||||||||||||||||
| readonly framework?: string; | ||||||||||||||||||||
| /** Build mode. Defaults to `'production'`. */ | ||||||||||||||||||||
| readonly mode?: 'production' | 'development'; | ||||||||||||||||||||
| /** External package overrides. */ | ||||||||||||||||||||
| readonly externals?: BundlerExternalsConfig; | ||||||||||||||||||||
| /** @utoo/pack tuning. */ | ||||||||||||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The reference to
Suggested change
|
||||||||||||||||||||
| readonly pack?: BundlerPackConfig; | ||||||||||||||||||||
| /** Enable tegg decoratedFile collection. Defaults to `true`. */ | ||||||||||||||||||||
| readonly tegg?: boolean; | ||||||||||||||||||||
| } | ||||||||||||||||||||
|
Comment on lines
+16
to
+33
|
||||||||||||||||||||
|
|
||||||||||||||||||||
| export interface BundleResult { | ||||||||||||||||||||
| /** Absolute path to the output directory. */ | ||||||||||||||||||||
| readonly outputDir: string; | ||||||||||||||||||||
| /** All artifact files (absolute paths), sorted. */ | ||||||||||||||||||||
| readonly files: readonly string[]; | ||||||||||||||||||||
| /** Absolute path to the normalized bundled manifest. */ | ||||||||||||||||||||
| readonly manifestPath: string; | ||||||||||||||||||||
| } | ||||||||||||||||||||
|
|
||||||||||||||||||||
|
||||||||||||||||||||
| /** | |
| * Placeholder API for the future bundling implementation. | |
| * | |
| * This function is not implemented yet and always throws. | |
| * The defaults described on {@link BundlerConfig} are planned behavior and | |
| * are not currently applied at runtime. | |
| */ |
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,9 @@ | ||||||||||||||||||||||||||||||||||||||||||
| import { describe, expect, it } from 'vitest'; | ||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||
| import { bundle } from '../src/index.ts'; | ||||||||||||||||||||||||||||||||||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. For consistency with ESM standards, it is recommended to use the
Suggested change
|
||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||
| describe('@eggjs/egg-bundler', () => { | ||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+1
to
+5
|
||||||||||||||||||||||||||||||||||||||||||
| import { describe, expect, it } from 'vitest'; | |
| import { bundle } from '../src/index.ts'; | |
| describe('@eggjs/egg-bundler', () => { | |
| import { describe, expect, expectTypeOf, it } from 'vitest'; | |
| import { bundle, type BundleResult, type BundlerConfig } from '../src/index.ts'; | |
| describe('@eggjs/egg-bundler', () => { | |
| it('exports bundle() with the expected public API signature', () => { | |
| expectTypeOf(bundle).toEqualTypeOf<(_config: BundlerConfig) => Promise<BundleResult>>(); | |
| }); |
Copilot
AI
Apr 21, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The test hard-codes /tmp paths, which is not cross-platform (fails on Windows) and may also cause collisions across parallel test runs. Use os.tmpdir() + fs.mkdtemp() (or a test temp-dir helper) to create a unique temporary directory, and build baseDir/outputDir with path.join().
| import { describe, expect, it } from 'vitest'; | |
| import { bundle } from '../src/index.ts'; | |
| describe('@eggjs/egg-bundler', () => { | |
| it('bundle() is a placeholder that throws until implemented', async () => { | |
| await expect(bundle({ baseDir: '/tmp', outputDir: '/tmp/out' })).rejects.toThrow(/not implemented/); | |
| import { mkdtemp } from 'node:fs/promises'; | |
| import { tmpdir } from 'node:os'; | |
| import * as path from 'node:path'; | |
| import { describe, expect, it } from 'vitest'; | |
| import { bundle } from '../src/index.ts'; | |
| describe('@eggjs/egg-bundler', () => { | |
| it('bundle() is a placeholder that throws until implemented', async () => { | |
| const baseDir = await mkdtemp(path.join(tmpdir(), 'egg-bundler-')); | |
| const outputDir = path.join(baseDir, 'out'); | |
| await expect(bundle({ baseDir, outputDir })).rejects.toThrow(/not implemented/); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In TypeScript ESM, import and export paths should use the
.jsextension (or the extension that will exist at runtime) rather than.ts. Using.tsextensions in import paths is non-standard and will cause errors in Node.js and most TypeScript configurations unless specific flags likeallowImportingTsExtensionsare used. For standard ESM compatibility, it is recommended to use.jsextensions in the source code.