mirror of
https://gitlab.com/soapbox-pub/shakespeare.git
synced 2026-12-05 08:23:34 +00:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
2335395641 | ||
|
|
af2436a3b8 | ||
|
|
1fd3d23d4f |
No files matched your search
@@ -1,5 +1,10 @@
|
||||
# Changelog
|
||||
|
||||
## [9.13.0] - 2026-04-26
|
||||
|
||||
### Added
|
||||
- Build projects with Tailwind CSS v4, including `@import "tailwindcss"` entry files and third-party v4 plugins like `tw-animate-css`
|
||||
|
||||
## [9.12.0] - 2026-04-25
|
||||
|
||||
### Added
|
||||
|
||||
Generated
+2
-2
@@ -1,12 +1,12 @@
|
||||
{
|
||||
"name": "shakespeare.diy",
|
||||
"version": "9.11.4",
|
||||
"version": "9.12.0",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "shakespeare.diy",
|
||||
"version": "9.11.4",
|
||||
"version": "9.12.0",
|
||||
"license": "AGPL-3.0-or-later",
|
||||
"dependencies": {
|
||||
"@capacitor/app": "^8.1.0",
|
||||
|
||||
+1
-1
@@ -3,7 +3,7 @@
|
||||
"description": "Build custom apps with AI assistance using Shakespeare, an open-source development environment",
|
||||
"homepage": "https://shakespeare.diy",
|
||||
"license": "AGPL-3.0-or-later",
|
||||
"version": "9.12.0",
|
||||
"version": "9.13.0",
|
||||
"type": "module",
|
||||
"author": {
|
||||
"name": "shakespeare.diy",
|
||||
|
||||
@@ -1,5 +1,10 @@
|
||||
# Changelog
|
||||
|
||||
## [9.13.0] - 2026-04-26
|
||||
|
||||
### Added
|
||||
- Build projects with Tailwind CSS v4, including `@import "tailwindcss"` entry files and third-party v4 plugins like `tw-animate-css`
|
||||
|
||||
## [9.12.0] - 2026-04-25
|
||||
|
||||
### Added
|
||||
|
||||
@@ -255,14 +255,22 @@ export function esmPlugin(options: EsmPluginOptions): Plugin {
|
||||
? path.split("/").slice(0, 2).join("/")
|
||||
: path.split("/")[0];
|
||||
|
||||
// If the importer is CSS, ignore (no JS deps)
|
||||
try {
|
||||
const { pathname } = new URL(args.importer);
|
||||
if (/\.css$/.test(pathname)) {
|
||||
return; // CSS imports don't have external dependencies
|
||||
}
|
||||
} catch {
|
||||
// not a URL; continue
|
||||
// When the importer is a CSS file, treat `@import "tailwindcss"`
|
||||
// and its subpaths (`tailwindcss/preflight`, `/theme`, `/utilities`)
|
||||
// as external so the Tailwind v4 `@tailwindcss/browser` runtime can
|
||||
// process them at runtime (the v4 runtime special-cases these and
|
||||
// rejects all other `@import` specifiers). Any other bare CSS
|
||||
// `@import` falls through to the normal CDN resolution below, which
|
||||
// will load the dependency as CSS content and bundle it inline
|
||||
// (esm.sh redirects bare package specifiers for CSS-only packages
|
||||
// to their `.css` entry, which the `onLoad` handler picks up via
|
||||
// the `text/css` content-type -> `loader: "css"` mapping).
|
||||
const importerIsCss = /\.css(?:\?|$)/.test(args.importer ?? "");
|
||||
if (importerIsCss && /^tailwindcss(?:\/|$)/.test(path)) {
|
||||
return {
|
||||
path: args.path,
|
||||
external: true,
|
||||
};
|
||||
}
|
||||
|
||||
// Check if this is a file: dependency
|
||||
|
||||
+46
-5
@@ -52,6 +52,37 @@ export interface BuildContext {
|
||||
tsconfig?: TsConfig;
|
||||
}
|
||||
|
||||
/** Tailwind CSS variant used by a project (or `null` if Tailwind is not enabled). */
|
||||
export type TailwindVariant = "v3" | "v4" | null;
|
||||
|
||||
/**
|
||||
* Detect which major version of Tailwind CSS a project uses by inspecting the
|
||||
* `tailwindcss` entry in package.json (dependencies, devDependencies, or
|
||||
* peerDependencies). Returns `null` when no Tailwind dependency is declared.
|
||||
*
|
||||
* The version string is matched loosely: any leading non-digit characters
|
||||
* (such as `^`, `~`, `>=`, or `v`) are stripped before reading the major
|
||||
* number. Ranges like `>=3.0.0 <5.0.0`, git URLs, or other non-standard
|
||||
* specifiers fall through to `null`, which callers should treat as "skip
|
||||
* Tailwind injection entirely".
|
||||
*/
|
||||
export function detectTailwindVariant(packageJson: PackageJson): TailwindVariant {
|
||||
const spec =
|
||||
packageJson.dependencies?.tailwindcss ??
|
||||
packageJson.devDependencies?.tailwindcss ??
|
||||
packageJson.peerDependencies?.tailwindcss;
|
||||
|
||||
if (!spec) return null;
|
||||
|
||||
const match = spec.match(/(\d+)/);
|
||||
if (!match) return null;
|
||||
|
||||
const major = Number(match[1]);
|
||||
if (major >= 4) return "v4";
|
||||
if (major === 3) return "v3";
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Read package.json, package-lock.json/yarn.lock, and tsconfig.json from project
|
||||
* Exported for use by deployment adapters that need to bundle workers
|
||||
@@ -193,12 +224,22 @@ async function bundle(
|
||||
}
|
||||
}
|
||||
|
||||
// Enable Tailwind CSS if a config file is present
|
||||
for (const path of ["tailwind.config.ts", "tailwind.config.js"]) {
|
||||
if (await fileExists(fs, join(projectPath, path))) {
|
||||
entryPoints.push(`shakespeare:${path}`);
|
||||
break;
|
||||
// Enable Tailwind CSS based on the version declared in package.json.
|
||||
// v3 needs a synthetic entry that loads the Play CDN runtime and assigns
|
||||
// the project's tailwind.config.{js,ts} to `window.tailwind.config`.
|
||||
// v4 has no JS config (theming is CSS-based via `@theme`) and the
|
||||
// `@tailwindcss/browser@4` runtime auto-scans the document, so the shim
|
||||
// just needs to side-effect-import the runtime.
|
||||
const tailwindVariant = detectTailwindVariant(context.packageJson);
|
||||
if (tailwindVariant === "v3") {
|
||||
for (const path of ["tailwind.config.ts", "tailwind.config.js"]) {
|
||||
if (await fileExists(fs, join(projectPath, path))) {
|
||||
entryPoints.push(`shakespeare:${path}`);
|
||||
break;
|
||||
}
|
||||
}
|
||||
} else if (tailwindVariant === "v4") {
|
||||
entryPoints.push("shakespeare:tailwindcss@4");
|
||||
}
|
||||
|
||||
const collectedWorkers: WorkerMatch[] = [];
|
||||
|
||||
@@ -14,7 +14,9 @@ export function shakespearePlugin(options: ShakespearePluginOptions): Plugin {
|
||||
name: "shakespeare",
|
||||
|
||||
setup(build) {
|
||||
// Handle Tailwind CSS configuration files
|
||||
// Handle Tailwind CSS configuration files (v3).
|
||||
// The synthetic entry loads the v3 Play CDN runtime and assigns the
|
||||
// project's tailwind.config.{js,ts} to the global `tailwind.config`.
|
||||
build.onResolve({ filter: /^shakespeare:tailwind\.config\.(js|ts)$/ }, (args) => {
|
||||
return {
|
||||
path: args.path,
|
||||
@@ -34,6 +36,24 @@ export function shakespearePlugin(options: ShakespearePluginOptions): Plugin {
|
||||
};
|
||||
});
|
||||
|
||||
// Handle Tailwind CSS v4 runtime.
|
||||
// v4 has no JS config (theming is done in CSS via `@theme`) and the
|
||||
// `@tailwindcss/browser@4` runtime auto-detects `<style type="text/tailwindcss">`
|
||||
// blocks in the document, so the shim just side-effect-imports the runtime.
|
||||
build.onResolve({ filter: /^shakespeare:tailwindcss@4$/ }, (args) => {
|
||||
return {
|
||||
path: args.path,
|
||||
namespace: "shakespeare-tailwind-v4",
|
||||
};
|
||||
});
|
||||
|
||||
build.onLoad({ filter: /.*/, namespace: "shakespeare-tailwind-v4" }, () => {
|
||||
return {
|
||||
contents: `import "${options.esmUrl}/@tailwindcss/browser@4";`,
|
||||
loader: "js",
|
||||
};
|
||||
});
|
||||
|
||||
// Handle "sonner" imports with a dummy API
|
||||
build.onResolve({ filter: /^sonner$/ }, (args) => {
|
||||
return {
|
||||
|
||||
Reference in new issue
Block a user