Skip to content

Commit

Permalink
Use .cjs extension instead of package.json for CJS export
Browse files Browse the repository at this point in the history
  • Loading branch information
EvanHahn committed Mar 26, 2023
1 parent e2ef9d8 commit dfb2ee7
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 10 deletions.
3 changes: 1 addition & 2 deletions .npmignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
!README.md
!SECURITY.md

!dist/cjs/cjs.js
!dist/cjs/package.json
!dist/cjs/cjs.cjs
!dist/esm/esm.js
!dist/**/*.d.ts
7 changes: 1 addition & 6 deletions bin/build-helmet.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const esmDistPath = path.join(esmDistDir, "esm.js");
const esmTypesTempPath = path.join(esmDistDir, "tmp-esm-index.d.ts");
const esmTypesDistPath = path.join(esmDistDir, "esm.d.ts");
const commonJsDistDir = path.join(distPath, "cjs");
const commonJsDistPath = path.join(commonJsDistDir, "cjs.js");
const commonJsDistPath = path.join(commonJsDistDir, "cjs.cjs");
const commonJsTypesTempPath = path.join(
commonJsDistDir,
"tmp-commonjs-index.d.ts"
Expand Down Expand Up @@ -48,11 +48,6 @@ const compileCommonjs = () =>
}
);

await fs.writeFile(
path.join(commonJsDistDir, "package.json"),
JSON.stringify({ type: "commonjs" })
);

await fs.rename(commonJsTypesTempPath, commonJsTypesDistPath);
});

Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,13 +56,13 @@
},
"license": "MIT",
"type": "module",
"main": "./dist/cjs/cjs.js",
"main": "./dist/cjs/cjs.cjs",
"module": "./dist/esm/esm.js",
"types": "./dist/esm/esm.d.ts",
"exports": {
".": {
"import": "./dist/esm/esm.js",
"require": "./dist/cjs/cjs.js",
"require": "./dist/cjs/cjs.cjs",
"types": "./dist/esm/esm.d.ts"
}
}
Expand Down

0 comments on commit dfb2ee7

Please sign in to comment.