Resolve third-party plugins with exports in their package.json (#14775)
This PR fixes an issue when trying to resolve plugins with `exports` in their `package.json`, like `@headlessui/tailwindcss`. The missing `conditionNames` in the enhanced resolver config would cause it to not properly look up the name. ## Test Plan I added a test using the `postcss` setup (the existing plugin tests are inside the CLI setup but the CLI can only ever run in Module JS mode). To ensure the tests are resolving to the right environment (CJS vs MJS), I added logging of the `import.meta.url` value to the resolver code. When run, this was the output:  Co-authored-by: Adam Wathan <adam.wathan@gmail.com>
This commit is contained in:
parent
3f2afaf3d0
commit
35cd2ff1ee
3 changed files with 81 additions and 0 deletions
79
integrations/postcss/plugins.test.ts
Normal file
79
integrations/postcss/plugins.test.ts
Normal file
|
|
@ -0,0 +1,79 @@
|
|||
import { candidate, css, html, js, json, test } from '../utils'
|
||||
|
||||
test(
|
||||
'builds the `@headlessui/tailwindcss` plugin utilities (CJS)',
|
||||
{
|
||||
fs: {
|
||||
'package.json': json`
|
||||
{
|
||||
"type": "commonjs",
|
||||
"dependencies": {
|
||||
"postcss": "^8",
|
||||
"postcss-cli": "^10",
|
||||
"tailwindcss": "workspace:^",
|
||||
"@tailwindcss/postcss": "workspace:^",
|
||||
"@headlessui/tailwindcss": "^0.2.1"
|
||||
}
|
||||
}
|
||||
`,
|
||||
'postcss.config.cjs': js`
|
||||
let tailwindcss = require('@tailwindcss/postcss')
|
||||
module.exports = {
|
||||
plugins: [tailwindcss()],
|
||||
}
|
||||
`,
|
||||
'index.html': html`
|
||||
<div className="ui-open:flex"></div>
|
||||
`,
|
||||
'src/index.css': css`
|
||||
@import 'tailwindcss/theme' theme(reference);
|
||||
@import 'tailwindcss/utilities';
|
||||
@plugin '@headlessui/tailwindcss';
|
||||
`,
|
||||
},
|
||||
},
|
||||
async ({ fs, exec }) => {
|
||||
await exec('pnpm postcss src/index.css --output dist/out.css')
|
||||
|
||||
await fs.expectFileToContain('dist/out.css', [candidate`ui-open:flex`])
|
||||
},
|
||||
)
|
||||
|
||||
test(
|
||||
'builds the `@headlessui/tailwindcss` plugin utilities (ESM)',
|
||||
{
|
||||
fs: {
|
||||
'package.json': json`
|
||||
{
|
||||
"type": "module",
|
||||
"dependencies": {
|
||||
"postcss": "^8",
|
||||
"postcss-cli": "^10",
|
||||
"tailwindcss": "workspace:^",
|
||||
"@tailwindcss/postcss": "workspace:^",
|
||||
"@headlessui/tailwindcss": "^0.2.1"
|
||||
}
|
||||
}
|
||||
`,
|
||||
'postcss.config.mjs': js`
|
||||
import tailwindcss from '@tailwindcss/postcss'
|
||||
export default {
|
||||
plugins: [tailwindcss()],
|
||||
}
|
||||
`,
|
||||
'index.html': html`
|
||||
<div className="ui-open:flex"></div>
|
||||
`,
|
||||
'src/index.css': css`
|
||||
@import 'tailwindcss/theme' theme(reference);
|
||||
@import 'tailwindcss/utilities';
|
||||
@plugin '@headlessui/tailwindcss';
|
||||
`,
|
||||
},
|
||||
},
|
||||
async ({ fs, exec }) => {
|
||||
await exec('pnpm postcss src/index.css --output dist/out.css')
|
||||
|
||||
await fs.expectFileToContain('dist/out.css', [candidate`ui-open:flex`])
|
||||
},
|
||||
)
|
||||
Loading…
Add table
Add a link
Reference in a new issue