Skip to content

Commit

Permalink
feat: enable custom packages encapsulation (#92)
Browse files Browse the repository at this point in the history
  • Loading branch information
Jakub Jankowski authored Jul 21, 2021
1 parent 2267049 commit 48c5b1e
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
1 change: 1 addition & 0 deletions src/commands/build/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ export default class BuildCommand extends Command {
'dependenciesMeta',
'pkg',
'type',
'exports',
]);

releasePkg.main = 'index.js';
Expand Down
16 changes: 12 additions & 4 deletions src/commands/bundle/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,15 +47,23 @@ export default class BundleCommand extends BuildCommand {
protected preparePackageJson() {
const pkg = super.preparePackageJson();

const exports = {
require: './index.js',
import: './index.mjs',
};

Object.assign(pkg, {
type: 'commonjs',
main: './index.js',
// webpack v4 support
module: './index.esm.js',
exports: {
require: './index.js',
import: './index.mjs',
},
exports:
'exports' in pkg && typeof pkg.exports === 'object'
? {
...pkg.exports,
'.': exports,
}
: exports,
});

return pkg;
Expand Down

0 comments on commit 48c5b1e

Please sign in to comment.