Skip to content

Commit

Permalink
feat: extract resolve options to plugin definition
Browse files Browse the repository at this point in the history
  • Loading branch information
43081j committed Jan 18, 2023
1 parent c66aa3f commit 33d16fc
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 12 deletions.
2 changes: 1 addition & 1 deletion packages/dev-server-core/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import WebSocket from 'ws';
export { WebSocket };

export { DevServer } from './server/DevServer';
export { Plugin, ServerStartParams } from './plugins/Plugin';
export { Plugin, ServerStartParams, ResolveOptions } from './plugins/Plugin';
export { DevServerCoreConfig, MimeTypeMappings } from './server/DevServerCoreConfig';
export { WebSocketsManager, WebSocketData } from './web-sockets/WebSocketsManager';
export {
Expand Down
12 changes: 7 additions & 5 deletions packages/dev-server-core/src/plugins/Plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,12 @@ export interface ServerStartParams {
webSockets?: WebSocketsManager;
}

export interface ResolveOptions {
isEntry?: boolean;
skipSelf?: boolean;
[key: string]: unknown;
}

export interface Plugin {
name: string;
injectWebSocket?: boolean;
Expand All @@ -40,11 +46,7 @@ export interface Plugin {
code?: string;
column?: number;
line?: number;
resolveOptions?: {
custom?: Record<string, unknown>;
isEntry?: boolean;
skipSelf?: boolean;
};
resolveOptions?: ResolveOptions;
}): ResolveResult | Promise<ResolveResult>;
resolveImportSkip?(context: Context, source: string, importer: string): void;
transformImport?(args: {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
import path from 'path';
import { DevServerCoreConfig, FSWatcher, Plugin as WdsPlugin, Context } from '@web/dev-server-core';
import {
DevServerCoreConfig,
FSWatcher,
Plugin as WdsPlugin,
Context,
ResolveOptions,
} from '@web/dev-server-core';
import {
PluginContext,
MinimalPluginContext,
Expand All @@ -8,11 +14,6 @@ import {
ModuleInfo,
} from 'rollup';

interface ResolveOptions {
skipSelf?: boolean;
[key: string]: unknown;
}

export function createRollupPluginContextAdapter<
T extends PluginContext | MinimalPluginContext | TransformPluginContext,
>(
Expand Down

0 comments on commit 33d16fc

Please sign in to comment.