Skip to content

Commit

Permalink
[dev-tool] Honor exports when bundling. (Azure#26432)
Browse files Browse the repository at this point in the history
This package modifies the bundling logic slightly so that after checking
for a package.json `main` field it will also look at the package.json
`exports["."].require` field.
  • Loading branch information
witemple-msft authored Jul 7, 2023
1 parent cd8e166 commit 4af4923
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
2 changes: 1 addition & 1 deletion common/tools/dev-tool/src/commands/run/bundle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ export default leafCommand(commandInfo, async (options) => {

try {
const bundle = await rollup.rollup(baseConfig);
const cjsOutput = info.packageJson.main;
const cjsOutput = info.packageJson.main ?? info.packageJson.exports?.["."]?.require;
if (!cjsOutput) {
throw new Error("Expecting valid main entry");
}
Expand Down
8 changes: 8 additions & 0 deletions common/tools/dev-tool/src/util/resolveProject.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,14 @@ declare global {
description: string;
main: string;
types: string;
exports?: {
[path: string]: {
import?: string;
require?: string;
types?: string;
[extraTypes: `types@${string}`]: string;
}
},
typesVersions?: {
[k: string]: {
[k: string]: string[];
Expand Down

0 comments on commit 4af4923

Please sign in to comment.