From c74fa2dd7cf2140ae728af4775fdea2219e1f670 Mon Sep 17 00:00:00 2001 From: Chen Gang Date: Fri, 28 Aug 2020 08:16:23 +0800 Subject: [PATCH] clean unnecessary code --- snowpack/src/build/build-pipeline.ts | 5 ++++- snowpack/src/commands/build.ts | 3 --- snowpack/src/commands/install.ts | 4 ---- 3 files changed, 4 insertions(+), 8 deletions(-) diff --git a/snowpack/src/build/build-pipeline.ts b/snowpack/src/build/build-pipeline.ts index f052b333fd..11da563ec4 100644 --- a/snowpack/src/build/build-pipeline.ts +++ b/snowpack/src/build/build-pipeline.ts @@ -122,7 +122,7 @@ async function runPipelineTransformStep( try { for (const destExt of Object.keys(output)) { const destBuildFile = output[destExt]; - const {code} = typeof destBuildFile === 'string' ? {code: destBuildFile} : destBuildFile; + const {code} = destBuildFile; const fileName = rootFileName + destExt; const filePath = rootFilePath + destExt; const debugPath = path.relative(process.cwd(), filePath); @@ -141,9 +141,12 @@ async function runPipelineTransformStep( // if step returned a value, only update code (don’t touch .map) if (typeof result === 'string') { output[destExt].code = result; + output[destExt].map = undefined; } else if (result && typeof result === 'object' && (result as {result: string}).result) { output[destExt].code = (result as {result: string}).result; + output[destExt].map = undefined; } + // if source maps disabled, don’t return any if (!sourceMaps) output[destExt].map = undefined; } diff --git a/snowpack/src/commands/build.ts b/snowpack/src/commands/build.ts index b04365c993..ef27db426c 100644 --- a/snowpack/src/commands/build.ts +++ b/snowpack/src/commands/build.ts @@ -292,7 +292,6 @@ export async function command(commandOptions: CommandOptions) { async function installDependencies() { const scannedFiles = Object.values(buildPipelineFiles) .map((f) => Object.values(f.filesToResolve)) - .filter(Boolean) .reduce((flat, item) => flat.concat(item), []); const installDest = path.join(buildDirectoryLoc, config.buildOptions.webModulesUrl); const installResult = await installOptimizedDependencies(scannedFiles, installDest, { @@ -478,6 +477,4 @@ export async function command(commandOptions: CommandOptions) { watcher.on('add', (fileLoc) => onWatchEvent(fileLoc)); watcher.on('change', (fileLoc) => onWatchEvent(fileLoc)); watcher.on('unlink', (fileLoc) => onDeleteEvent(fileLoc)); - - return new Promise(() => {}); } diff --git a/snowpack/src/commands/install.ts b/snowpack/src/commands/install.ts index bcee1fcddf..281bfad30d 100644 --- a/snowpack/src/commands/install.ts +++ b/snowpack/src/commands/install.ts @@ -257,7 +257,6 @@ export async function install( const installEntrypoints: {[targetName: string]: string} = {}; const assetEntrypoints: {[targetName: string]: string} = {}; const importMap: ImportMap = {imports: {}}; - const installTargetsMap: {[targetLoc: string]: InstallTarget[]} = {}; const skipFailures = false; const autoDetectNamedExports = [ ...CJS_PACKAGES_TO_AUTO_DETECT, @@ -283,9 +282,6 @@ export async function install( .forEach(([key]) => { importMap.imports[key] = `./${targetName}.js`; }); - installTargetsMap[targetLoc] = installTargets.filter( - (t) => installSpecifier === t.specifier, - ); installResults.push([installSpecifier, 'SUCCESS']); } else if (targetType === 'ASSET') { assetEntrypoints[targetName] = targetLoc;