diff --git a/src/createRollupConfig.ts b/src/createRollupConfig.ts index eedc7dd5b..c1b08f70d 100644 --- a/src/createRollupConfig.ts +++ b/src/createRollupConfig.ts @@ -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, @@ -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' : '', diff --git a/src/index.ts b/src/index.ts index dc907ed69..ab1c2ff72 100755 --- a/src/index.ts +++ b/src/index.ts @@ -293,7 +293,7 @@ prog opts.name = opts.name || appPackageJson.name; 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; @@ -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 {