Skip to content

Commit

Permalink
fix: dts bundle
Browse files Browse the repository at this point in the history
  • Loading branch information
egoist committed May 13, 2020
1 parent 18e618e commit e4961d6
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
8 changes: 6 additions & 2 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,12 @@ export async function createRollupConfigs(files: string[], options: Options) {
plugins: [
hashbangPlugin(),
jsonPlugin(),
resolvePlugin({ bundle: options.bundle, external: options.external }),
commonjsPlugin({
resolvePlugin({
bundle: options.bundle,
external: options.external,
dts,
}),
!dts && commonjsPlugin({
namedExports: {
// commonjs plugin failed to detect named exports for `resolve`, TODO: report this bug
resolve: Object.keys(require('resolve')),
Expand Down
7 changes: 6 additions & 1 deletion src/resolve-plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,16 @@ const joycon = new JoyCon()
export const resolvePlugin = ({
bundle,
external,
dts,
}: {
bundle?: boolean
external?: string[]
dts?: boolean
}): Plugin => {
const nodeResolve = nodeResolvePlugin()
const nodeResolve = nodeResolvePlugin({
mainFields: dts ? ['types'] : ['module', 'main'],
extensions: dts ? ['.d.ts'] : ['.mjs', '.js', '.json', '.node'],
})

return {
...nodeResolve,
Expand Down

0 comments on commit e4961d6

Please sign in to comment.