Skip to content

Commit 85536c5

Browse files
committed
add option to handle build directory structure of packages with bundles
1 parent ffe29a2 commit 85536c5

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

rollup/npmHelpers.js

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import { makeNodeResolvePlugin, makeSucrasePlugin } from './plugins/index.js';
1212
const packageDotJSON = require(path.resolve(process.cwd(), './package.json'));
1313

1414
export function makeBaseNPMConfig(options = {}) {
15-
const { entrypoints = ['src/index.ts'] } = options;
15+
const { entrypoints = ['src/index.ts'], hasBundles = false } = options;
1616

1717
const nodeResolvePlugin = makeNodeResolvePlugin();
1818
const sucrasePlugin = makeSucrasePlugin();
@@ -21,6 +21,9 @@ export function makeBaseNPMConfig(options = {}) {
2121
input: entrypoints,
2222

2323
output: {
24+
// an appropriately-named directory will be added to this base value when we specify either a cjs or esm build
25+
dir: hasBundles ? 'build/npm' : 'build',
26+
2427
sourcemap: true,
2528

2629
// output individual files rather than one big bundle
@@ -62,8 +65,8 @@ export function makeBaseNPMConfig(options = {}) {
6265

6366
export function makeNPMConfigVariants(baseConfig) {
6467
const variantSpecificConfigs = [
65-
{ output: { format: 'cjs', dir: 'build/cjs' } },
66-
{ output: { format: 'esm', dir: 'build/esm' } },
68+
{ output: { format: 'cjs', dir: path.join(baseConfig.output.dir, 'cjs') } },
69+
{ output: { format: 'esm', dir: path.join(baseConfig.output.dir, 'esm') } },
6770
];
6871

6972
return variantSpecificConfigs.map(variant => deepMerge(baseConfig, variant));

0 commit comments

Comments
 (0)