Skip to content

Commit

Permalink
fix logging
Browse files Browse the repository at this point in the history
  • Loading branch information
FredKSchott committed Sep 12, 2020
1 parent c7da5f9 commit 384d9a6
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 18,973 deletions.
6 changes: 5 additions & 1 deletion esmpkg/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import {rollupPluginNodeProcessPolyfill} from './rollup-plugins/rollup-plugin-no
import {rollupPluginDependencyStats} from './rollup-plugins/rollup-plugin-stats';
import {rollupPluginStripSourceMapping} from './rollup-plugins/rollup-plugin-strip-source-mapping';
import {rollupPluginWrapInstallTargets} from './rollup-plugins/rollup-plugin-wrap-install-targets';
import {DependencyStatsOutput, EnvVarReplacements, ImportMap, InstallTarget} from './types';
import {DependencyStatsOutput, EnvVarReplacements, ImportMap, InstallTarget, LoggerLevel} from './types';
import {
createInstallTarget,
findMatchingAliasEntry,
Expand Down Expand Up @@ -190,6 +190,7 @@ function resolveWebDependency(dep: string): DependencyLoc {
interface InstallOptions {
alias: Record<string, string>;
lockfile?: ImportMap;
logLevel: LoggerLevel;
verbose?: boolean;
dest: string;
env: EnvVarReplacements;
Expand Down Expand Up @@ -221,6 +222,7 @@ const EMPTY_INSTALL_RETURN: InstallResult = {
function setOptionDefaults(_options: PublicInstallOptions): InstallOptions {
const options = {
alias: {},
logLevel: 'info' as LoggerLevel,
dest: 'web_modules',
externalPackage: [],
polyfillNode: false,
Expand All @@ -243,6 +245,7 @@ export async function install(
const {
alias: installAlias,
lockfile,
logLevel,
dest: destLoc,
namedExports,
externalPackage: externalPackages,
Expand All @@ -252,6 +255,7 @@ export async function install(
treeshake: isTreeshake,
polyfillNode,
} = setOptionDefaults(_options);
logger.level = logLevel;

const installTargets: InstallTarget[] = _installTargets.map((t) =>
typeof t === 'string' ? createInstallTarget(t) : t,
Expand Down
47 changes: 0 additions & 47 deletions esmpkg/src/types.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
import {PluginHooks, OutputPluginValueHooks} from 'rollup';

export interface Plugin extends Partial<PluginHooks>, Partial<OutputPluginValueHooks> {
name: string;
}
export type DeepPartial<T> = {
[P in keyof T]?: T[P] extends Array<infer U>
? Array<DeepPartial<U>>
Expand All @@ -13,48 +8,6 @@ export type DeepPartial<T> = {

export type EnvVarReplacements = Record<string, string | number | true>;

export type SnowpackBuiltFile = {code: string | Buffer; map?: string};
export type SnowpackBuildMap = Record<string, SnowpackBuiltFile>;

/** Standard file interface */
export interface SnowpackSourceFile<Type = string | Buffer> {
/** base extension (e.g. `.js`) */
baseExt: string;
/** file contents */
contents: Type;
/** expanded extension (e.g. `.proxy.js` or `.module.css`) */
expandedExt: string;
/** if no location on disk, assume this exists in memory */
locOnDisk: string;
}

export interface PluginLoadOptions {
filePath: string;
fileExt: string;
isDev: boolean;
isHmrEnabled: boolean;
}

export interface PluginTransformOptions {
id: string;
fileExt: string;
contents: string | Buffer;
isDev: boolean;
isHmrEnabled: boolean;
}

export interface PluginRunOptions {
isDev: boolean;
isHmrEnabled: boolean;
}

/** map of extensions -> code (e.g. { ".js": "[code]", ".css": "[code]" }) */
export type PluginLoadResult = string | SnowpackBuildMap;

export interface PluginOptimizeOptions {
buildDirectory: string;
}

export interface ImportMap {
imports: {[packageName: string]: string};
}
Expand Down
1 change: 1 addition & 0 deletions snowpack/src/commands/install.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ export async function run({
const finalResult = await install(installTargets, {
lockfile: newLockfile || undefined,
alias: config.alias,
logLevel: logger.level,
...config.installOptions,
}).catch((err) => {
if (err.loc) {
Expand Down
Loading

0 comments on commit 384d9a6

Please sign in to comment.