Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: unjs/unbuild
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v0.8.7
Choose a base ref
...
head repository: unjs/unbuild
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: v0.8.8
Choose a head ref
  • 2 commits
  • 3 files changed
  • 1 contributor

Commits on Aug 11, 2022

  1. Verified

    This commit was signed with the committer’s verified signature.
    ericwyles Eric Wyles
    Copy the full SHA
    aaf8227 View commit details
  2. chore(release): 0.8.8

    pi0 committed Aug 11, 2022
    Copy the full SHA
    f0576bd View commit details
Showing with 19 additions and 4 deletions.
  1. +7 −0 CHANGELOG.md
  2. +1 −1 package.json
  3. +11 −3 src/builder/rollup.ts
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -2,6 +2,13 @@

All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.

### [0.8.8](https://github.com/unjs/unbuild/compare/v0.8.7...v0.8.8) (2022-08-11)


### Bug Fixes

* **rollup:** seperate dynamic chunks from shared chunk names ([aaf8227](https://github.com/unjs/unbuild/commit/aaf8227692f5c11b93ed034d5528fb69f255601f))

### [0.8.7](https://github.com/unjs/unbuild/compare/v0.8.6...v0.8.7) (2022-08-10)


2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "unbuild",
"version": "0.8.7",
"version": "0.8.8",
"description": "A unified javascript build system",
"repository": "unjs/unbuild",
"license": "MIT",
14 changes: 11 additions & 3 deletions src/builder/rollup.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { writeFile, mkdir } from 'fs/promises'
import { promises as fsp } from 'fs'
import { pathToFileURL } from 'url'
import type { RollupOptions, OutputOptions, OutputChunk } from 'rollup'
import type { RollupOptions, OutputOptions, OutputChunk, PreRenderedChunk } from 'rollup'
import { rollup } from 'rollup'
import commonjs from '@rollup/plugin-commonjs'
import { nodeResolve } from '@rollup/plugin-node-resolve'
@@ -130,6 +130,14 @@ export async function rollupBuild (ctx: BuildContext) {
}

export function getRollupOptions (ctx: BuildContext): RollupOptions {
const getChunkFilename = (chunk: PreRenderedChunk, ext: string) => {
if (chunk.isDynamicEntry) {
return `chunks/[name].${ext}`
}
// TODO: Find a way to generate human friendly hash for short groups
return `shared/${ctx.options.name}.[hash].${ext}`
}

return {
context: ctx.options.rootDir,

@@ -142,7 +150,7 @@ export function getRollupOptions (ctx: BuildContext): RollupOptions {
ctx.options.rollup.emitCJS && {
dir: resolve(ctx.options.rootDir, ctx.options.outDir),
entryFileNames: '[name].cjs',
chunkFileNames: `${ctx.options.name}.[hash].cjs`,
chunkFileNames: (chunk: PreRenderedChunk) => getChunkFilename(chunk, 'cjs'),
format: 'cjs',
exports: 'auto',
preferConst: true,
@@ -152,7 +160,7 @@ export function getRollupOptions (ctx: BuildContext): RollupOptions {
{
dir: resolve(ctx.options.rootDir, ctx.options.outDir),
entryFileNames: '[name].mjs',
chunkFileNames: `${ctx.options.name}.[hash].mjs`,
chunkFileNames: (chunk: PreRenderedChunk) => getChunkFilename(chunk, 'mjs'),
format: 'esm',
exports: 'auto',
preferConst: true,