Skip to content

Commit

Permalink
Use the .mjs file extension for the esm build (#59)
Browse files Browse the repository at this point in the history
* Added exports to package.json

* Use the .mjs file extension for the esm build
  • Loading branch information
Redemption198 authored Dec 30, 2022
1 parent 77b6790 commit 58c5fce
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
4 changes: 2 additions & 2 deletions packages/perfect-freehand/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,12 @@
".": {
"types": "./dist/types/index.d.ts",
"require": "./dist/cjs/index.js",
"import": "./dist/esm/index.js"
"import": "./dist/esm/index.mjs"
}
},
"license": "MIT",
"main": "./dist/cjs/index.js",
"module": "./dist/esm/index.js",
"module": "./dist/esm/index.mjs",
"types": "./dist/types/index.d.ts",
"typings": "./dist/types/index.d.ts",
"scripts": {
Expand Down
3 changes: 2 additions & 1 deletion packages/perfect-freehand/scripts/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,15 @@ async function main() {
target: 'es6',
tsconfig: './tsconfig.build.json',
metafile: true,
outExtension: { '.js': '.mjs' },
})

let esmSize = 0
Object.values(esmResult.metafile.outputs).forEach((output) => {
esmSize += output.bytes
})

fs.readFile('./dist/esm/index.js', (_err, data) => {
fs.readFile('./dist/esm/index.mjs', (_err, data) => {
gzip(data, (_err, result) => {
console.log(
`✔ ${name}: Built package. ${(esmSize / 1000).toFixed(2)}kb (${(
Expand Down

0 comments on commit 58c5fce

Please sign in to comment.