Skip to content

Commit 4741780

Browse files
thecrypticaceRobinMalfaitreinink
committed
Fix @tailwindcss/line-clamp warning (#10919)
* WIP * Move warning to validateConfig This only happens in setupTrackingContext outside of resolveConfig * Use original dynamic require approach in `validateConfig` The important thing is that this happens in Node-land only. It is outside of `resolveConfig` which is public and importable into user projects. That is the scenario that breaks because of static import hoisting. * Don’t reference process when it might be undefined The `resolveConfig` dep path is public which should not reference process. However, we have some behavior that changes based on env vars so we need to conditionalize it instead. * Update changelog * Formatting * More formatting * Update changelog --------- Co-authored-by: Robin Malfait <[email protected]> Co-authored-by: Jonathan Reinink <[email protected]>
1 parent 9cd0301 commit 4741780

File tree

3 files changed

+30
-7
lines changed

3 files changed

+30
-7
lines changed

CHANGELOG.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1212
- Try resolving `config.default` before `config` to ensure the config file is resolved correctly ([#10898](https://github.com/tailwindlabs/tailwindcss/pull/10898))
1313
- Pull pseudo elements outside of `:is` and `:has` when using `@apply` ([#10903](https://github.com/tailwindlabs/tailwindcss/pull/10903))
1414
- Update the types for the `safelist` config ([#10901](https://github.com/tailwindlabs/tailwindcss/pull/10901))
15-
- Drop `@tailwindcss/line-clamp` warning ([#10915](https://github.com/tailwindlabs/tailwindcss/pull/10915))
15+
- Fix `@tailwindcss/line-clamp` warning ([#10915](https://github.com/tailwindlabs/tailwindcss/pull/10915), [#10919](https://github.com/tailwindlabs/tailwindcss/pull/10919))
16+
- Fix `process` is not defined error ([#10919](https://github.com/tailwindlabs/tailwindcss/pull/10919))
1617

1718
## [3.3.0] - 2023-03-27
1819

src/lib/sharedState.js

+15-6
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,21 @@
11
import pkg from '../../package.json'
22
let OXIDE_DEFAULT_ENABLED = pkg.tailwindcss.engine === 'oxide'
33

4-
export const env = {
5-
NODE_ENV: process.env.NODE_ENV,
6-
DEBUG: resolveDebug(process.env.DEBUG),
7-
ENGINE: pkg.tailwindcss.engine,
8-
OXIDE: resolveBoolean(process.env.OXIDE, OXIDE_DEFAULT_ENABLED),
9-
}
4+
export const env =
5+
typeof process !== 'undefined'
6+
? {
7+
NODE_ENV: process.env.NODE_ENV,
8+
DEBUG: resolveDebug(process.env.DEBUG),
9+
ENGINE: pkg.tailwindcss.engine,
10+
OXIDE: resolveBoolean(process.env.OXIDE, OXIDE_DEFAULT_ENABLED),
11+
}
12+
: {
13+
NODE_ENV: 'production',
14+
DEBUG: false,
15+
ENGINE: pkg.tailwindcss.engine,
16+
OXIDE: OXIDE_DEFAULT_ENABLED,
17+
}
18+
1019
export const contextMap = new Map()
1120
export const configContextMap = new Map()
1221
export const contextSourcesMap = new Map()

src/util/validateConfig.js

+13
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,18 @@ export function validateConfig(config) {
99
])
1010
}
1111

12+
// Warn if the line-clamp plugin is installed
13+
try {
14+
let plugin = require('@tailwindcss/line-clamp')
15+
if (config.plugins.includes(plugin)) {
16+
log.warn('line-clamp-in-core', [
17+
'As of Tailwind CSS v3.3, the `@tailwindcss/line-clamp` plugin is now included by default.',
18+
'Remove it from the `plugins` array in your configuration to eliminate this warning.',
19+
])
20+
21+
config.plugins = config.plugins.filter((p) => p !== plugin)
22+
}
23+
} catch {}
24+
1225
return config
1326
}

0 commit comments

Comments
 (0)