a95b581e07
* Changed Wardlt use back to Tldraw. Added some VS Code marketplace categories * Missed removing one Wardlt mention * Initial support for esbuild based vscode extension workflow. * Hacky start of vs code extension build script * Fixed categories of extension * Added script for generating VS Code extension installer * Temp fix for file format change affecting VS Code extension * Temp fix for file format change issue * Cleanup, prevent changes from saving pagestates * Remove logic around saving pageState * standardize capitalization * v0.1.8 * Edit readme, scripts * Update .eslintignore * v0.1.9 * v0.1.10 * cleans up build scripts, adds publishing notes * Added VS Code extension implementation references links. start:vscode now auto opens the extension folder in VS Code * Removed step from VS Code README to manually open the extensions folder * Removed file * v0.1.11 * v0.1.12 * Fix empty file * v0.1.13 * README cleanup * v0.1.14 * Update TLDrawEditorProvider.ts * v0.1.15 * Fix types for file extension (sort of) build script for extension Co-authored-by: Steve Ruiz <steveruizok@gmail.com>
53 lines
1.3 KiB
JavaScript
53 lines
1.3 KiB
JavaScript
/* eslint-disable */
|
||
const fs = require('fs')
|
||
const esbuild = require('esbuild')
|
||
const { gzip } = require('zlib')
|
||
const pkg = require('../package.json')
|
||
|
||
async function main() {
|
||
if (fs.existsSync('./dist')) {
|
||
fs.rmSync('./dist', { recursive: true }, (e) => {
|
||
if (e) {
|
||
throw e
|
||
}
|
||
})
|
||
}
|
||
|
||
try {
|
||
const esmResult = esbuild.buildSync({
|
||
entryPoints: ['./src/extension.ts'],
|
||
outdir: 'dist/web',
|
||
minify: true,
|
||
bundle: true,
|
||
format: 'cjs',
|
||
target: 'es6',
|
||
define: {
|
||
'process.env.NODE_ENV': '"production"',
|
||
},
|
||
tsconfig: './tsconfig.json',
|
||
external: Object.keys(pkg.dependencies).concat(Object.keys(pkg.peerDependencies)).concat(["vscode"]),
|
||
metafile: true,
|
||
|
||
})
|
||
|
||
let esmSize = 0
|
||
Object.values(esmResult.metafile.outputs).forEach((output) => {
|
||
esmSize += output.bytes
|
||
})
|
||
|
||
fs.readFile('./dist/web/index.js', (_err, data) => {
|
||
gzip(data, (_err, result) => {
|
||
console.log(
|
||
`✔ ${pkg.name}: Built pkg. ${(esmSize / 1000).toFixed(2)}kb (${(
|
||
result.length / 1000
|
||
).toFixed(2)}kb minified)`
|
||
)
|
||
})
|
||
})
|
||
} catch (e) {
|
||
console.log(`× ${pkg.name}: Build failed due to an error.`)
|
||
console.log(e)
|
||
}
|
||
}
|
||
|
||
main()
|