Skip to content

Commit

Permalink
move env to @tailwindcss/node
Browse files Browse the repository at this point in the history
This allows us to:
1. Not worry about `process` being available, because we are already in
   a node-like environment.
2. Use a proper import from the package
  • Loading branch information
RobinMalfait committed Sep 30, 2024
1 parent d7b856e commit 6017362
Show file tree
Hide file tree
Showing 6 changed files with 8 additions and 7 deletions.
3 changes: 1 addition & 2 deletions packages/@tailwindcss-cli/src/commands/build/index.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
import watcher from '@parcel/watcher'
import { compile } from '@tailwindcss/node'
import { compile, env } from '@tailwindcss/node'
import { clearRequireCache } from '@tailwindcss/node/require-cache'
import { Scanner, type ChangedContent } from '@tailwindcss/oxide'
import { Features, transform } from 'lightningcss'
import { existsSync } from 'node:fs'
import fs from 'node:fs/promises'
import path from 'node:path'
import * as env from '../../../../tailwindcss/src/env'
import type { Arg, Result } from '../../utils/args'
import { Disposables } from '../../utils/disposables'
import {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export const DEBUG = typeof process !== 'undefined' ? resolveDebug(process.env.DEBUG) : false
export const DEBUG = resolveDebug(process.env.DEBUG)

function resolveDebug(debug: typeof process.env.DEBUG) {
if (debug === undefined) {
Expand Down
2 changes: 2 additions & 0 deletions packages/@tailwindcss-node/src/index.cts
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import * as Module from 'node:module'
import { pathToFileURL } from 'node:url'
import * as env from './env'
export * from './compile'
export * from './normalize-path'
export { env }

// In Bun, ESM modules will also populate `require.cache`, so the module hook is
// not necessary.
Expand Down
2 changes: 2 additions & 0 deletions packages/@tailwindcss-node/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import * as Module from 'node:module'
import { pathToFileURL } from 'node:url'
import * as env from './env'
export * from './compile'
export * from './normalize-path'
export { env }

// In Bun, ESM modules will also populate `require.cache`, so the module hook is
// not necessary.
Expand Down
3 changes: 1 addition & 2 deletions packages/@tailwindcss-postcss/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
import { compile } from '@tailwindcss/node'
import { compile, env } from '@tailwindcss/node'
import { clearRequireCache } from '@tailwindcss/node/require-cache'
import { Scanner } from '@tailwindcss/oxide'
import fs from 'fs'
import { Features, transform } from 'lightningcss'
import path from 'path'
import postcss, { type AcceptedPlugin, type PluginCreator } from 'postcss'
import * as env from '../../tailwindcss/src/env'
import fixRelativePathsPlugin from './postcss-fix-relative-paths'

/**
Expand Down
3 changes: 1 addition & 2 deletions packages/@tailwindcss-vite/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
import { compile, normalizePath } from '@tailwindcss/node'
import { compile, env, normalizePath } from '@tailwindcss/node'
import { clearRequireCache } from '@tailwindcss/node/require-cache'
import { Scanner } from '@tailwindcss/oxide'
import { Features, transform } from 'lightningcss'
import path from 'path'
import type { Plugin, ResolvedConfig, Rollup, Update, ViteDevServer } from 'vite'
import * as env from '../../tailwindcss/src/env'

export default function tailwindcss(): Plugin[] {
let servers: ViteDevServer[] = []
Expand Down

0 comments on commit 6017362

Please sign in to comment.