Adds package sizes to build scripts
This commit is contained in:
parent
f7971d5c6f
commit
7808d6b75e
4 changed files with 38 additions and 10 deletions
|
@ -1,6 +1,7 @@
|
|||
/* eslint-disable */
|
||||
const fs = require('fs')
|
||||
const esbuild = require('esbuild')
|
||||
const { gzip } = require('zlib')
|
||||
|
||||
const name = process.env.npm_package_name || ''
|
||||
|
||||
|
@ -27,7 +28,7 @@ async function main() {
|
|||
external: ['react', 'react-dom'],
|
||||
})
|
||||
|
||||
esbuild.buildSync({
|
||||
const esmResult = esbuild.buildSync({
|
||||
entryPoints: ['./src/index.ts'],
|
||||
outdir: 'dist/esm',
|
||||
minify: true,
|
||||
|
@ -38,9 +39,23 @@ async function main() {
|
|||
jsxFactory: 'React.createElement',
|
||||
jsxFragment: 'React.Fragment',
|
||||
external: ['react', 'react-dom'],
|
||||
metafile: true,
|
||||
})
|
||||
|
||||
console.log(`✔ ${name}: Built package.`)
|
||||
let esmSize = 0
|
||||
Object.values(esmResult.metafile.outputs).forEach((output) => {
|
||||
esmSize += output.bytes
|
||||
})
|
||||
|
||||
fs.readFile('./dist/esm/index.js', (_err, data) => {
|
||||
gzip(data, (_err, result) => {
|
||||
console.log(
|
||||
`✔ ${name}: Built package. ${(esmSize / 1000).toFixed(2)}kb (${(
|
||||
result.length / 1000
|
||||
).toFixed(2)}kb minified)`
|
||||
)
|
||||
})
|
||||
})
|
||||
} catch (e) {
|
||||
console.log(`× ${name}: Build failed due to an error.`)
|
||||
console.log(e)
|
||||
|
|
|
@ -57,8 +57,6 @@ async function main() {
|
|||
)
|
||||
})
|
||||
})
|
||||
|
||||
console.log(`✔ ${name}: Built package.`)
|
||||
} catch (e) {
|
||||
console.log(`× ${name}: Build failed due to an error.`)
|
||||
console.log(e)
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
/* eslint-disable */
|
||||
const fs = require('fs')
|
||||
const esbuild = require('esbuild')
|
||||
const { gzip } = require('zlib')
|
||||
|
||||
const name = process.env.npm_package_name || ''
|
||||
|
||||
|
@ -28,7 +29,7 @@ async function main() {
|
|||
external: ['react', 'react-dom'],
|
||||
})
|
||||
|
||||
esbuild.buildSync({
|
||||
const esmResult = esbuild.buildSync({
|
||||
entryPoints: ['./src/index.ts'],
|
||||
outdir: 'dist/esm',
|
||||
minify: true,
|
||||
|
@ -40,9 +41,23 @@ async function main() {
|
|||
jsxFactory: 'React.createElement',
|
||||
jsxFragment: 'React.Fragment',
|
||||
external: ['react', 'react-dom'],
|
||||
metafile: true,
|
||||
})
|
||||
|
||||
console.log(`✔ ${name}: Built package.`)
|
||||
let esmSize = 0
|
||||
Object.values(esmResult.metafile.outputs).forEach((output) => {
|
||||
esmSize += output.bytes
|
||||
})
|
||||
|
||||
fs.readFile('./dist/esm/index.js', (_err, data) => {
|
||||
gzip(data, (_err, result) => {
|
||||
console.log(
|
||||
`✔ ${name}: Built package. ${(esmSize / 1000).toFixed(2)}kb (${(
|
||||
result.length / 1000
|
||||
).toFixed(2)}kb minified)`
|
||||
)
|
||||
})
|
||||
})
|
||||
} catch (e) {
|
||||
console.log(`× ${name}: Build failed due to an error.`)
|
||||
console.log(e)
|
||||
|
|
|
@ -4,10 +4,10 @@
|
|||
"exclude": ["node_modules", "**/*.test.ts", "**/*.spec.ts"],
|
||||
"files": [],
|
||||
"references": [
|
||||
{ "path": "./packages/vec" },
|
||||
{ "path": "./packages/intersect" },
|
||||
{ "path": "./packages/tldraw" },
|
||||
{ "path": "./packages/core" }
|
||||
{ "path": "./packages/vec/src" },
|
||||
{ "path": "./packages/intersect/src" },
|
||||
{ "path": "./packages/tldraw/src" },
|
||||
{ "path": "./packages/core/src" }
|
||||
],
|
||||
"compilerOptions": {
|
||||
"baseUrl": ".",
|
||||
|
|
Loading…
Reference in a new issue