Skip to content

Commit

Permalink
update build script to use unbuild
Browse files Browse the repository at this point in the history
  • Loading branch information
YieldRay committed Jun 17, 2024
1 parent d00dd05 commit a225d86
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 13 deletions.
27 changes: 15 additions & 12 deletions build.ts
Original file line number Diff line number Diff line change
@@ -1,25 +1,25 @@
import * as esbuild from 'npm:esbuild'

console.log(
await esbuild.build({
entryPoints: ['src/index.ts'],
bundle: true,
outdir: 'dist',
format: 'esm',
}),
)
import { execSync } from 'node:child_process'

const pkg = JSON.parse(Deno.readTextFileSync('./deno.json'))

try {
Deno.removeSync('./package.json')
console.log('Previous package.json removed.')
} catch { // NOOP
}

const packageJson = {
name: pkg.name,
version: pkg.version,
main: 'dist/index.js',
type: 'module',
exports: {
'.': {
import: './dist/index.mjs',
require: './dist/index.cjs',
},
},
main: './dist/index.cjs',
types: './dist/index.d.ts',
files: ['dist'],
author: 'YieldRay',
license: 'MIT',
Expand All @@ -33,6 +33,9 @@ const packageJson = {
homepage: 'https://github.com/YieldRay/json-rpc-ts#readme',
}

Deno.writeTextFileSync('./package.json', JSON.stringify(packageJson, null, 4))
console.log('New package.json created.')
console.log(packageJson)

Deno.writeTextFileSync('./package.json', JSON.stringify(packageJson, null, 4))
console.log('Building package using unbuild...')
execSync('npx [email protected]', { stdio: ['ignore', 'inherit', 'inherit'] })
2 changes: 1 addition & 1 deletion deno.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
"noImplicitOverride": true
},
"imports": {
"std/": "https://deno.land/std@0.221.0/"
"std/": "https://deno.land/std@0.224.0/"
},
"tasks": {
"lint": "deno lint",
Expand Down
19 changes: 19 additions & 0 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
// This file is redundant for Deno
// But necessary for unbuild, as it indirectly reads this config
// https://docs.deno.com/runtime/manual/advanced/typescript/configuration
{
"compilerOptions": {
"allowJs": true,
"esModuleInterop": true,
"experimentalDecorators": false,
"inlineSourceMap": true,
"isolatedModules": true,
"jsx": "react",
"module": "esnext",
"moduleDetection": "force",
"strict": true,
"target": "esnext",
"useDefineForClassFields": true,
"allowImportingTsExtensions": true
}
}

0 comments on commit a225d86

Please sign in to comment.