chore: run esbuild scripts in sync, hopefully fixing publishing issues (#7159)

We are suspecting that operations within those esbuild scripts are not
awaited properly - potentially causing issues in the publish script,
publishing the next package without any built .js files
This commit is contained in:
Alessio Gravili
2024-07-15 17:31:48 -04:00
committed by GitHub
parent 2925c3bb90
commit 08f50bb441
5 changed files with 93 additions and 117 deletions

View File

@@ -18,9 +18,9 @@ const removeCSSImports = {
},
}
// Bundle only the .scss files into a single css file
await esbuild
.build({
async function build() {
// Bundle only the .scss files into a single css file
await esbuild.build({
entryPoints: ['src/exports/client/index.ts'],
bundle: true,
minify: true,
@@ -30,18 +30,14 @@ await esbuild
//external: ['*.svg'],
plugins: [sassPlugin({ css: 'external' })],
})
.then(() => {
fs.rename('dist/field/index.css', 'dist/exports/client/bundled.css', (err) => {
if (err) console.error(`Error while renaming index.css: ${err}`)
})
console.log('dist/field/bundled.css bundled successfully')
await fs.rename('dist/field/index.css', 'dist/exports/client/bundled.css', (err) => {
if (err) console.error(`Error while renaming index.css: ${err}`)
})
.catch(() => process.exit(1))
// Bundle `client.ts`
const resultClient = await esbuild
.build({
console.log('dist/field/bundled.css bundled successfully')
// Bundle `client.ts`
const resultClient = await esbuild.build({
entryPoints: ['src/exports/client/index.ts'],
bundle: true,
platform: 'browser',
@@ -90,15 +86,14 @@ const resultClient = await esbuild
plugins: [
removeCSSImports,
/*commonjs({
ignore: ['date-fns', '@floating-ui/react'],
}),*/
ignore: ['date-fns', '@floating-ui/react'],
}),*/
],
sourcemap: true,
})
.then((res, err) => {
console.log('client/index.ts bundled successfully')
return res
})
.catch(() => process.exit(1))
console.log('client/index.ts bundled successfully')
fs.writeFileSync('meta_client.json', JSON.stringify(resultClient.metafile))
fs.writeFileSync('meta_client.json', JSON.stringify(resultClient.metafile))
}
await build()