Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(fix): --name shouldn't change output filenames #669

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions src/createRollupConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,18 @@ import replace from '@rollup/plugin-replace';
import resolve from '@rollup/plugin-node-resolve';
import sourceMaps from 'rollup-plugin-sourcemaps';
import typescript from 'rollup-plugin-typescript2';
import * as fs from 'fs-extra';
import ts from 'typescript';

import { extractErrors } from './errors/extractErrors';
import { babelPluginTsdx } from './babelPluginTsdx';
import { TsdxOptions } from './types';
import { TsdxOptions, PackageJson } from './types';

let appPackageJson: PackageJson;

try {
appPackageJson = fs.readJSONSync(paths.appPackageJson);
} catch (e) {}

const errorCodeOpts = {
errorMapFilePath: paths.appErrorsJson,
Expand All @@ -35,7 +42,7 @@ export async function createRollupConfig(
opts.minify !== undefined ? opts.minify : opts.env === 'production';

const outputName = [
`${paths.appDist}/${safePackageName(opts.name)}`,
`${paths.appDist}/${safePackageName(appPackageJson.name)}`,
opts.format,
opts.env,
shouldMinify ? 'min' : '',
Expand Down
4 changes: 2 additions & 2 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,7 @@ prog
opts.name = opts.name || appPackageJson.name;
agilgur5 marked this conversation as resolved.
Show resolved Hide resolved
opts.input = await getInputs(opts.entry, appPackageJson.source);
if (opts.format.includes('cjs')) {
await writeCjsEntryFile(opts.name);
await writeCjsEntryFile(appPackageJson.name);
}

type Killer = execa.ExecaChildProcess | null;
Expand Down Expand Up @@ -393,7 +393,7 @@ prog
await cleanDistFolder();
const logger = await createProgressEstimator();
if (opts.format.includes('cjs')) {
const promise = writeCjsEntryFile(opts.name).catch(logError);
const promise = writeCjsEntryFile(appPackageJson.name).catch(logError);
logger(promise, 'Creating entry file');
}
try {
Expand Down