Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

EnsurecorePlugins order is consistent #5928

Merged
merged 2 commits into from
Oct 29, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
ensure corePlugins order is consistent
  • Loading branch information
RobinMalfait committed Oct 29, 2021
commit 874db1eb7d5d122f3c0d8bd0f3331829422cae4d
15 changes: 9 additions & 6 deletions src/util/resolveConfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -238,12 +238,15 @@ function resolveVariants([firstConfig, ...variantConfigs], variantOrder) {
}

function resolveCorePlugins(corePluginConfigs) {
const result = [...corePluginConfigs].reduceRight((resolved, corePluginConfig) => {
if (isFunction(corePluginConfig)) {
return corePluginConfig({ corePlugins: resolved })
}
return configurePlugins(corePluginConfig, resolved)
}, corePluginList)
const result = [...corePluginConfigs]
.reduceRight((resolved, corePluginConfig) => {
if (isFunction(corePluginConfig)) {
return corePluginConfig({ corePlugins: resolved })
}
return configurePlugins(corePluginConfig, resolved)
}, corePluginList)
.slice()
.sort((a, z) => Math.sign(corePluginList.indexOf(a) - corePluginList.indexOf(z)))

return result
}
Expand Down
32 changes: 32 additions & 0 deletions tests/corePlugins.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import postcss from 'postcss'
import tailwind from '../src/index'

function run(input, config = {}) {
return postcss([tailwind(config)]).process(input, { from: undefined })
}

it('should not change the order of the plugins based on corePlugins in config', async () => {
let config1 = {
purge: {
enabled: true,
content: [{ raw: `<div class="transform translate-x-full"></div>` }],
},
corePlugins: ['translate', 'transform'],
}
let config2 = {
purge: {
enabled: true,
content: [{ raw: `<div class="transform translate-x-full"></div>` }],
},
corePlugins: ['transform', 'translate'],
}

let input = `
@tailwind base;
@tailwind components;
@tailwind utilities;
`

let [first, second] = await Promise.all([run(input, config1), run(input, config2)])
expect(first.css).toMatchFormattedCss(second.css)
})