@web/dev-server
Advanced tools
Comparing version
#!/usr/bin/env node | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const startDevServer_1 = require("./startDevServer"); | ||
startDevServer_1.startDevServer(); | ||
import { startDevServer } from './startDevServer.js'; | ||
startDevServer(); | ||
//# sourceMappingURL=bin.js.map |
@@ -1,3 +0,2 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
export {}; | ||
//# sourceMappingURL=DevServerConfig.js.map |
@@ -1,3 +0,3 @@ | ||
import { DevServerConfig } from './DevServerConfig'; | ||
import { DevServerConfig } from './DevServerConfig.js'; | ||
export declare function mergeConfigs(...configs: Partial<DevServerConfig | undefined>[]): Partial<DevServerConfig>; | ||
//# sourceMappingURL=mergeConfigs.d.ts.map |
@@ -1,6 +0,3 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.mergeConfigs = void 0; | ||
const arrayKeys = ['plugins', 'middleware']; | ||
function mergeConfigs(...configs) { | ||
export function mergeConfigs(...configs) { | ||
const finalConfig = { | ||
@@ -26,3 +23,2 @@ plugins: [], | ||
} | ||
exports.mergeConfigs = mergeConfigs; | ||
//# sourceMappingURL=mergeConfigs.js.map |
@@ -1,5 +0,5 @@ | ||
import { DevServerCliArgs } from './readCliArgs'; | ||
import { DevServerConfig } from './DevServerConfig'; | ||
import { DevServerCliArgs } from './readCliArgs.js'; | ||
import { DevServerConfig } from './DevServerConfig.js'; | ||
export declare function validateConfig(config: Partial<DevServerConfig>): DevServerConfig; | ||
export declare function parseConfig(config: Partial<DevServerConfig>, cliArgs?: DevServerCliArgs): Promise<DevServerConfig>; | ||
//# sourceMappingURL=parseConfig.d.ts.map |
@@ -1,14 +0,8 @@ | ||
"use strict"; | ||
var __importDefault = (this && this.__importDefault) || function (mod) { | ||
return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.parseConfig = exports.validateConfig = void 0; | ||
const portfinder_1 = require("portfinder"); | ||
const path_1 = __importDefault(require("path")); | ||
const mergeConfigs_1 = require("./mergeConfigs"); | ||
const esbuildPlugin_1 = require("../plugins/esbuildPlugin"); | ||
const watchPlugin_1 = require("../plugins/watchPlugin"); | ||
const nodeResolvePlugin_1 = require("../plugins/nodeResolvePlugin"); | ||
const DevServerStartError_1 = require("../DevServerStartError"); | ||
import { getPortPromise } from 'portfinder'; | ||
import path from 'path'; | ||
import { mergeConfigs } from './mergeConfigs.js'; | ||
import { esbuildPlugin } from '../plugins/esbuildPlugin.js'; | ||
import { watchPlugin } from '../plugins/watchPlugin.js'; | ||
import { nodeResolvePlugin } from '../plugins/nodeResolvePlugin.js'; | ||
import { DevServerStartError } from '../DevServerStartError.js'; | ||
const defaultConfig = { | ||
@@ -27,3 +21,3 @@ rootDir: process.cwd(), | ||
if (typeof config[key] !== type) { | ||
throw new DevServerStartError_1.DevServerStartError(`Configuration error: The ${key} setting should be a ${type}.`); | ||
throw new DevServerStartError(`Configuration error: The ${key} setting should be a ${type}.`); | ||
} | ||
@@ -34,3 +28,3 @@ } | ||
const booleanSettings = ['watch', 'preserveSymlinks', 'http2', 'eventStream']; | ||
function validateConfig(config) { | ||
export function validateConfig(config) { | ||
stringSettings.forEach(key => validate(config, key, 'string')); | ||
@@ -52,6 +46,4 @@ numberSettings.forEach(key => validate(config, key, 'number')); | ||
} | ||
exports.validateConfig = validateConfig; | ||
async function parseConfig(config, cliArgs) { | ||
var _a; | ||
const mergedConfigs = mergeConfigs_1.mergeConfigs(defaultConfig, config, cliArgs); | ||
export async function parseConfig(config, cliArgs) { | ||
const mergedConfigs = mergeConfigs(defaultConfig, config, cliArgs); | ||
// backwards compatibility for configs written for es-dev-server, where middleware was | ||
@@ -64,10 +56,10 @@ // spelled incorrectly as middlewares | ||
// filter out non-objects from plugin list | ||
finalConfig.plugins = ((_a = finalConfig.plugins) !== null && _a !== void 0 ? _a : []).filter(pl => typeof pl === 'object'); | ||
finalConfig.plugins = (finalConfig.plugins ?? []).filter(pl => typeof pl === 'object'); | ||
// ensure rootDir is always resolved | ||
if (typeof finalConfig.rootDir === 'string') { | ||
finalConfig.rootDir = path_1.default.resolve(finalConfig.rootDir); | ||
finalConfig.rootDir = path.resolve(finalConfig.rootDir); | ||
} | ||
// generate a default random port | ||
if (typeof finalConfig.port !== 'number') { | ||
finalConfig.port = await portfinder_1.getPortPromise({ port: 8000 }); | ||
finalConfig.port = await getPortPromise({ port: 8000 }); | ||
} | ||
@@ -77,14 +69,13 @@ if (finalConfig.nodeResolve) { | ||
// do node resolve after user plugins, to allow user plugins to resolve imports | ||
finalConfig.plugins.push(nodeResolvePlugin_1.nodeResolvePlugin(finalConfig.rootDir, finalConfig.preserveSymlinks, userOptions)); | ||
finalConfig.plugins.push(nodeResolvePlugin(finalConfig.rootDir, finalConfig.preserveSymlinks, userOptions)); | ||
} | ||
// map flags to plugin | ||
if (finalConfig === null || finalConfig === void 0 ? void 0 : finalConfig.esbuildTarget) { | ||
finalConfig.plugins.unshift(esbuildPlugin_1.esbuildPlugin(finalConfig.esbuildTarget)); | ||
if (finalConfig?.esbuildTarget) { | ||
finalConfig.plugins.unshift(esbuildPlugin(finalConfig.esbuildTarget)); | ||
} | ||
if (finalConfig.watch) { | ||
finalConfig.plugins.unshift(watchPlugin_1.watchPlugin()); | ||
finalConfig.plugins.unshift(watchPlugin()); | ||
} | ||
return finalConfig; | ||
} | ||
exports.parseConfig = parseConfig; | ||
//# sourceMappingURL=parseConfig.js.map |
@@ -1,2 +0,2 @@ | ||
import { DevServerConfig } from './DevServerConfig'; | ||
import { DevServerConfig } from './DevServerConfig.js'; | ||
export interface DevServerCliArgs extends Partial<Pick<DevServerConfig, 'rootDir' | 'open' | 'appIndex' | 'preserveSymlinks' | 'nodeResolve' | 'watch' | 'esbuildTarget'>> { | ||
@@ -3,0 +3,0 @@ config?: string; |
@@ -1,10 +0,4 @@ | ||
"use strict"; | ||
var __importDefault = (this && this.__importDefault) || function (mod) { | ||
return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.readCliArgs = void 0; | ||
const command_line_args_1 = __importDefault(require("command-line-args")); | ||
const command_line_usage_1 = __importDefault(require("command-line-usage")); | ||
const camelcase_1 = __importDefault(require("camelcase")); | ||
import commandLineArgs from 'command-line-args'; | ||
import commandLineUsage from 'command-line-usage'; | ||
import camelCase from 'camelcase'; | ||
const options = [ | ||
@@ -85,4 +79,4 @@ { | ||
]; | ||
function readCliArgs({ argv = process.argv } = {}) { | ||
const cliArgs = command_line_args_1.default(options, { argv, partial: true }); | ||
export function readCliArgs({ argv = process.argv } = {}) { | ||
const cliArgs = commandLineArgs(options, { argv, partial: true }); | ||
// when the open flag is used without arguments, it defaults to null. treat this as "true" | ||
@@ -94,3 +88,3 @@ if ('open' in cliArgs && typeof cliArgs.open !== 'string') { | ||
/* eslint-disable-next-line no-console */ | ||
console.log(command_line_usage_1.default([ | ||
console.log(commandLineUsage([ | ||
{ | ||
@@ -110,7 +104,6 @@ header: 'Web Dev Server', | ||
for (const [key, value] of Object.entries(cliArgs)) { | ||
cliArgsConfig[camelcase_1.default(key)] = value; | ||
cliArgsConfig[camelCase(key)] = value; | ||
} | ||
return cliArgsConfig; | ||
} | ||
exports.readCliArgs = readCliArgs; | ||
//# sourceMappingURL=readCliArgs.js.map |
@@ -1,6 +0,3 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.readFileConfig = void 0; | ||
const config_loader_1 = require("@web/config-loader"); | ||
const DevServerStartError_1 = require("../DevServerStartError"); | ||
import { readConfig, ConfigLoaderError } from '@web/config-loader'; | ||
import { DevServerStartError } from '../DevServerStartError.js'; | ||
/** | ||
@@ -11,9 +8,9 @@ * Reads the config from disk, defaults to process.cwd() + web-dev-server.config.{mjs,js,cjs} or | ||
*/ | ||
async function readFileConfig({ configName = 'web-dev-server.config', configPath, } = {}) { | ||
export async function readFileConfig({ configName = 'web-dev-server.config', configPath, } = {}) { | ||
try { | ||
return await config_loader_1.readConfig(configName, typeof configPath === 'string' ? configPath : undefined); | ||
return await readConfig(configName, typeof configPath === 'string' ? configPath : undefined); | ||
} | ||
catch (error) { | ||
if (error instanceof config_loader_1.ConfigLoaderError) { | ||
throw new DevServerStartError_1.DevServerStartError(error.message); | ||
if (error instanceof ConfigLoaderError) { | ||
throw new DevServerStartError(error.message); | ||
} | ||
@@ -23,3 +20,2 @@ throw error; | ||
} | ||
exports.readFileConfig = readFileConfig; | ||
//# sourceMappingURL=readFileConfig.js.map |
@@ -1,7 +0,3 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.DevServerStartError = void 0; | ||
class DevServerStartError extends Error { | ||
export class DevServerStartError extends Error { | ||
} | ||
exports.DevServerStartError = DevServerStartError; | ||
//# sourceMappingURL=DevServerStartError.js.map |
export { RollupNodeResolveOptions } from '@web/dev-server-rollup'; | ||
export { startDevServer } from './startDevServer'; | ||
export { mergeConfigs } from './config/mergeConfigs'; | ||
export { DevServerStartError } from './DevServerStartError'; | ||
export { esbuildPlugin } from './plugins/esbuildPlugin'; | ||
export { nodeResolvePlugin } from './plugins/nodeResolvePlugin'; | ||
import type { DevServerConfig as FullDevServerConfig } from './config/DevServerConfig'; | ||
export declare type DevServerConfig = Partial<FullDevServerConfig>; | ||
export { startDevServer } from './startDevServer.js'; | ||
export { mergeConfigs } from './config/mergeConfigs.js'; | ||
export { DevServerStartError } from './DevServerStartError.js'; | ||
export { esbuildPlugin } from './plugins/esbuildPlugin.js'; | ||
export { nodeResolvePlugin } from './plugins/nodeResolvePlugin.js'; | ||
import type { DevServerConfig as FullDevServerConfig } from './config/DevServerConfig.js'; | ||
export type DevServerConfig = Partial<FullDevServerConfig>; | ||
//# sourceMappingURL=index.d.ts.map |
@@ -1,14 +0,6 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.nodeResolvePlugin = exports.esbuildPlugin = exports.DevServerStartError = exports.mergeConfigs = exports.startDevServer = void 0; | ||
var startDevServer_1 = require("./startDevServer"); | ||
Object.defineProperty(exports, "startDevServer", { enumerable: true, get: function () { return startDevServer_1.startDevServer; } }); | ||
var mergeConfigs_1 = require("./config/mergeConfigs"); | ||
Object.defineProperty(exports, "mergeConfigs", { enumerable: true, get: function () { return mergeConfigs_1.mergeConfigs; } }); | ||
var DevServerStartError_1 = require("./DevServerStartError"); | ||
Object.defineProperty(exports, "DevServerStartError", { enumerable: true, get: function () { return DevServerStartError_1.DevServerStartError; } }); | ||
var esbuildPlugin_1 = require("./plugins/esbuildPlugin"); | ||
Object.defineProperty(exports, "esbuildPlugin", { enumerable: true, get: function () { return esbuildPlugin_1.esbuildPlugin; } }); | ||
var nodeResolvePlugin_1 = require("./plugins/nodeResolvePlugin"); | ||
Object.defineProperty(exports, "nodeResolvePlugin", { enumerable: true, get: function () { return nodeResolvePlugin_1.nodeResolvePlugin; } }); | ||
export { startDevServer } from './startDevServer.js'; | ||
export { mergeConfigs } from './config/mergeConfigs.js'; | ||
export { DevServerStartError } from './DevServerStartError.js'; | ||
export { esbuildPlugin } from './plugins/esbuildPlugin.js'; | ||
export { nodeResolvePlugin } from './plugins/nodeResolvePlugin.js'; | ||
//# sourceMappingURL=index.js.map |
import { Plugin } from '@web/dev-server-core'; | ||
import { DevServerLogger } from './DevServerLogger'; | ||
import { DevServerLogger } from './DevServerLogger.js'; | ||
export interface LoggerArgs { | ||
@@ -4,0 +4,0 @@ debugLogging: boolean; |
@@ -1,10 +0,7 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.createLogger = void 0; | ||
const DevServerLogger_1 = require("./DevServerLogger"); | ||
const logStartMessage_1 = require("./logStartMessage"); | ||
import { DevServerLogger } from './DevServerLogger.js'; | ||
import { logStartMessage } from './logStartMessage.js'; | ||
const CLEAR_COMMAND = process.platform === 'win32' ? '\x1B[2J\x1B[0f' : '\x1B[2J\x1B[H'; | ||
function createLogger(args) { | ||
export function createLogger(args) { | ||
let onSyntaxError; | ||
const logger = new DevServerLogger_1.DevServerLogger(args.debugLogging, msg => onSyntaxError === null || onSyntaxError === void 0 ? void 0 : onSyntaxError(msg)); | ||
const logger = new DevServerLogger(args.debugLogging, msg => onSyntaxError?.(msg)); | ||
return { | ||
@@ -24,3 +21,3 @@ logger, | ||
} | ||
logStartMessage_1.logStartMessage(config, logger); | ||
logStartMessage(config, logger); | ||
} | ||
@@ -38,3 +35,2 @@ if (args.logStartMessage) { | ||
} | ||
exports.createLogger = createLogger; | ||
//# sourceMappingURL=createLogger.js.map |
@@ -1,11 +0,7 @@ | ||
"use strict"; | ||
var __importDefault = (this && this.__importDefault) || function (mod) { | ||
return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.DevServerLogger = void 0; | ||
const code_frame_1 = require("@babel/code-frame"); | ||
const path_1 = __importDefault(require("path")); | ||
const nanocolors_1 = require("nanocolors"); | ||
class DevServerLogger { | ||
import { codeFrameColumns } from '@babel/code-frame'; | ||
import path from 'path'; | ||
import { red, cyan } from 'nanocolors'; | ||
export class DevServerLogger { | ||
debugLogging; | ||
onSyntaxError; | ||
constructor(debugLogging, onSyntaxError) { | ||
@@ -37,6 +33,6 @@ this.debugLogging = debugLogging; | ||
const { message, code, filePath, column, line } = error; | ||
const highlightedResult = code_frame_1.codeFrameColumns(code, { start: { line, column } }, { highlightCode: true }); | ||
const result = code_frame_1.codeFrameColumns(code, { start: { line, column } }, { highlightCode: false }); | ||
const relativePath = path_1.default.relative(process.cwd(), filePath); | ||
console.error(nanocolors_1.red(`Error while transforming ${nanocolors_1.cyan(relativePath)}: ${message}\n`)); | ||
const highlightedResult = codeFrameColumns(code, { start: { line, column } }, { highlightCode: true }); | ||
const result = codeFrameColumns(code, { start: { line, column } }, { highlightCode: false }); | ||
const relativePath = path.relative(process.cwd(), filePath); | ||
console.error(red(`Error while transforming ${cyan(relativePath)}: ${message}\n`)); | ||
console.error(highlightedResult); | ||
@@ -47,3 +43,2 @@ console.error(''); | ||
} | ||
exports.DevServerLogger = DevServerLogger; | ||
//# sourceMappingURL=DevServerLogger.js.map |
@@ -1,24 +0,17 @@ | ||
"use strict"; | ||
var __importDefault = (this && this.__importDefault) || function (mod) { | ||
return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.logStartMessage = void 0; | ||
const ip_1 = __importDefault(require("ip")); | ||
const nanocolors_1 = require("nanocolors"); | ||
import ip from 'ip'; | ||
import { bold, cyan, white } from 'nanocolors'; | ||
const createAddress = (config, host, path) => `http${config.http2 ? 's' : ''}://${host}:${config.port}${path}`; | ||
function logNetworkAddress(config, logger, openPath) { | ||
try { | ||
const address = ip_1.default.address(); | ||
const address = ip.address(); | ||
if (typeof address === 'string') { | ||
logger.log(`${nanocolors_1.white('Network:')} ${nanocolors_1.cyan(createAddress(config, address, openPath))}`); | ||
logger.log(`${white('Network:')} ${cyan(createAddress(config, address, openPath))}`); | ||
} | ||
} | ||
catch (_a) { | ||
catch { | ||
// | ||
} | ||
} | ||
function logStartMessage(config, logger) { | ||
var _a; | ||
const prettyHost = (_a = config.hostname) !== null && _a !== void 0 ? _a : 'localhost'; | ||
export function logStartMessage(config, logger) { | ||
const prettyHost = config.hostname ?? 'localhost'; | ||
let openPath = typeof config.open === 'string' ? config.open : '/'; | ||
@@ -28,7 +21,7 @@ if (!openPath.startsWith('/')) { | ||
} | ||
logger.log(nanocolors_1.bold('Web Dev Server started...')); | ||
logger.log(bold('Web Dev Server started...')); | ||
logger.log(''); | ||
logger.group(); | ||
logger.log(`${nanocolors_1.white('Root dir:')} ${nanocolors_1.cyan(config.rootDir)}`); | ||
logger.log(`${nanocolors_1.white('Local:')} ${nanocolors_1.cyan(createAddress(config, prettyHost, openPath))}`); | ||
logger.log(`${white('Root dir:')} ${cyan(config.rootDir)}`); | ||
logger.log(`${white('Local:')} ${cyan(createAddress(config, prettyHost, openPath))}`); | ||
logNetworkAddress(config, logger, openPath); | ||
@@ -38,3 +31,2 @@ logger.groupEnd(); | ||
} | ||
exports.logStartMessage = logStartMessage; | ||
//# sourceMappingURL=logStartMessage.js.map |
@@ -1,3 +0,3 @@ | ||
import { DevServerConfig } from './config/DevServerConfig'; | ||
import { DevServerConfig } from './config/DevServerConfig.js'; | ||
export declare function openBrowser(config: DevServerConfig): Promise<void>; | ||
//# sourceMappingURL=openBrowser.d.ts.map |
@@ -1,9 +0,3 @@ | ||
"use strict"; | ||
var __importDefault = (this && this.__importDefault) || function (mod) { | ||
return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.openBrowser = void 0; | ||
const open_1 = __importDefault(require("open")); | ||
const path_1 = __importDefault(require("path")); | ||
import openBrowserWindow from 'open'; | ||
import path from 'path'; | ||
function isValidURL(str) { | ||
@@ -26,3 +20,3 @@ try { | ||
} | ||
async function openBrowser(config) { | ||
export async function openBrowser(config) { | ||
const basePath = getBasePath(config.basePath); | ||
@@ -35,6 +29,6 @@ let openPath; | ||
else if (config.appIndex) { | ||
const resolvedAppIndex = path_1.default.resolve(config.appIndex); | ||
const relativeAppIndex = path_1.default.relative(config.rootDir, resolvedAppIndex); | ||
const appIndexBrowserPath = `/${relativeAppIndex.split(path_1.default.sep).join('/')}`; | ||
const appIndexDir = path_1.default.dirname(appIndexBrowserPath); | ||
const resolvedAppIndex = path.resolve(config.appIndex); | ||
const relativeAppIndex = path.relative(config.rootDir, resolvedAppIndex); | ||
const appIndexBrowserPath = `/${relativeAppIndex.split(path.sep).join('/')}`; | ||
const appIndexDir = path.dirname(appIndexBrowserPath); | ||
// if an appIndex was provided, use it's directory as open path | ||
@@ -50,5 +44,4 @@ openPath = `${basePath}${appIndexDir.endsWith('/') ? appIndexDir : `${appIndexDir}/`}`; | ||
} | ||
await open_1.default(openPath); | ||
await openBrowserWindow(openPath); | ||
} | ||
exports.openBrowser = openBrowser; | ||
//# sourceMappingURL=openBrowser.js.map |
@@ -1,4 +0,1 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.esbuildPlugin = void 0; | ||
function requirePlugin() { | ||
@@ -18,7 +15,6 @@ try { | ||
} | ||
function esbuildPlugin(target) { | ||
export function esbuildPlugin(target) { | ||
const pluginModule = requirePlugin(); | ||
return pluginModule.esbuildPlugin({ target }); | ||
} | ||
exports.esbuildPlugin = esbuildPlugin; | ||
//# sourceMappingURL=esbuildPlugin.js.map |
@@ -1,12 +0,6 @@ | ||
"use strict"; | ||
var __importDefault = (this && this.__importDefault) || function (mod) { | ||
return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.nodeResolvePlugin = void 0; | ||
const dev_server_rollup_1 = require("@web/dev-server-rollup"); | ||
const deepmerge_1 = __importDefault(require("deepmerge")); | ||
function nodeResolvePlugin(rootDir, preserveSymlinks, userOptions) { | ||
import { nodeResolve, rollupAdapter } from '@web/dev-server-rollup'; | ||
import deepmerge from 'deepmerge'; | ||
export function nodeResolvePlugin(rootDir, preserveSymlinks, userOptions) { | ||
const userOptionsObject = typeof userOptions === 'object' ? userOptions : {}; | ||
const options = deepmerge_1.default({ | ||
const options = deepmerge({ | ||
rootDir, | ||
@@ -18,5 +12,6 @@ extensions: ['.mjs', '.js', '.cjs', '.jsx', '.json', '.ts', '.tsx'], | ||
}, userOptionsObject); | ||
return dev_server_rollup_1.rollupAdapter(dev_server_rollup_1.nodeResolve(options), { preserveSymlinks }, { throwOnUnresolvedImport: true }); | ||
// use user config exportConditions if present. otherwise use ['development'] | ||
options.exportConditions = userOptionsObject.exportConditions || ['development']; | ||
return rollupAdapter(nodeResolve(options), { preserveSymlinks }, { throwOnUnresolvedImport: true }); | ||
} | ||
exports.nodeResolvePlugin = nodeResolvePlugin; | ||
//# sourceMappingURL=nodeResolvePlugin.js.map |
@@ -1,9 +0,3 @@ | ||
"use strict"; | ||
var __importDefault = (this && this.__importDefault) || function (mod) { | ||
return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.watchPlugin = void 0; | ||
const debounce_1 = __importDefault(require("debounce")); | ||
function watchPlugin() { | ||
import debounce from 'debounce'; | ||
export function watchPlugin() { | ||
return { | ||
@@ -19,3 +13,3 @@ name: 'watch', | ||
} | ||
const onChange = debounce_1.default(onFileChanged, 100); | ||
const onChange = debounce(onFileChanged, 100); | ||
fileWatcher.addListener('change', onChange); | ||
@@ -26,3 +20,2 @@ fileWatcher.addListener('unlink', onChange); | ||
} | ||
exports.watchPlugin = watchPlugin; | ||
//# sourceMappingURL=watchPlugin.js.map |
import { DevServer } from '@web/dev-server-core'; | ||
import { DevServerConfig } from './config/DevServerConfig'; | ||
import { DevServerConfig } from './config/DevServerConfig.js'; | ||
export interface StartDevServerParams { | ||
@@ -4,0 +4,0 @@ /** |
@@ -1,26 +0,22 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.startDevServer = void 0; | ||
const dev_server_core_1 = require("@web/dev-server-core"); | ||
const mergeConfigs_1 = require("./config/mergeConfigs"); | ||
const parseConfig_1 = require("./config/parseConfig"); | ||
const readCliArgs_1 = require("./config/readCliArgs"); | ||
const readFileConfig_1 = require("./config/readFileConfig"); | ||
const DevServerStartError_1 = require("./DevServerStartError"); | ||
const createLogger_1 = require("./logger/createLogger"); | ||
const openBrowser_1 = require("./openBrowser"); | ||
import { DevServer } from '@web/dev-server-core'; | ||
import { mergeConfigs } from './config/mergeConfigs.js'; | ||
import { parseConfig } from './config/parseConfig.js'; | ||
import { readCliArgs } from './config/readCliArgs.js'; | ||
import { readFileConfig } from './config/readFileConfig.js'; | ||
import { DevServerStartError } from './DevServerStartError.js'; | ||
import { createLogger } from './logger/createLogger.js'; | ||
import { openBrowser } from './openBrowser.js'; | ||
/** | ||
* Starts the dev server. | ||
*/ | ||
async function startDevServer(options = {}) { | ||
var _a; | ||
export async function startDevServer(options = {}) { | ||
const { config: extraConfig, readCliArgs: readCliArgsFlag = true, readFileConfig: readFileConfigFlag = true, configName, autoExitProcess = true, logStartMessage = true, argv = process.argv, } = options; | ||
try { | ||
const cliArgs = readCliArgsFlag ? readCliArgs_1.readCliArgs({ argv }) : {}; | ||
const cliArgs = readCliArgsFlag ? readCliArgs({ argv }) : {}; | ||
const rawConfig = readFileConfigFlag | ||
? await readFileConfig_1.readFileConfig({ configName, configPath: cliArgs.config }) | ||
? await readFileConfig({ configName, configPath: cliArgs.config }) | ||
: {}; | ||
const mergedConfig = mergeConfigs_1.mergeConfigs(extraConfig, rawConfig); | ||
const config = await parseConfig_1.parseConfig(mergedConfig, cliArgs); | ||
const { logger, loggerPlugin } = createLogger_1.createLogger({ | ||
const mergedConfig = mergeConfigs(extraConfig, rawConfig); | ||
const config = await parseConfig(mergedConfig, cliArgs); | ||
const { logger, loggerPlugin } = createLogger({ | ||
debugLogging: !!config.debug, | ||
@@ -30,5 +26,5 @@ clearTerminalOnReload: !!config.watch && !!config.clearTerminalOnReload, | ||
}); | ||
config.plugins = (_a = config.plugins) !== null && _a !== void 0 ? _a : []; | ||
config.plugins = config.plugins ?? []; | ||
config.plugins.unshift(loggerPlugin); | ||
const server = new dev_server_core_1.DevServer(config, logger); | ||
const server = new DevServer(config, logger); | ||
if (autoExitProcess) { | ||
@@ -46,3 +42,3 @@ process.on('uncaughtException', error => { | ||
if (config.open != null && config.open !== false) { | ||
await openBrowser_1.openBrowser(config); | ||
await openBrowser(config); | ||
} | ||
@@ -52,3 +48,3 @@ return server; | ||
catch (error) { | ||
if (error instanceof DevServerStartError_1.DevServerStartError) { | ||
if (error instanceof DevServerStartError) { | ||
console.error(error.message); | ||
@@ -62,3 +58,2 @@ } | ||
} | ||
exports.startDevServer = startDevServer; | ||
//# sourceMappingURL=startDevServer.js.map |
{ | ||
"name": "@web/dev-server", | ||
"version": "0.0.0-canary-20230420104136", | ||
"version": "0.0.0-canary-20231122093600", | ||
"publishConfig": { | ||
@@ -21,4 +21,6 @@ "access": "public" | ||
}, | ||
"type": "module", | ||
"exports": { | ||
".": { | ||
"types": "./index.d.ts", | ||
"import": "./index.mjs", | ||
@@ -29,6 +31,6 @@ "require": "./dist/index.js" | ||
"engines": { | ||
"node": ">=16.0.0" | ||
"node": ">=18.0.0" | ||
}, | ||
"scripts": { | ||
"start": "yarn start:syntax", | ||
"start": "npm run start:syntax", | ||
"start:base-path": "node dist/bin.js --config demo/base-path/config.mjs --open", | ||
@@ -45,5 +47,3 @@ "start:http2": "node dist/bin.js --config demo/http2/config.mjs --open demo/http2/", | ||
"files": [ | ||
"*.d.mts", | ||
"*.d.ts", | ||
"*.js", | ||
"*.mjs", | ||
@@ -64,5 +64,5 @@ "dist", | ||
"@types/command-line-args": "^5.0.0", | ||
"@web/config-loader": "0.0.0-canary-20230420104136", | ||
"@web/dev-server-core": "0.0.0-canary-20230420104136", | ||
"@web/dev-server-rollup": "0.0.0-canary-20230420104136", | ||
"@web/config-loader": "0.0.0-canary-20231122093600", | ||
"@web/dev-server-core": "0.0.0-canary-20231122093600", | ||
"@web/dev-server-rollup": "0.0.0-canary-20231122093600", | ||
"camelcase": "^6.2.0", | ||
@@ -80,5 +80,5 @@ "command-line-args": "^5.1.1", | ||
"@types/command-line-usage": "^5.0.1", | ||
"lit-html": "^2.0.0", | ||
"puppeteer": "^19.8.2" | ||
"lit-html": "^2.7.3 || ^3.0.0", | ||
"puppeteer": "^20.0.0" | ||
} | ||
} |
#!/usr/bin/env node | ||
import { startDevServer } from './startDevServer'; | ||
import { startDevServer } from './startDevServer.js'; | ||
startDevServer(); |
@@ -1,2 +0,2 @@ | ||
import { DevServerConfig } from './DevServerConfig'; | ||
import { DevServerConfig } from './DevServerConfig.js'; | ||
@@ -3,0 +3,0 @@ const arrayKeys = ['plugins', 'middleware']; |
import { getPortPromise } from 'portfinder'; | ||
import path from 'path'; | ||
import { DevServerCliArgs } from './readCliArgs'; | ||
import { mergeConfigs } from './mergeConfigs'; | ||
import { DevServerConfig } from './DevServerConfig'; | ||
import { esbuildPlugin } from '../plugins/esbuildPlugin'; | ||
import { watchPlugin } from '../plugins/watchPlugin'; | ||
import { nodeResolvePlugin } from '../plugins/nodeResolvePlugin'; | ||
import { DevServerStartError } from '../DevServerStartError'; | ||
import { DevServerCliArgs } from './readCliArgs.js'; | ||
import { mergeConfigs } from './mergeConfigs.js'; | ||
import { DevServerConfig } from './DevServerConfig.js'; | ||
import { esbuildPlugin } from '../plugins/esbuildPlugin.js'; | ||
import { watchPlugin } from '../plugins/watchPlugin.js'; | ||
import { nodeResolvePlugin } from '../plugins/nodeResolvePlugin.js'; | ||
import { DevServerStartError } from '../DevServerStartError.js'; | ||
@@ -12,0 +12,0 @@ const defaultConfig: Partial<DevServerConfig> = { |
import commandLineArgs from 'command-line-args'; | ||
import commandLineUsage, { OptionDefinition } from 'command-line-usage'; | ||
import camelCase from 'camelcase'; | ||
import { DevServerConfig } from './DevServerConfig'; | ||
import { DevServerConfig } from './DevServerConfig.js'; | ||
@@ -6,0 +6,0 @@ export interface DevServerCliArgs |
import { readConfig, ConfigLoaderError } from '@web/config-loader'; | ||
import { DevServerStartError } from '../DevServerStartError'; | ||
import { DevServerStartError } from '../DevServerStartError.js'; | ||
@@ -30,3 +30,3 @@ export interface ReadFileConfigParams { | ||
if (error instanceof ConfigLoaderError) { | ||
throw new DevServerStartError(error.message); | ||
throw new DevServerStartError((error as Error).message); | ||
} | ||
@@ -33,0 +33,0 @@ throw error; |
export { RollupNodeResolveOptions } from '@web/dev-server-rollup'; | ||
export { startDevServer } from './startDevServer'; | ||
export { mergeConfigs } from './config/mergeConfigs'; | ||
export { DevServerStartError } from './DevServerStartError'; | ||
export { esbuildPlugin } from './plugins/esbuildPlugin'; | ||
export { nodeResolvePlugin } from './plugins/nodeResolvePlugin'; | ||
export { startDevServer } from './startDevServer.js'; | ||
export { mergeConfigs } from './config/mergeConfigs.js'; | ||
export { DevServerStartError } from './DevServerStartError.js'; | ||
export { esbuildPlugin } from './plugins/esbuildPlugin.js'; | ||
export { nodeResolvePlugin } from './plugins/nodeResolvePlugin.js'; | ||
import type { DevServerConfig as FullDevServerConfig } from './config/DevServerConfig'; | ||
import type { DevServerConfig as FullDevServerConfig } from './config/DevServerConfig.js'; | ||
export type DevServerConfig = Partial<FullDevServerConfig>; |
import { Plugin } from '@web/dev-server-core'; | ||
import { DevServerLogger } from './DevServerLogger'; | ||
import { logStartMessage } from './logStartMessage'; | ||
import { DevServerLogger } from './DevServerLogger.js'; | ||
import { logStartMessage } from './logStartMessage.js'; | ||
@@ -5,0 +5,0 @@ const CLEAR_COMMAND = process.platform === 'win32' ? '\x1B[2J\x1B[0f' : '\x1B[2J\x1B[H'; |
import openBrowserWindow from 'open'; | ||
import path from 'path'; | ||
import { DevServerConfig } from './config/DevServerConfig'; | ||
import { DevServerConfig } from './config/DevServerConfig.js'; | ||
@@ -5,0 +5,0 @@ function isValidURL(str: string) { |
@@ -6,3 +6,3 @@ function requirePlugin() { | ||
} catch (error) { | ||
if (error.code === 'MODULE_NOT_FOUND') { | ||
if ((error as NodeJS.ErrnoException).code === 'MODULE_NOT_FOUND') { | ||
throw new Error( | ||
@@ -9,0 +9,0 @@ 'You need to add @web/dev-server-esbuild as a dependency of your project to use the esbuild flags.', |
@@ -22,2 +22,5 @@ import { nodeResolve, rollupAdapter, RollupNodeResolveOptions } from '@web/dev-server-rollup'; | ||
// use user config exportConditions if present. otherwise use ['development'] | ||
options.exportConditions = userOptionsObject.exportConditions || ['development']; | ||
return rollupAdapter( | ||
@@ -24,0 +27,0 @@ nodeResolve(options), |
import { DevServer } from '@web/dev-server-core'; | ||
import { DevServerConfig } from './config/DevServerConfig'; | ||
import { mergeConfigs } from './config/mergeConfigs'; | ||
import { parseConfig } from './config/parseConfig'; | ||
import { readCliArgs } from './config/readCliArgs'; | ||
import { readFileConfig } from './config/readFileConfig'; | ||
import { DevServerStartError } from './DevServerStartError'; | ||
import { createLogger } from './logger/createLogger'; | ||
import { openBrowser } from './openBrowser'; | ||
import { DevServerConfig } from './config/DevServerConfig.js'; | ||
import { mergeConfigs } from './config/mergeConfigs.js'; | ||
import { parseConfig } from './config/parseConfig.js'; | ||
import { readCliArgs } from './config/readCliArgs.js'; | ||
import { readFileConfig } from './config/readFileConfig.js'; | ||
import { DevServerStartError } from './DevServerStartError.js'; | ||
import { createLogger } from './logger/createLogger.js'; | ||
import { openBrowser } from './openBrowser.js'; | ||
@@ -11,0 +11,0 @@ export interface StartDevServerParams { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Yes
NaN74341
-4.8%1271
-5.71%+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed