Skip to content

Commit

Permalink
fix(web): optimized rollup output logic
Browse files Browse the repository at this point in the history
ISSUES CLOSED: #8475
ISSUES CLOSED: #8505
  • Loading branch information
xiejay97 committed Apr 22, 2022
1 parent ebc3e64 commit 9d66981
Showing 1 changed file with 20 additions and 3 deletions.
23 changes: 20 additions & 3 deletions packages/web/src/executors/rollup/rollup.impl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -305,9 +305,26 @@ function updatePackageJson(
/\.[jt]sx?$/,
'.d.ts'
);
packageJson.main = entryFileTmpl.replace('<%= extension %>', 'umd');
packageJson.module = entryFileTmpl.replace('<%= extension %>', 'esm');
packageJson.typings = `./${typingsFile}`;

// Update main field
if (!packageJson.main) {
if (options.format.includes('cjs')) {
packageJson.main = entryFileTmpl.replace('<%= extension %>', 'cjs');
} else if (options.format.includes('umd')) {
packageJson.main = entryFileTmpl.replace('<%= extension %>', 'umd');
}
}

// Update module field
if (!packageJson.module && options.format.includes('esm')) {
packageJson.module = entryFileTmpl.replace('<%= extension %>', 'esm');
}

// Update typings field
if (!packageJson.typings) {
packageJson.typings = `./${typingsFile}`;
}

writeJsonFile(`${options.outputPath}/package.json`, packageJson);

if (
Expand Down

0 comments on commit 9d66981

Please sign in to comment.