Skip to content

Commit

Permalink
Update to @tailwindcss/language-service
Browse files Browse the repository at this point in the history
  • Loading branch information
remcohaszing committed Jul 30, 2024
1 parent ab338a9 commit e7de5c1
Show file tree
Hide file tree
Showing 6 changed files with 248 additions and 163 deletions.
20 changes: 8 additions & 12 deletions build.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,6 @@ await build({
resolve(path.replace('lib', 'src'), options)
)

// The tailwindcss-language-service main export exports CJS by default, but we get better
// tree shaking if we import the ESM variant.
onResolve({ filter: /^tailwindcss-language-service$/ }, ({ path, ...options }) =>
resolve('tailwindcss-language-service/dist/tailwindcss-language-service.esm.js', options)
)

// This file pulls in a number of dependencies, but we don’t really need it anyway.
onResolve({ filter: /^\.+\/(util\/)?log$/, namespace: 'file' }, ({ path, ...options }) => {
if (options.importer.includes(`${sep}tailwindcss${sep}`)) {
Expand All @@ -69,19 +63,21 @@ await build({
})
})

// The culori main export exports CJS by default, but we get better tree shaking if we
// import the ESM variant.
onResolve({ filter: /^culori$/ }, ({ path, ...options }) =>
resolve('culori/build/culori.js', options)
)

// CJS doesn’t require extensions, but ESM does. Since our package uses ESM, but dependant
// bundled packages don’t, we need to add it ourselves.
onResolve(
{ filter: /^(postcss-selector-parser|semver)\/.*\/\w+$/ },
({ path, ...options }) => resolve(`${path}.js`, options)
)

onResolve({ filter: /^postcss-value-parser$/ }, ({ path, ...options }) =>
resolve('tailwindcss/src/value-parser', options)
)

onResolve({ filter: /^vscode-languageserver$/ }, ({ path, ...options }) =>
resolve('vscode-languageserver-types', options)
)

// Rewrite the tailwind stubs from CJS to ESM, so our bundle doesn’t need to include any CJS
// related logic.
onLoad(
Expand Down
Loading

0 comments on commit e7de5c1

Please sign in to comment.