Skip to content

Commit

Permalink
Merge pull request #67 from sdegutis/patch-2
Browse files Browse the repository at this point in the history
Add no-source-maps option
  • Loading branch information
FredKSchott authored Jul 25, 2019
2 parents 073e678 + d28d251 commit 6580c47
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ export interface InstallOptions {
namedExports?: {[filepath: string]: string[]};
remoteUrl?: string;
remotePackages: [string, string][];
noSourceMaps?: boolean;
}

const cwd = process.cwd();
Expand All @@ -45,6 +46,7 @@ function showHelp() {
--clean Clear out the destination directory before install.
--optimize Minify installed dependencies.
--strict Only install pure ESM dependency trees. Fail if a CJS module is encountered.
--no-source-maps Skip emitting source map files (.js.map) into dest
Advanced Options:
--remote-package "name,version" pair(s) signal that a package should be left unbundled and referenced remotely.
Example: With the value "foo,v4" will rewrite all imports of "foo" to "{remoteUrl}/foo/v4" (see --remote-url).
Expand Down Expand Up @@ -143,7 +145,7 @@ function getWebDependencyName(dep: string): string {

export async function install(
arrayOfDeps: string[],
{isCleanInstall, destLoc, skipFailures, isStrict, isOptimized, namedExports, remoteUrl, remotePackages}: InstallOptions,
{isCleanInstall, destLoc, skipFailures, isStrict, isOptimized, noSourceMaps, namedExports, remoteUrl, remotePackages}: InstallOptions,
) {

const knownNamedExports = {...namedExports};
Expand Down Expand Up @@ -256,7 +258,7 @@ export async function install(
const outputOptions = {
dir: destLoc,
format: 'esm' as 'esm',
sourcemap: true,
sourcemap: !noSourceMaps,
exports: 'named' as 'named',
chunkFileNames: 'common/[name]-[hash].js',
};
Expand All @@ -270,7 +272,7 @@ export async function install(
}

export async function cli(args: string[]) {
const {help, optimize = false, strict = false, clean = false, dest = 'web_modules', remoteUrl = 'https://cdn.pika.dev', remotePackage: remotePackages = []} = yargs(args);
const {help, noSourceMaps = false, optimize = false, strict = false, clean = false, dest = 'web_modules', remoteUrl = 'https://cdn.pika.dev', remotePackage: remotePackages = []} = yargs(args);
const destLoc = path.join(cwd, dest);

if (help) {
Expand All @@ -291,6 +293,7 @@ export async function cli(args: string[]) {
skipFailures: !doesWhitelistExist,
isStrict: strict,
isOptimized: optimize,
noSourceMaps,
remoteUrl,
remotePackages: remotePackages.map(p => p.split(',')),
});
Expand Down

0 comments on commit 6580c47

Please sign in to comment.