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

Use the new preserveEntrySignatures option recommended for libraries #117

Merged
merged 3 commits into from
Jun 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/neat-turtles-press.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@crackle/core': patch
---

Ensure DTS entries have the same exports as their source files
17 changes: 15 additions & 2 deletions packages/core/src/package-utils/dts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { rollup } from 'rollup';
import dts from 'rollup-plugin-dts';

import type { EnhancedConfig } from '../config';
import { logger } from '../entries/logger';
import { externals } from '../plugins/rollup/externals';
import type { PackageEntryPoint } from '../types';
import { commonOutputOptions } from '../vite-config';
Expand All @@ -21,10 +22,22 @@ export const createDtsBundle = async (
}),
],
onLog(level, log, defaultHandler) {
if (log.code === 'OPTIMIZE_CHUNK_STATUS') return false;
if (log.code === 'EMPTY_BUNDLE') return false;
switch (log.code) {
case 'OPTIMIZE_CHUNK_STATUS':
case 'EMPTY_BUNDLE':
return false;
case 'UNUSED_EXTERNAL_IMPORT':
if (
log.message.startsWith(
'"RefAttributes" is imported from external module "react" but never used in',
)
)
return false;
}
logger.debug(`onLog ${log.code}: ${log.message}`);
defaultHandler(level, log);
},
preserveEntrySignatures: 'strict',
});

await bundle.write({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,18 @@ exports.Box = Box;


/* #region dist/css-more.d.ts */
export { Box, Breakpoint, breakpointNames, breakpoints } from './index.js';
declare const breakpointNames: readonly ["mobile", "tablet", "desktop", "wide"];
declare const breakpoints: {
readonly mobile: 0;
readonly tablet: 740;
readonly desktop: 992;
readonly wide: 1200;
};
type Breakpoint = keyof typeof breakpoints;

declare const Box: () => null;

export { Box, Breakpoint, breakpointNames, breakpoints };
/* #endregion */


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ exports.Box = cssMore.Box;


/* #region dist/css.d.ts */
export { Box } from './index.js';
export { Box } from './css-more.js';
/* #endregion */


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,8 @@ if (process.env.NODE_ENV === "development") {


/* #region dist/index.d.ts */
declare const breakpointNames: readonly ["mobile", "tablet", "desktop", "wide"];
declare const breakpoints: {
readonly mobile: 0;
readonly tablet: 740;
readonly desktop: 992;
readonly wide: 1200;
};
type Breakpoint = keyof typeof breakpoints;

declare const Box: () => null;

export { Box, Breakpoint, breakpointNames, breakpoints };
export { }
/* #endregion */


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ exports.breakpoints = styles_lib_breakpoints_cjs.breakpoints;


/* #region dist/reset.d.ts */
export { Breakpoint, breakpointNames, breakpoints } from './index.js';
export { Breakpoint, breakpointNames, breakpoints } from './css-more.js';
/* #endregion */


Expand Down