Tweak build script

master
Jordan Pittman 2023-10-27 11:27:26 -04:00
parent df8857be2f
commit 3df69994c4
4 changed files with 74 additions and 29 deletions

38
package-lock.json generated
View File

@ -2491,6 +2491,28 @@
"@esbuild/win32-x64": "0.19.5"
}
},
"node_modules/esbuild-node-externals": {
"version": "1.9.0",
"resolved": "https://registry.npmjs.org/esbuild-node-externals/-/esbuild-node-externals-1.9.0.tgz",
"integrity": "sha512-WV6Ogvl+AZEX3vWAM0UGxqb08l3M73EUeymizKGccUC0iWlF1CwdpkZVu200bSqONamjSV0v22vf4YBahJXs8g==",
"dev": true,
"dependencies": {
"find-up": "^5.0.0",
"tslib": "^2.4.1"
},
"engines": {
"node": ">=12"
},
"peerDependencies": {
"esbuild": "0.12 - 0.19"
}
},
"node_modules/esbuild-node-externals/node_modules/tslib": {
"version": "2.6.2",
"resolved": "https://registry.npmjs.org/tslib/-/tslib-2.6.2.tgz",
"integrity": "sha512-AEYxH93jGFPn/a2iVAwW87VuUIkR1FVUKB77NwMF7nBTDkDrrT/Hpt/IrCJ0QXhW27jTBDcf5ZY7w6RiqTMw2Q==",
"dev": true
},
"node_modules/esbuild/node_modules/@esbuild/android-arm": {
"version": "0.19.5",
"resolved": "https://registry.npmjs.org/@esbuild/android-arm/-/android-arm-0.19.5.tgz",
@ -7632,9 +7654,10 @@
},
"devDependencies": {
"esbuild": "^0.19.5",
"esbuild-node-externals": "^1.9.0",
"prettier": "2.3.0",
"tslib": "2.2.0",
"typescript": "4.6.4"
"typescript": "^5.2"
}
},
"packages/tailwindcss-language-service/node_modules/lru-cache": {
@ -7662,6 +7685,19 @@
"node": ">=10"
}
},
"packages/tailwindcss-language-service/node_modules/typescript": {
"version": "5.2.2",
"resolved": "https://registry.npmjs.org/typescript/-/typescript-5.2.2.tgz",
"integrity": "sha512-mI4WrpHsbCIcwT9cF4FZvr80QUeKvsUsUvKDoR+X/7XHQH98xYD8YHZg7ANtz2GtZt/CBq2QJ0thkGJMHfqc1w==",
"dev": true,
"bin": {
"tsc": "bin/tsc",
"tsserver": "bin/tsserver"
},
"engines": {
"node": ">=14.17"
}
},
"packages/vscode-tailwindcss": {
"version": "0.10.1",
"license": "MIT",

View File

@ -40,8 +40,9 @@
},
"devDependencies": {
"esbuild": "^0.19.5",
"esbuild-node-externals": "^1.9.0",
"prettier": "2.3.0",
"tslib": "2.2.0",
"typescript": "4.6.4"
"typescript": "^5.2"
}
}

View File

@ -1,6 +1,8 @@
import esbuild from 'esbuild'
import path from 'node:path'
import { spawnSync } from 'node:child_process'
import esbuild from 'esbuild'
import minimist from 'minimist'
import { nodeExternalsPlugin } from 'esbuild-node-externals'
const __dirname = new URL('.', import.meta.url).pathname
@ -9,37 +11,43 @@ const args = minimist(process.argv.slice(2), {
})
console.log('- Preparing')
let builds = await Promise.all([
esbuild.context({
entryPoints: [path.resolve(__dirname, '../src/index.ts')],
bundle: true,
platform: 'node',
external: [],
outdir: 'dist',
minify: args.minify,
let build = await esbuild.context({
entryPoints: [path.resolve(__dirname, '../src/index.ts')],
bundle: true,
platform: 'node',
external: [],
outdir: 'dist',
minify: args.minify,
format: 'cjs',
}),
format: 'esm',
esbuild.context({
entryPoints: [path.resolve(__dirname, '../src/index.ts')],
bundle: true,
platform: 'node',
external: [],
outdir: 'dist',
minify: args.minify,
format: 'esm',
}),
])
plugins: [
nodeExternalsPlugin(),
{
name: 'generate-types',
async setup(build) {
build.onEnd(async (result) => {
// Call the tsc command to generate the types
spawnSync(
'tsc',
['--emitDeclarationOnly', '--outDir', path.resolve(__dirname, '../dist')],
{
stdio: 'inherit',
}
)
})
},
},
],
})
console.log('- Building')
await Promise.all(builds.map((build) => build.rebuild()))
await build.rebuild()
if (args.watch) {
console.log('- Watching')
await Promise.all(builds.map((build) => build.watch()))
await build.watch()
} else {
console.log('- Cleaning up')
await Promise.all(builds.map((build) => build.dispose()))
await build.dispose()
}

View File

@ -1,7 +1,7 @@
{
"include": ["src", "../../types"],
"compilerOptions": {
"module": "esnext",
"module": "NodeNext",
"lib": ["ES2020"],
"target": "ES2020",
"importHelpers": true,
@ -13,7 +13,7 @@
"noUnusedParameters": false,
"noImplicitReturns": true,
"noFallthroughCasesInSwitch": true,
"moduleResolution": "node",
"moduleResolution": "NodeNext",
"jsx": "react",
"esModuleInterop": true
}