Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
3 changes: 3 additions & 0 deletions crates/node/npm/win32-arm64-msvc/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# `@tailwindcss/oxide-win32-arm64-msvc`

This is the **arm64-pc-windows-msvc** binary for `@tailwindcss/oxide`
27 changes: 27 additions & 0 deletions crates/node/npm/win32-arm64-msvc/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{
"name": "@tailwindcss/oxide-win32-arm64-msvc",
"version": "4.0.0-alpha.30",
"repository": {
"type": "git",
"url": "git+https://github.com/tailwindlabs/tailwindcss.git",
"directory": "crates/node/npm/win32-arm64-msvc"
},
"os": [
"win32"
],
"cpu": [
"arm64"
],
"main": "tailwindcss-oxide.win32-arm64-msvc.node",
"files": [
"tailwindcss-oxide.win32-arm64-msvc.node"
],
"publishConfig": {
"provenance": true,
"access": "public"
},
"license": "MIT",
"engines": {
"node": ">= 10"
}
}
6 changes: 4 additions & 2 deletions crates/node/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@
"armv7-unknown-linux-gnueabihf",
"x86_64-unknown-linux-musl",
"x86_64-unknown-freebsd",
"i686-pc-windows-msvc"
"i686-pc-windows-msvc",
"aarch64-pc-windows-msvc"
]
}
},
Expand Down Expand Up @@ -56,6 +57,7 @@
"@tailwindcss/oxide-linux-arm64-musl": "workspace:*",
"@tailwindcss/oxide-linux-x64-gnu": "workspace:*",
"@tailwindcss/oxide-linux-x64-musl": "workspace:*",
"@tailwindcss/oxide-win32-x64-msvc": "workspace:*"
"@tailwindcss/oxide-win32-x64-msvc": "workspace:*",
"@tailwindcss/oxide-win32-arm64-msvc": "workspace:*"
}
}
13 changes: 8 additions & 5 deletions crates/oxide/src/glob.rs
Original file line number Diff line number Diff line change
Expand Up @@ -237,15 +237,18 @@ mod tests {

let optimized_sources = optimize_patterns(&sources);

let parent_dir = format!("{}", fs::canonicalize(base).unwrap().display());
let parent_dir =
format!("{}{}", dunce::canonicalize(base).unwrap().display(), "/").replace('\\', "/");

// Remove the temporary directory from the base
optimized_sources
.into_iter()
.map(|source| GlobEntry {
// Normalize paths to use unix style separators
base: source.base.replace(&parent_dir, "").replace('\\', "/"),
pattern: source.pattern,
.map(|source| {
GlobEntry {
// Normalize paths to use unix style separators
base: source.base.replace('\\', "/").replace(&parent_dir, "/"),
pattern: source.pattern,
}
})
.collect()
}
Expand Down
23 changes: 19 additions & 4 deletions crates/oxide/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ use bstr::ByteSlice;
use fxhash::{FxHashMap, FxHashSet};
use glob::optimize_patterns;
use glob_match::glob_match;
use paths::Path;
use rayon::prelude::*;
use std::fs;
use std::path::PathBuf;
Expand All @@ -18,6 +19,7 @@ pub mod cursor;
pub mod fast_skip;
pub mod glob;
pub mod parser;
pub mod paths;
pub mod scanner;

static SHOULD_TRACE: sync::LazyLock<bool> = sync::LazyLock::new(
Expand Down Expand Up @@ -151,7 +153,8 @@ impl Scanner {

self.files
.iter()
.map(|x| x.to_string_lossy().into())
.filter_map(|x| Path::from(x.clone()).canonicalize().ok())
.map(|x| x.to_string())
.collect()
}

Expand Down Expand Up @@ -257,9 +260,18 @@ impl Scanner {
false
});

fn join_paths(a: &str, b: &str) -> PathBuf {
let mut tmp = a.to_owned();

tmp += "/";
tmp += b.trim_end_matches("**/*").trim_end_matches('/');

PathBuf::from(&tmp)
}

for path in auto_sources
.iter()
.map(|source| PathBuf::from(&source.base).join(source.pattern.trim_end_matches("**/*")))
.map(|source| join_paths(&source.base, &source.pattern))
{
// Insert a glob for the base path, so we can see new files/folders in the directory itself.
self.globs.push(GlobEntry {
Expand Down Expand Up @@ -292,7 +304,8 @@ impl Scanner {
// match as well.
//
// Instead we combine the base and the pattern as a single glob pattern.
let mut full_pattern = source.base.clone();
let mut full_pattern = source.base.clone().replace('\\', "/");

if !source.pattern.is_empty() {
full_pattern.push('/');
full_pattern.push_str(&source.pattern);
Expand All @@ -314,7 +327,9 @@ impl Scanner {
continue;
};

if glob_match(&full_pattern, file_path_str) {
let file_path_str = file_path_str.replace('\\', "/");

if glob_match(&full_pattern, &file_path_str) {
self.files.push(file_path);
}
}
Expand Down
65 changes: 65 additions & 0 deletions crates/oxide/src/paths.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
use std::fmt::Display;
use std::io;
use std::path;

#[derive(Clone)]
pub struct Path {
inner: path::PathBuf,
}

impl From<path::PathBuf> for Path {
fn from(value: path::PathBuf) -> Self {
Self { inner: value }
}
}

impl From<String> for Path {
fn from(value: String) -> Self {
Self {
inner: value.into(),
}
}
}

impl From<&str> for Path {
fn from(value: &str) -> Self {
Self {
inner: value.into(),
}
}
}

impl Display for Path {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(
f,
"{}",
format!("{}", self.inner.display()).replace('\\', "/")
)
}
}

impl Path {
pub fn trim_prefix(&self, prefix: String) -> Self {
let prefix = prefix.replace('\\', "/");
let my_path = self.to_string();

if let Some(str) = my_path.strip_prefix(&prefix) {
return str.into();
}

my_path.into()
}

pub fn join(&self, component: &str) -> Self {
if component.is_empty() {
return self.clone();
}

self.inner.join(component).into()
}

pub fn canonicalize(&self) -> io::Result<Self> {
Ok(dunce::canonicalize(&self.inner)?.into())
}
}
25 changes: 7 additions & 18 deletions crates/oxide/tests/scanner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ mod scanner {
}
}

let base = format!("{}", dir.display());
let base = format!("{}", dir.display()).replace('\\', "/");

// Resolve all content paths for the (temporary) current working directory
let mut sources: Vec<GlobEntry> = globs
Expand All @@ -51,31 +51,20 @@ mod scanner {

let candidates = scanner.scan();

let mut paths: Vec<_> = scanner
.get_files()
.into_iter()
.map(|x| x.replace(&format!("{}{}", &base, path::MAIN_SEPARATOR), ""))
.collect();
let mut paths: Vec<_> = scanner.get_files();

for glob in scanner.get_globs() {
paths.push(format!(
"{}{}{}",
glob.base,
path::MAIN_SEPARATOR,
glob.pattern
));
paths.push(format!("{}{}{}", glob.base, "/", glob.pattern));
}

let parent_dir = format!(
"{}{}",
fs::canonicalize(&base).unwrap().display(),
path::MAIN_SEPARATOR
);
let parent_dir =
format!("{}{}", dunce::canonicalize(&base).unwrap().display(), "/").replace('\\', "/");

paths = paths
.into_iter()
.map(|x| {
x.replace(&parent_dir, "").replace('\\', "/") // Normalize paths to use unix style separators
// Normalize paths to use unix style separators
x.replace('\\', "/").replace(&parent_dir, "")
})
.collect();

Expand Down
2 changes: 1 addition & 1 deletion packages/@tailwindcss-standalone/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
"@parcel/watcher-linux-x64-musl": "^2.4.2-alpha.0",
"@parcel/watcher-win32-x64": "^2.4.2-alpha.0",
"@types/bun": "^1.1.11",
"bun": "^1.1.29",
"bun": "1.1.29",
"lightningcss-darwin-arm64": "^1.25.1",
"lightningcss-darwin-x64": "^1.25.1",
"lightningcss-linux-arm64-gnu": "^1.25.1",
Expand Down
16 changes: 12 additions & 4 deletions packages/@tailwindcss-vite/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -431,7 +431,7 @@ class Root {
let root = this.compiler.root

if (root !== 'none' && root !== null) {
let basePath = path.posix.resolve(root.base, root.pattern)
let basePath = normalizePath(path.resolve(root.base, root.pattern))

let isDir = await fs.stat(basePath).then(
(stats) => stats.isDirectory(),
Expand Down Expand Up @@ -463,14 +463,22 @@ class Root {
if (!this.compiler) return new Set()
if (this.compiler.root === 'none') return new Set()

const HAS_DRIVE_LETTER = /^[A-Z]:/

let shouldIncludeCandidatesFrom = (id: string) => {
if (this.basePath === null) return true

// This a virtual module that's not on the file system
// TODO: What should we do here?
if (id.startsWith(this.basePath)) return true

// This is a windows absolute path that doesn't match so return false
if (HAS_DRIVE_LETTER.test(id)) return false

// We've got a path that's not absolute and not on Windows
// TODO: this is probably a virtual module -- not sure if we need to scan it
if (!id.startsWith('/')) return true

return id.startsWith(this.basePath)
// This is an absolute path on POSIX and it does not match
return false
}

let shared = new Set<string>()
Expand Down
7 changes: 6 additions & 1 deletion pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions scripts/version-packages.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ const syncedWorkspaces = new Map([
'crates/node/npm/linux-x64-gnu',
'crates/node/npm/linux-x64-musl',
'crates/node/npm/win32-x64-msvc',
'crates/node/npm/win32-arm64-msvc',
],
],
['@tailwindcss/cli', ['packages/@tailwindcss-standalone']],
Expand Down