Skip to content

Commit 3df6999

Browse files
committed
Tweak build script
1 parent df8857b commit 3df6999

File tree

4 files changed

+76
-31
lines changed

4 files changed

+76
-31
lines changed

package-lock.json

Lines changed: 37 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/tailwindcss-language-service/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,9 @@
4040
},
4141
"devDependencies": {
4242
"esbuild": "^0.19.5",
43+
"esbuild-node-externals": "^1.9.0",
4344
"prettier": "2.3.0",
4445
"tslib": "2.2.0",
45-
"typescript": "4.6.4"
46+
"typescript": "^5.2"
4647
}
4748
}
Lines changed: 35 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
1-
import esbuild from 'esbuild'
21
import path from 'node:path'
2+
import { spawnSync } from 'node:child_process'
3+
import esbuild from 'esbuild'
34
import minimist from 'minimist'
5+
import { nodeExternalsPlugin } from 'esbuild-node-externals'
46

57
const __dirname = new URL('.', import.meta.url).pathname
68

@@ -9,37 +11,43 @@ const args = minimist(process.argv.slice(2), {
911
})
1012

1113
console.log('- Preparing')
12-
let builds = await Promise.all([
13-
esbuild.context({
14-
entryPoints: [path.resolve(__dirname, '../src/index.ts')],
15-
bundle: true,
16-
platform: 'node',
17-
external: [],
18-
outdir: 'dist',
19-
minify: args.minify,
20-
21-
format: 'cjs',
22-
}),
23-
24-
esbuild.context({
25-
entryPoints: [path.resolve(__dirname, '../src/index.ts')],
26-
bundle: true,
27-
platform: 'node',
28-
external: [],
29-
outdir: 'dist',
30-
minify: args.minify,
31-
32-
format: 'esm',
33-
}),
34-
])
14+
let build = await esbuild.context({
15+
entryPoints: [path.resolve(__dirname, '../src/index.ts')],
16+
bundle: true,
17+
platform: 'node',
18+
external: [],
19+
outdir: 'dist',
20+
minify: args.minify,
21+
22+
format: 'esm',
23+
24+
plugins: [
25+
nodeExternalsPlugin(),
26+
{
27+
name: 'generate-types',
28+
async setup(build) {
29+
build.onEnd(async (result) => {
30+
// Call the tsc command to generate the types
31+
spawnSync(
32+
'tsc',
33+
['--emitDeclarationOnly', '--outDir', path.resolve(__dirname, '../dist')],
34+
{
35+
stdio: 'inherit',
36+
}
37+
)
38+
})
39+
},
40+
},
41+
],
42+
})
3543

3644
console.log('- Building')
37-
await Promise.all(builds.map((build) => build.rebuild()))
45+
await build.rebuild()
3846

3947
if (args.watch) {
4048
console.log('- Watching')
41-
await Promise.all(builds.map((build) => build.watch()))
49+
await build.watch()
4250
} else {
4351
console.log('- Cleaning up')
44-
await Promise.all(builds.map((build) => build.dispose()))
52+
await build.dispose()
4553
}

packages/tailwindcss-language-service/tsconfig.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"include": ["src", "../../types"],
33
"compilerOptions": {
4-
"module": "esnext",
4+
"module": "NodeNext",
55
"lib": ["ES2020"],
66
"target": "ES2020",
77
"importHelpers": true,
@@ -13,7 +13,7 @@
1313
"noUnusedParameters": false,
1414
"noImplicitReturns": true,
1515
"noFallthroughCasesInSwitch": true,
16-
"moduleResolution": "node",
16+
"moduleResolution": "NodeNext",
1717
"jsx": "react",
1818
"esModuleInterop": true
1919
}

0 commit comments

Comments
 (0)