From cae9d0249343f446d1026fdf33229c9de4ac357b Mon Sep 17 00:00:00 2001 From: Jordan Pittman Date: Fri, 2 Aug 2024 12:06:23 -0400 Subject: [PATCH 1/5] Add preliminary standalone CLI experiment --- package.json | 8 ++- packages/@tailwindcss-standalone/build.ts | 69 +++++++++++++++++++ packages/@tailwindcss-standalone/package.json | 52 ++++++++++++++ packages/@tailwindcss-standalone/src/index.ts | 7 ++ .../@tailwindcss-standalone/src/plugin.ts | 31 +++++++++ .../src/resolve.standalone.ts | 34 +++++++++ patches/@parcel__watcher@2.4.1.patch | 57 +++++++++++++++ patches/lightningcss@1.26.0.patch | 56 +++++++++++++++ 8 files changed, 313 insertions(+), 1 deletion(-) create mode 100644 packages/@tailwindcss-standalone/build.ts create mode 100644 packages/@tailwindcss-standalone/package.json create mode 100644 packages/@tailwindcss-standalone/src/index.ts create mode 100644 packages/@tailwindcss-standalone/src/plugin.ts create mode 100644 packages/@tailwindcss-standalone/src/resolve.standalone.ts create mode 100644 patches/@parcel__watcher@2.4.1.patch create mode 100644 patches/lightningcss@1.26.0.patch diff --git a/package.json b/package.json index 609845143..889e13d2b 100644 --- a/package.json +++ b/package.json @@ -60,5 +60,11 @@ "typescript": "^5.5.4", "vitest": "^2.0.5" }, - "packageManager": "pnpm@9.6.0" + "packageManager": "pnpm@9.6.0", + "pnpm": { + "patchedDependencies": { + "@parcel/watcher@2.4.1": "patches/@parcel__watcher@2.4.1.patch", + "lightningcss@1.26.0": "patches/lightningcss@1.26.0.patch" + } + } } diff --git a/packages/@tailwindcss-standalone/build.ts b/packages/@tailwindcss-standalone/build.ts new file mode 100644 index 000000000..4bfafd102 --- /dev/null +++ b/packages/@tailwindcss-standalone/build.ts @@ -0,0 +1,69 @@ +import { $ } from 'bun' +import { createHash } from 'node:crypto' +import { mkdir, readFile, writeFile } from 'node:fs/promises' +import * as path from 'node:path' +import { fileURLToPath } from 'node:url' + +const __dirname = fileURLToPath(new URL('.', import.meta.url)) + +async function buildForPlatform(triple: string, outfile: string) { + // We wrap this in a retry because occasionally the atomic rename fails for some reason + for (let i = 0; i < 5; ++i) { + try { + return await $`bun build --compile --target=${triple} ./src/index.ts --outfile=${outfile}` + } catch (err) { + if (i < 5) continue + + throw new Error(`Failed to build for platform ${triple}`, { cause: err }) + } + } +} + +async function build(triple: string, file: string) { + let start = process.hrtime.bigint() + + let outfile = path.resolve(__dirname, `dist/${file}`) + + await buildForPlatform(triple, outfile) + + await new Promise((resolve) => setTimeout(resolve, 100)) + + let content = await readFile(outfile) + let sum = createHash('sha256').update(content).digest('hex') + + let elapsed = process.hrtime.bigint() - start + + return { + triple, + file, + sum, + elapsed, + } +} + +await mkdir(path.resolve(__dirname, 'dist'), { recursive: true }) + +// Build platform binaries and checksum them +let results = await Promise.all([ + build('bun-linux-arm64', './tailwindcss-linux-arm64'), + build('bun-linux-x64', './tailwindcss-linux-x64'), + // build('linux-armv7', 'tailwindcss-linux-armv7'), + build('bun-darwin-arm64', './tailwindcss-macos-arm64'), + build('bun-darwin-x64', './tailwindcss-macos-x64'), + build('bun-windows-x64', './tailwindcss-windows-x64.exe'), + // buildForPlatform('win32-arm64', 'tailwindcss-windows-arm64'), +]) + +// Write the checksums to a file +let sumsFile = path.resolve(__dirname, 'dist/sha256sums.txt') +let sums = results.map(({ file, sum }) => `${sum} ${file}`) + +console.table( + results.map(({ triple, sum, elapsed }) => ({ + triple, + sum, + elapsed: `${(Number(elapsed) / 1e6).toFixed(0)}ms`, + })), +) + +await writeFile(sumsFile, sums.join('\n') + '\n') diff --git a/packages/@tailwindcss-standalone/package.json b/packages/@tailwindcss-standalone/package.json new file mode 100644 index 000000000..7d9279fa9 --- /dev/null +++ b/packages/@tailwindcss-standalone/package.json @@ -0,0 +1,52 @@ +{ + "name": "@tailwindcss/standalone", + "version": "4.0.0-alpha.18", + "description": "Standalone CLI for Tailwind CSS", + "license": "MIT", + "repository": { + "type": "git", + "url": "https://github.com/tailwindlabs/tailwindcss.git", + "directory": "packages/@tailwindcss-standalone" + }, + "bugs": "https://github.com/tailwindlabs/tailwindcss/issues", + "homepage": "https://tailwindcss.com", + "scripts": { + "lint": "tsc --noEmit", + "build": "bun ./build.ts" + }, + "bin": { + "tailwindcss": "./dist/index.mjs" + }, + "exports": { + "./package.json": "./package.json" + }, + "files": [ + "dist" + ], + "publishConfig": { + "provenance": true, + "access": "public" + }, + "dependencies": { + "@tailwindcss/cli": "workspace:^", + "tailwindcss": "workspace:^" + }, + "__notes": "These binary packages must be included so Bun can build the CLI for all supported platforms. We also rely on Lightning CSS and Parcel being patched so Bun can statically analyze the executables.", + "devDependencies": { + "@parcel/watcher-darwin-arm64": "^2.4.2-alpha.0", + "@parcel/watcher-darwin-x64": "^2.4.2-alpha.0", + "@parcel/watcher-linux-arm64-glibc": "^2.4.2-alpha.0", + "@parcel/watcher-linux-arm64-musl": "^2.4.2-alpha.0", + "@parcel/watcher-linux-x64-glibc": "^2.4.2-alpha.0", + "@parcel/watcher-linux-x64-musl": "^2.4.2-alpha.0", + "@parcel/watcher-win32-x64": "^2.4.2-alpha.0", + "@types/bun": "^1.1.6", + "lightningcss-darwin-arm64": "^1.25.1", + "lightningcss-darwin-x64": "^1.25.1", + "lightningcss-linux-arm64-gnu": "^1.25.1", + "lightningcss-linux-arm64-musl": "^1.25.1", + "lightningcss-linux-x64-gnu": "^1.25.1", + "lightningcss-linux-x64-musl": "^1.25.1", + "lightningcss-win32-x64-msvc": "^1.25.1" + } +} diff --git a/packages/@tailwindcss-standalone/src/index.ts b/packages/@tailwindcss-standalone/src/index.ts new file mode 100644 index 000000000..92f32dc79 --- /dev/null +++ b/packages/@tailwindcss-standalone/src/index.ts @@ -0,0 +1,7 @@ +import { plugin } from 'bun' +import { resolution } from './plugin.ts' + +plugin(resolution) + +await new Promise((resolve) => setTimeout(resolve)) +await import('../../@tailwindcss-cli/src/index.ts') diff --git a/packages/@tailwindcss-standalone/src/plugin.ts b/packages/@tailwindcss-standalone/src/plugin.ts new file mode 100644 index 000000000..a4eea590e --- /dev/null +++ b/packages/@tailwindcss-standalone/src/plugin.ts @@ -0,0 +1,31 @@ +import type { BunPlugin } from 'bun' + +export const resolution: BunPlugin = { + name: 'Custom loader', + target: 'bun', + setup(build) { + // onLoad + // build.onLoad({ filter: /./ }, async (file) => { + // console.log({ file }) + // return { + // loader: 'object', + // exports: {}, + // } + // }) + + // Replace resolve.ts with the local resolve.standalone.ts + build.onResolve({ filter: /./ }, (file) => { + console.log('on resolve', { file }) + + return undefined + + // return { + // path: require.resolve(file.path), + // } + + // return Object.assign(file, { + // path: require.resolve('./resolve.standalone.ts'), + // }) + }) + }, +} diff --git a/packages/@tailwindcss-standalone/src/resolve.standalone.ts b/packages/@tailwindcss-standalone/src/resolve.standalone.ts new file mode 100644 index 000000000..f2251dbca --- /dev/null +++ b/packages/@tailwindcss-standalone/src/resolve.standalone.ts @@ -0,0 +1,34 @@ +// @ts-ignore +import twIndex from 'tailwindcss/index.css' with { type: 'file' } + +// @ts-ignore +import twPreflight from 'tailwindcss/preflight.css' with { type: 'file' } + +// @ts-ignore +import twTheme from 'tailwindcss/theme.css' with { type: 'file' } + +// @ts-ignore +import twUtilities from 'tailwindcss/utilities.css' with { type: 'file' } + +// @ts-ignore +// import twPkg from 'tailwindcss/package.json' with { type: 'file' } + +import { createRequire } from 'node:module' + +const localResolve = createRequire(import.meta.url).resolve + +export function resolve(id: string) { + if (id === 'tailwindcss/index.css') { + return twIndex + } else if (id === 'tailwindcss/preflight.css') { + return twPreflight + } else if (id === 'tailwindcss/theme.css') { + return twTheme + } else if (id === 'tailwindcss/utilities.css') { + return twUtilities + } else if (id === 'tailwindcss/package.json') { + return twPkg + } else { + return localResolve(id) + } +} diff --git a/patches/@parcel__watcher@2.4.1.patch b/patches/@parcel__watcher@2.4.1.patch new file mode 100644 index 000000000..8de86bcc7 --- /dev/null +++ b/patches/@parcel__watcher@2.4.1.patch @@ -0,0 +1,57 @@ +diff --git a/index.js b/index.js +index 8afb2b1126dcc687b7ff9b631589da252c1f9c22..15d3b2ffa11f8999ab95d8306f789f2a4613bae3 100644 +--- a/index.js ++++ b/index.js +@@ -1,40 +1,22 @@ + const {createWrapper} = require('./wrapper'); + +-let name = `@parcel/watcher-${process.platform}-${process.arch}`; +-if (process.platform === 'linux') { +- const { MUSL, family } = require('detect-libc'); +- if (family === MUSL) { +- name += '-musl'; +- } else { +- name += '-glibc'; +- } +-} ++function loadPackage() { ++ if (process.platform === 'linux') { ++ const { MUSL, GLIBC, family } = require("detect-libc"); + +-let binding; +-try { +- binding = require(name); +-} catch (err) { +- handleError(err); +- try { +- binding = require('./build/Release/watcher.node'); +- } catch (err) { +- handleError(err); +- try { +- binding = require('./build/Debug/watcher.node'); +- } catch (err) { +- handleError(err); +- throw new Error(`No prebuild or local build of @parcel/watcher found. Tried ${name}. Please ensure it is installed (don't use --no-optional when installing with npm). Otherwise it is possible we don't support your platform yet. If this is the case, please report an issue to https://github.com/parcel-bundler/watcher.`); ++ if (family === MUSL) { ++ return require(`@parcel/watcher-${process.platform}-${process.arch}-musl`); ++ } else if (family === GLIBC) { ++ return require(`@parcel/watcher-${process.platform}-${process.arch}-glibc`); ++ } else { ++ throw new Error(`Unsupported libc on: ${process.platform}-${process.arch}`); + } ++ } else { ++ return require(`@parcel/watcher-${process.platform}-${process.arch}`); + } + } + +-function handleError(err) { +- if (err?.code !== 'MODULE_NOT_FOUND') { +- throw err; +- } +-} +- +-const wrapper = createWrapper(binding); ++const wrapper = createWrapper(loadPackage()); + exports.writeSnapshot = wrapper.writeSnapshot; + exports.getEventsSince = wrapper.getEventsSince; + exports.subscribe = wrapper.subscribe; diff --git a/patches/lightningcss@1.26.0.patch b/patches/lightningcss@1.26.0.patch new file mode 100644 index 000000000..9806590a2 --- /dev/null +++ b/patches/lightningcss@1.26.0.patch @@ -0,0 +1,56 @@ +diff --git a/node/index.js b/node/index.js +index a9f2f6d5f3394329fcf8bc06af549030c01167a5..1a7a6dd3612f786495e214090ab943a677a3a612 100644 +--- a/node/index.js ++++ b/node/index.js +@@ -1,27 +1,28 @@ +-let parts = [process.platform, process.arch]; +-if (process.platform === 'linux') { +- const { MUSL, family } = require('detect-libc'); +- if (family === MUSL) { +- parts.push('musl'); +- } else if (process.arch === 'arm') { +- parts.push('gnueabihf'); +- } else { +- parts.push('gnu'); +- } +-} else if (process.platform === 'win32') { +- parts.push('msvc'); +-} ++function loadPackage() { ++ if (process.platform === "linux") { ++ const { MUSL, GLIBC, family } = require("detect-libc"); + +-if (process.env.CSS_TRANSFORMER_WASM) { +- module.exports = require(`../pkg`); +-} else { +- try { +- module.exports = require(`lightningcss-${parts.join('-')}`); +- } catch (err) { +- module.exports = require(`../lightningcss.${parts.join('-')}.node`); ++ if (family === MUSL) { ++ return require(`lightningcss-${process.platform}-${process.arch}-musl`); ++ } else if (family === GLIBC) { ++ if (process.arch === "arm") { ++ return require(`lightningcss-${process.platform}-${process.arch}-gnueabihf`); ++ } else { ++ return require(`lightningcss-${process.platform}-${process.arch}-gnu`); ++ } ++ } else { ++ throw new Error( ++ `Unsupported libc on: ${process.platform}-${process.arch}` ++ ); ++ } ++ } else if (process.platform === "win32") { ++ return require(`lightningcss-${process.platform}-${process.arch}-msvc`); ++ } else { ++ return require(`lightningcss-${process.platform}-${process.arch}`); + } + } + +-module.exports.browserslistToTargets = require('./browserslistToTargets'); +-module.exports.composeVisitors = require('./composeVisitors'); +-module.exports.Features = require('./flags').Features; ++module.exports = loadPackage(); ++module.exports.browserslistToTargets = require("./browserslistToTargets"); ++module.exports.composeVisitors = require("./composeVisitors"); ++module.exports.Features = require("./flags").Features; From e1a87974b61c02c6133011fd435c24854f1050b8 Mon Sep 17 00:00:00 2001 From: Jordan Pittman Date: Mon, 26 Aug 2024 11:08:02 -0400 Subject: [PATCH 2/5] wip --- pnpm-lock.yaml | 221 ++++++++++++++++++++++++++++++++++++++----------- 1 file changed, 174 insertions(+), 47 deletions(-) diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 9c069ae65..35146a646 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -16,6 +16,14 @@ catalogs: specifier: ^5.4.0 version: 5.4.0 +patchedDependencies: + '@parcel/watcher@2.4.1': + hash: qvoazptra62ta6otw2xgwv3msu + path: patches/@parcel__watcher@2.4.1.patch + lightningcss@1.26.0: + hash: 2gljz2azdf5ggmo7nz3iycnapi + path: patches/lightningcss@1.26.0.patch + importers: .: @@ -52,7 +60,7 @@ importers: version: 5.5.4 vitest: specifier: ^2.0.5 - version: 2.0.5(@types/node@20.14.13)(lightningcss@1.26.0) + version: 2.0.5(@types/node@20.14.13)(lightningcss@1.26.0(patch_hash=2gljz2azdf5ggmo7nz3iycnapi)) crates/node: optionalDependencies: @@ -129,13 +137,13 @@ importers: dependencies: '@parcel/watcher': specifier: ^2.4.1 - version: 2.4.1 + version: 2.4.1(patch_hash=qvoazptra62ta6otw2xgwv3msu) '@tailwindcss/oxide': specifier: workspace:^ version: link:../../crates/node lightningcss: specifier: 'catalog:' - version: 1.26.0 + version: 1.26.0(patch_hash=2gljz2azdf5ggmo7nz3iycnapi) mri: specifier: ^1.2.0 version: 1.2.0 @@ -166,7 +174,7 @@ importers: version: link:../../crates/node lightningcss: specifier: 'catalog:' - version: 1.26.0 + version: 1.26.0(patch_hash=2gljz2azdf5ggmo7nz3iycnapi) postcss-import: specifier: ^16.1.0 version: 16.1.0(postcss@8.4.41) @@ -190,6 +198,61 @@ importers: specifier: ^8.4.41 version: 8.4.41 + packages/@tailwindcss-standalone: + dependencies: + '@tailwindcss/cli': + specifier: workspace:^ + version: link:../@tailwindcss-cli + tailwindcss: + specifier: workspace:^ + version: link:../tailwindcss + devDependencies: + '@parcel/watcher-darwin-arm64': + specifier: ^2.4.2-alpha.0 + version: 2.4.2-alpha.0 + '@parcel/watcher-darwin-x64': + specifier: ^2.4.2-alpha.0 + version: 2.4.2-alpha.0 + '@parcel/watcher-linux-arm64-glibc': + specifier: ^2.4.2-alpha.0 + version: 2.4.2-alpha.0 + '@parcel/watcher-linux-arm64-musl': + specifier: ^2.4.2-alpha.0 + version: 2.4.2-alpha.0 + '@parcel/watcher-linux-x64-glibc': + specifier: ^2.4.2-alpha.0 + version: 2.4.2-alpha.0 + '@parcel/watcher-linux-x64-musl': + specifier: ^2.4.2-alpha.0 + version: 2.4.2-alpha.0 + '@parcel/watcher-win32-x64': + specifier: ^2.4.2-alpha.0 + version: 2.4.2-alpha.0 + '@types/bun': + specifier: ^1.1.6 + version: 1.1.8 + lightningcss-darwin-arm64: + specifier: ^1.25.1 + version: 1.26.0 + lightningcss-darwin-x64: + specifier: ^1.25.1 + version: 1.26.0 + lightningcss-linux-arm64-gnu: + specifier: ^1.25.1 + version: 1.26.0 + lightningcss-linux-arm64-musl: + specifier: ^1.25.1 + version: 1.26.0 + lightningcss-linux-x64-gnu: + specifier: ^1.25.1 + version: 1.26.0 + lightningcss-linux-x64-musl: + specifier: ^1.25.1 + version: 1.26.0 + lightningcss-win32-x64-msvc: + specifier: ^1.25.1 + version: 1.26.0 + packages/@tailwindcss-vite: dependencies: '@tailwindcss/oxide': @@ -197,7 +260,7 @@ importers: version: link:../../crates/node lightningcss: specifier: 'catalog:' - version: 1.26.0 + version: 1.26.0(patch_hash=2gljz2azdf5ggmo7nz3iycnapi) postcss-load-config: specifier: ^6.0.1 version: 6.0.1(postcss@8.4.41) @@ -213,7 +276,7 @@ importers: version: link:../internal-postcss-fix-relative-paths vite: specifier: 'catalog:' - version: 5.4.0(@types/node@20.14.13)(lightningcss@1.26.0) + version: 5.4.0(@types/node@20.14.13)(lightningcss@1.26.0(patch_hash=2gljz2azdf5ggmo7nz3iycnapi)) packages/internal-example-plugin: {} @@ -242,7 +305,7 @@ importers: version: 20.14.13 lightningcss: specifier: 'catalog:' - version: 1.26.0 + version: 1.26.0(patch_hash=2gljz2azdf5ggmo7nz3iycnapi) playgrounds/nextjs: dependencies: @@ -291,7 +354,7 @@ importers: version: link:../../packages/@tailwindcss-vite '@vitejs/plugin-react': specifier: ^4.3.1 - version: 4.3.1(vite@5.4.0(@types/node@20.14.13)(lightningcss@1.26.0)) + version: 4.3.1(vite@5.4.0(@types/node@20.14.13)(lightningcss@1.26.0(patch_hash=2gljz2azdf5ggmo7nz3iycnapi))) react: specifier: ^18.3.1 version: 18.3.1 @@ -313,10 +376,10 @@ importers: version: 1.1.22 vite: specifier: 'catalog:' - version: 5.4.0(@types/node@20.14.13)(lightningcss@1.26.0) + version: 5.4.0(@types/node@20.14.13)(lightningcss@1.26.0(patch_hash=2gljz2azdf5ggmo7nz3iycnapi)) vite-plugin-handlebars: specifier: ^2.0.0 - version: 2.0.0(@types/node@20.14.13)(lightningcss@1.26.0) + version: 2.0.0(@types/node@20.14.13)(lightningcss@1.26.0(patch_hash=2gljz2azdf5ggmo7nz3iycnapi)) packages: @@ -875,12 +938,22 @@ packages: cpu: [arm64] os: [darwin] + '@parcel/watcher-darwin-arm64@2.4.2-alpha.0': + resolution: {integrity: sha512-2xH4Ve7OKjIh+4YRfTN3HGJa2W8KTPLOALHZj5fxcbTPwaVxdpIRItDrcikUx2u3AzGAFme7F+AZZXHnf0F15Q==} + engines: {node: '>= 10.0.0'} + os: [darwin] + '@parcel/watcher-darwin-x64@2.4.1': resolution: {integrity: sha512-yrw81BRLjjtHyDu7J61oPuSoeYWR3lDElcPGJyOvIXmor6DEo7/G2u1o7I38cwlcoBHQFULqF6nesIX3tsEXMg==} engines: {node: '>= 10.0.0'} cpu: [x64] os: [darwin] + '@parcel/watcher-darwin-x64@2.4.2-alpha.0': + resolution: {integrity: sha512-xtjmXUH4YZVah5+7Q0nb+fpRP5qZn9cFfuPuZ4k77UfUGVwhacgZyIRQgIOwMP3GkgW4TsrKQaw1KIe7L1ZqcQ==} + engines: {node: '>= 10.0.0'} + os: [darwin] + '@parcel/watcher-freebsd-x64@2.4.1': resolution: {integrity: sha512-TJa3Pex/gX3CWIx/Co8k+ykNdDCLx+TuZj3f3h7eOjgpdKM+Mnix37RYsYU4LHhiYJz3DK5nFCCra81p6g050w==} engines: {node: '>= 10.0.0'} @@ -899,24 +972,44 @@ packages: cpu: [arm64] os: [linux] + '@parcel/watcher-linux-arm64-glibc@2.4.2-alpha.0': + resolution: {integrity: sha512-vIIOcZf+fgsRReIK3Fw0WINvGo9UwiXfisnqYRzfpNByRZvkEPkGTIVe8iiDp72NhPTVmwIvBqM6yKDzIaw8GQ==} + engines: {node: '>= 10.0.0'} + os: [linux] + '@parcel/watcher-linux-arm64-musl@2.4.1': resolution: {integrity: sha512-p4Xb7JGq3MLgAfYhslU2SjoV9G0kI0Xry0kuxeG/41UfpjHGOhv7UoUDAz/jb1u2elbhazy4rRBL8PegPJFBhA==} engines: {node: '>= 10.0.0'} cpu: [arm64] os: [linux] + '@parcel/watcher-linux-arm64-musl@2.4.2-alpha.0': + resolution: {integrity: sha512-gXqEAoLG9bBCbQNUgqjSOxHcjpmCZmYT9M8UvrdTMgMYgXgiWcR8igKlPRd40mCIRZSkMpN2ScSy2WjQ0bQZnQ==} + engines: {node: '>= 10.0.0'} + os: [linux] + '@parcel/watcher-linux-x64-glibc@2.4.1': resolution: {integrity: sha512-s9O3fByZ/2pyYDPoLM6zt92yu6P4E39a03zvO0qCHOTjxmt3GHRMLuRZEWhWLASTMSrrnVNWdVI/+pUElJBBBg==} engines: {node: '>= 10.0.0'} cpu: [x64] os: [linux] + '@parcel/watcher-linux-x64-glibc@2.4.2-alpha.0': + resolution: {integrity: sha512-/WJJ3Y46ubwQW+Z+mzpzK3pvqn/AT7MA63NB0+k9GTLNxJQZNREensMtpJ/FJ+LVIiraEHTY22KQrsx9+DeNbw==} + engines: {node: '>= 10.0.0'} + os: [linux] + '@parcel/watcher-linux-x64-musl@2.4.1': resolution: {integrity: sha512-L2nZTYR1myLNST0O632g0Dx9LyMNHrn6TOt76sYxWLdff3cB22/GZX2UPtJnaqQPdCRoszoY5rcOj4oMTtp5fQ==} engines: {node: '>= 10.0.0'} cpu: [x64] os: [linux] + '@parcel/watcher-linux-x64-musl@2.4.2-alpha.0': + resolution: {integrity: sha512-1dz4fTM5HaANk3RSRmdhALT+bNqTHawVDL1D77HwV/FuF/kSjlM3rGrJuFaCKwQ5E8CInHCcobqMN8Jh8LYaRg==} + engines: {node: '>= 10.0.0'} + os: [linux] + '@parcel/watcher-win32-arm64@2.4.1': resolution: {integrity: sha512-Uq2BPp5GWhrq/lcuItCHoqxjULU1QYEcyjSO5jqqOK8RNFDBQnenMMx4gAl3v8GiWa59E9+uDM7yZ6LxwUIfRg==} engines: {node: '>= 10.0.0'} @@ -935,6 +1028,11 @@ packages: cpu: [x64] os: [win32] + '@parcel/watcher-win32-x64@2.4.2-alpha.0': + resolution: {integrity: sha512-U2abMKF7JUiIxQkos19AvTLFcnl2Xn8yIW1kzu+7B0Lux4Gkuu/BUDBroaM1s6+hwgK63NOLq9itX2Y3GwUThg==} + engines: {node: '>= 10.0.0'} + os: [win32] + '@parcel/watcher@2.4.1': resolution: {integrity: sha512-HNjmfLQEVRZmHRET336f20H/8kOozUGwk7yajvsonjNxbj2wBTK1WsQuHkD5yYh9RxFGL2EyDHryOihOwUoKDA==} engines: {node: '>= 10.0.0'} @@ -1046,12 +1144,18 @@ packages: '@types/babel__traverse@7.20.6': resolution: {integrity: sha512-r1bzfrm0tomOI8g1SzvCaQHo6Lcv6zu0EA+W2kHrt8dyrHQxGzBBL4kdkzIS+jBMV+EYcMAEAqXqYaLJq5rOZg==} + '@types/bun@1.1.8': + resolution: {integrity: sha512-PIwVFQKPviksiibobyvcWtMvMFMTj91T8dQEh9l1P3Ypr3ZuVn9w7HSr+5mTNrPqD1xpdDLEErzZPU8gqHBu6g==} + '@types/estree@1.0.5': resolution: {integrity: sha512-/kYRxGDLWzHOB7q+wtSUQlFrtcdUccpfy+X+9iMBpHK8QLLhx2wIPYuS5DYtR9Wa/YlZAbIovy7qVdB1Aq6Lyw==} '@types/json5@0.0.29': resolution: {integrity: sha512-dRLjCWHYg4oaA77cxO64oO+7JwCwnIzkZPdrrC71jQmQtlhM556pwKo5bUzqvZndkVbeFLIIi+9TC40JNF5hNQ==} + '@types/node@20.12.14': + resolution: {integrity: sha512-scnD59RpYD91xngrQQLGkE+6UrHUPzeKZWhhjBSa3HSkwjbQc38+q3RoIVEwxQGRw3M+j5hpNAM+lgV3cVormg==} + '@types/node@20.14.13': resolution: {integrity: sha512-+bHoGiZb8UiQ0+WEtmph2IWQCjIqg8MDZMAV+ppRRhUZnquF5mQkP/9vpSwJClEiSM/C7fZZExPzfU0vJTyp8w==} @@ -1067,6 +1171,9 @@ packages: '@types/react@18.3.3': resolution: {integrity: sha512-hti/R0pS0q1/xx+TsI73XIqk26eBsISZ2R0wUijXIngRK9R/e7Xw/cXVxQK7R5JjW+SV4zGcn5hXjudkN/pLIw==} + '@types/ws@8.5.12': + resolution: {integrity: sha512-3tPRkv1EtkDpzlgyKyI8pGsGZAGPEaXeu0DOj5DI25Ja91bdAYddYHbADRYVrZMRbfW+1l5YwXVDKohDJNQxkQ==} + '@typescript-eslint/parser@6.21.0': resolution: {integrity: sha512-tbsV1jPne5CkFQCgPBcDOt30ItF7aJoZL997JSF7MhGQqOeT3svWRYxiqlfA5RUdlHN6Fi+EI9bxqbdyAUZjYQ==} engines: {node: ^16.0.0 || >=18.0.0} @@ -1247,6 +1354,9 @@ packages: engines: {node: ^6 || ^7 || ^8 || ^9 || ^10 || ^11 || ^12 || >=13.7} hasBin: true + bun-types@1.1.26: + resolution: {integrity: sha512-n7jDe62LsB2+WE8Q8/mT3azkPaatKlj/2MyP6hi3mKvPz9oPpB6JW/Ll6JHtNLudasFFuvfgklYSE+rreGvBjw==} + bun@1.1.22: resolution: {integrity: sha512-G2HCPhzhjDc2jEDkZsO9vwPlpHrTm7a8UVwx9oNS5bZqo5OcSK5GPuWYDWjj7+37bRk5OVLfeIvUMtSrbKeIjQ==} os: [darwin, linux, win32] @@ -2000,13 +2110,11 @@ packages: lightningcss-darwin-arm64@1.26.0: resolution: {integrity: sha512-n4TIvHO1NY1ondKFYpL2ZX0bcC2y6yjXMD6JfyizgR8BCFNEeArINDzEaeqlfX9bXz73Bpz/Ow0nu+1qiDrBKg==} engines: {node: '>= 12.0.0'} - cpu: [arm64] os: [darwin] lightningcss-darwin-x64@1.26.0: resolution: {integrity: sha512-Rf9HuHIDi1R6/zgBkJh25SiJHF+dm9axUZW/0UoYCW1/8HV0gMI0blARhH4z+REmWiU1yYT/KyNF3h7tHyRXUg==} engines: {node: '>= 12.0.0'} - cpu: [x64] os: [darwin] lightningcss-freebsd-x64@1.26.0: @@ -2024,25 +2132,21 @@ packages: lightningcss-linux-arm64-gnu@1.26.0: resolution: {integrity: sha512-iJmZM7fUyVjH+POtdiCtExG+67TtPUTer7K/5A8DIfmPfrmeGvzfRyBltGhQz13Wi15K1lf2cPYoRaRh6vcwNA==} engines: {node: '>= 12.0.0'} - cpu: [arm64] os: [linux] lightningcss-linux-arm64-musl@1.26.0: resolution: {integrity: sha512-XxoEL++tTkyuvu+wq/QS8bwyTXZv2y5XYCMcWL45b8XwkiS8eEEEej9BkMGSRwxa5J4K+LDeIhLrS23CpQyfig==} engines: {node: '>= 12.0.0'} - cpu: [arm64] os: [linux] lightningcss-linux-x64-gnu@1.26.0: resolution: {integrity: sha512-1dkTfZQAYLj8MUSkd6L/+TWTG8V6Kfrzfa0T1fSlXCXQHrt1HC1/UepXHtKHDt/9yFwyoeayivxXAsApVxn6zA==} engines: {node: '>= 12.0.0'} - cpu: [x64] os: [linux] lightningcss-linux-x64-musl@1.26.0: resolution: {integrity: sha512-yX3Rk9m00JGCUzuUhFEojY+jf/6zHs3XU8S8Vk+FRbnr4St7cjyMXdNjuA2LjiT8e7j8xHRCH8hyZ4H/btRE4A==} engines: {node: '>= 12.0.0'} - cpu: [x64] os: [linux] lightningcss-win32-arm64-msvc@1.26.0: @@ -2054,7 +2158,6 @@ packages: lightningcss-win32-x64-msvc@1.26.0: resolution: {integrity: sha512-pYS3EyGP3JRhfqEFYmfFDiZ9/pVNfy8jVIYtrx9TVNusVyDK3gpW1w/rbvroQ4bDJi7grdUtyrYU6V2xkY/bBw==} engines: {node: '>= 12.0.0'} - cpu: [x64] os: [win32] lightningcss@1.26.0: @@ -3329,9 +3432,13 @@ snapshots: '@parcel/watcher-darwin-arm64@2.4.1': optional: true + '@parcel/watcher-darwin-arm64@2.4.2-alpha.0': {} + '@parcel/watcher-darwin-x64@2.4.1': optional: true + '@parcel/watcher-darwin-x64@2.4.2-alpha.0': {} + '@parcel/watcher-freebsd-x64@2.4.1': optional: true @@ -3341,15 +3448,23 @@ snapshots: '@parcel/watcher-linux-arm64-glibc@2.4.1': optional: true + '@parcel/watcher-linux-arm64-glibc@2.4.2-alpha.0': {} + '@parcel/watcher-linux-arm64-musl@2.4.1': optional: true + '@parcel/watcher-linux-arm64-musl@2.4.2-alpha.0': {} + '@parcel/watcher-linux-x64-glibc@2.4.1': optional: true + '@parcel/watcher-linux-x64-glibc@2.4.2-alpha.0': {} + '@parcel/watcher-linux-x64-musl@2.4.1': optional: true + '@parcel/watcher-linux-x64-musl@2.4.2-alpha.0': {} + '@parcel/watcher-win32-arm64@2.4.1': optional: true @@ -3359,7 +3474,9 @@ snapshots: '@parcel/watcher-win32-x64@2.4.1': optional: true - '@parcel/watcher@2.4.1': + '@parcel/watcher-win32-x64@2.4.2-alpha.0': {} + + '@parcel/watcher@2.4.1(patch_hash=qvoazptra62ta6otw2xgwv3msu)': dependencies: detect-libc: 1.0.3 is-glob: 4.0.3 @@ -3461,10 +3578,18 @@ snapshots: dependencies: '@babel/types': 7.25.2 + '@types/bun@1.1.8': + dependencies: + bun-types: 1.1.26 + '@types/estree@1.0.5': {} '@types/json5@0.0.29': {} + '@types/node@20.12.14': + dependencies: + undici-types: 5.26.5 + '@types/node@20.14.13': dependencies: undici-types: 5.26.5 @@ -3484,6 +3609,10 @@ snapshots: '@types/prop-types': 15.7.12 csstype: 3.1.3 + '@types/ws@8.5.12': + dependencies: + '@types/node': 20.14.13 + '@typescript-eslint/parser@6.21.0(eslint@8.57.0)(typescript@5.5.4)': dependencies: '@typescript-eslint/scope-manager': 6.21.0 @@ -3526,14 +3655,14 @@ snapshots: '@ungap/structured-clone@1.2.0': {} - '@vitejs/plugin-react@4.3.1(vite@5.4.0(@types/node@20.14.13)(lightningcss@1.26.0))': + '@vitejs/plugin-react@4.3.1(vite@5.4.0(@types/node@20.14.13)(lightningcss@1.26.0(patch_hash=2gljz2azdf5ggmo7nz3iycnapi)))': dependencies: '@babel/core': 7.25.2 '@babel/plugin-transform-react-jsx-self': 7.24.7(@babel/core@7.25.2) '@babel/plugin-transform-react-jsx-source': 7.24.7(@babel/core@7.25.2) '@types/babel__core': 7.20.5 react-refresh: 0.14.2 - vite: 5.4.0(@types/node@20.14.13)(lightningcss@1.26.0) + vite: 5.4.0(@types/node@20.14.13)(lightningcss@1.26.0(patch_hash=2gljz2azdf5ggmo7nz3iycnapi)) transitivePeerDependencies: - supports-color @@ -3715,6 +3844,11 @@ snapshots: node-releases: 2.0.18 update-browserslist-db: 1.1.0(browserslist@4.23.2) + bun-types@1.1.26: + dependencies: + '@types/node': 20.12.14 + '@types/ws': 8.5.12 + bun@1.1.22: optionalDependencies: '@oven/bun-darwin-aarch64': 1.1.22 @@ -4077,7 +4211,7 @@ snapshots: eslint: 8.57.0 eslint-import-resolver-node: 0.3.9 eslint-import-resolver-typescript: 3.6.1(@typescript-eslint/parser@6.21.0(eslint@8.57.0)(typescript@5.5.4))(eslint-import-resolver-node@0.3.9)(eslint-plugin-import@2.29.1(eslint@8.57.0))(eslint@8.57.0) - eslint-plugin-import: 2.29.1(@typescript-eslint/parser@6.21.0(eslint@8.57.0)(typescript@5.5.4))(eslint-import-resolver-typescript@3.6.1)(eslint@8.57.0) + eslint-plugin-import: 2.29.1(@typescript-eslint/parser@6.21.0(eslint@8.57.0)(typescript@5.5.4))(eslint-import-resolver-typescript@3.6.1(@typescript-eslint/parser@6.21.0(eslint@8.57.0)(typescript@5.5.4))(eslint-import-resolver-node@0.3.9)(eslint-plugin-import@2.29.1(eslint@8.57.0))(eslint@8.57.0))(eslint@8.57.0) eslint-plugin-jsx-a11y: 6.9.0(eslint@8.57.0) eslint-plugin-react: 7.35.0(eslint@8.57.0) eslint-plugin-react-hooks: 4.6.2(eslint@8.57.0) @@ -4101,7 +4235,7 @@ snapshots: enhanced-resolve: 5.17.1 eslint: 8.57.0 eslint-module-utils: 2.8.1(@typescript-eslint/parser@6.21.0(eslint@8.57.0)(typescript@5.5.4))(eslint-import-resolver-node@0.3.9)(eslint-import-resolver-typescript@3.6.1(@typescript-eslint/parser@6.21.0(eslint@8.57.0)(typescript@5.5.4))(eslint-import-resolver-node@0.3.9)(eslint-plugin-import@2.29.1(eslint@8.57.0))(eslint@8.57.0))(eslint@8.57.0) - eslint-plugin-import: 2.29.1(@typescript-eslint/parser@6.21.0(eslint@8.57.0)(typescript@5.5.4))(eslint-import-resolver-typescript@3.6.1)(eslint@8.57.0) + eslint-plugin-import: 2.29.1(@typescript-eslint/parser@6.21.0(eslint@8.57.0)(typescript@5.5.4))(eslint-import-resolver-typescript@3.6.1(@typescript-eslint/parser@6.21.0(eslint@8.57.0)(typescript@5.5.4))(eslint-import-resolver-node@0.3.9)(eslint-plugin-import@2.29.1(eslint@8.57.0))(eslint@8.57.0))(eslint@8.57.0) fast-glob: 3.3.2 get-tsconfig: 4.7.6 is-core-module: 2.15.0 @@ -4123,7 +4257,7 @@ snapshots: transitivePeerDependencies: - supports-color - eslint-plugin-import@2.29.1(@typescript-eslint/parser@6.21.0(eslint@8.57.0)(typescript@5.5.4))(eslint-import-resolver-typescript@3.6.1)(eslint@8.57.0): + eslint-plugin-import@2.29.1(@typescript-eslint/parser@6.21.0(eslint@8.57.0)(typescript@5.5.4))(eslint-import-resolver-typescript@3.6.1(@typescript-eslint/parser@6.21.0(eslint@8.57.0)(typescript@5.5.4))(eslint-import-resolver-node@0.3.9)(eslint-plugin-import@2.29.1(eslint@8.57.0))(eslint@8.57.0))(eslint@8.57.0): dependencies: array-includes: 3.1.8 array.prototype.findlastindex: 1.2.5 @@ -4688,11 +4822,9 @@ snapshots: prelude-ls: 1.2.1 type-check: 0.4.0 - lightningcss-darwin-arm64@1.26.0: - optional: true + lightningcss-darwin-arm64@1.26.0: {} - lightningcss-darwin-x64@1.26.0: - optional: true + lightningcss-darwin-x64@1.26.0: {} lightningcss-freebsd-x64@1.26.0: optional: true @@ -4700,25 +4832,20 @@ snapshots: lightningcss-linux-arm-gnueabihf@1.26.0: optional: true - lightningcss-linux-arm64-gnu@1.26.0: - optional: true + lightningcss-linux-arm64-gnu@1.26.0: {} - lightningcss-linux-arm64-musl@1.26.0: - optional: true + lightningcss-linux-arm64-musl@1.26.0: {} - lightningcss-linux-x64-gnu@1.26.0: - optional: true + lightningcss-linux-x64-gnu@1.26.0: {} - lightningcss-linux-x64-musl@1.26.0: - optional: true + lightningcss-linux-x64-musl@1.26.0: {} lightningcss-win32-arm64-msvc@1.26.0: optional: true - lightningcss-win32-x64-msvc@1.26.0: - optional: true + lightningcss-win32-x64-msvc@1.26.0: {} - lightningcss@1.26.0: + lightningcss@1.26.0(patch_hash=2gljz2azdf5ggmo7nz3iycnapi): dependencies: detect-libc: 1.0.3 optionalDependencies: @@ -5462,13 +5589,13 @@ snapshots: dependencies: punycode: 2.3.1 - vite-node@2.0.5(@types/node@20.14.13)(lightningcss@1.26.0): + vite-node@2.0.5(@types/node@20.14.13)(lightningcss@1.26.0(patch_hash=2gljz2azdf5ggmo7nz3iycnapi)): dependencies: cac: 6.7.14 debug: 4.3.6 pathe: 1.1.2 tinyrainbow: 1.2.0 - vite: 5.4.0(@types/node@20.14.13)(lightningcss@1.26.0) + vite: 5.4.0(@types/node@20.14.13)(lightningcss@1.26.0(patch_hash=2gljz2azdf5ggmo7nz3iycnapi)) transitivePeerDependencies: - '@types/node' - less @@ -5480,10 +5607,10 @@ snapshots: - supports-color - terser - vite-plugin-handlebars@2.0.0(@types/node@20.14.13)(lightningcss@1.26.0): + vite-plugin-handlebars@2.0.0(@types/node@20.14.13)(lightningcss@1.26.0(patch_hash=2gljz2azdf5ggmo7nz3iycnapi)): dependencies: handlebars: 4.7.8 - vite: 5.4.0(@types/node@20.14.13)(lightningcss@1.26.0) + vite: 5.4.0(@types/node@20.14.13)(lightningcss@1.26.0(patch_hash=2gljz2azdf5ggmo7nz3iycnapi)) transitivePeerDependencies: - '@types/node' - less @@ -5494,7 +5621,7 @@ snapshots: - sugarss - terser - vite@5.4.0(@types/node@20.14.13)(lightningcss@1.26.0): + vite@5.4.0(@types/node@20.14.13)(lightningcss@1.26.0(patch_hash=2gljz2azdf5ggmo7nz3iycnapi)): dependencies: esbuild: 0.21.5 postcss: 8.4.41 @@ -5502,9 +5629,9 @@ snapshots: optionalDependencies: '@types/node': 20.14.13 fsevents: 2.3.3 - lightningcss: 1.26.0 + lightningcss: 1.26.0(patch_hash=2gljz2azdf5ggmo7nz3iycnapi) - vitest@2.0.5(@types/node@20.14.13)(lightningcss@1.26.0): + vitest@2.0.5(@types/node@20.14.13)(lightningcss@1.26.0(patch_hash=2gljz2azdf5ggmo7nz3iycnapi)): dependencies: '@ampproject/remapping': 2.3.0 '@vitest/expect': 2.0.5 @@ -5522,8 +5649,8 @@ snapshots: tinybench: 2.9.0 tinypool: 1.0.0 tinyrainbow: 1.2.0 - vite: 5.4.0(@types/node@20.14.13)(lightningcss@1.26.0) - vite-node: 2.0.5(@types/node@20.14.13)(lightningcss@1.26.0) + vite: 5.4.0(@types/node@20.14.13)(lightningcss@1.26.0(patch_hash=2gljz2azdf5ggmo7nz3iycnapi)) + vite-node: 2.0.5(@types/node@20.14.13)(lightningcss@1.26.0(patch_hash=2gljz2azdf5ggmo7nz3iycnapi)) why-is-node-running: 2.3.0 optionalDependencies: '@types/node': 20.14.13 From fc864358175749f31ec1ab1fc233f8dbf6e424af Mon Sep 17 00:00:00 2001 From: Jordan Pittman Date: Mon, 26 Aug 2024 11:55:17 -0400 Subject: [PATCH 3/5] Attempt resolving embedded files with a relative path Bun added support for referencing embedded files with require.resolve passing in a relative path --- .../@tailwindcss-cli/src/utils/resolve.ts | 18 +++++++++- packages/@tailwindcss-standalone/build.ts | 8 +++-- packages/@tailwindcss-standalone/package.json | 3 +- packages/@tailwindcss-standalone/src/index.ts | 6 ---- .../@tailwindcss-standalone/src/plugin.ts | 31 ----------------- .../src/resolve.standalone.ts | 34 ------------------- 6 files changed, 25 insertions(+), 75 deletions(-) delete mode 100644 packages/@tailwindcss-standalone/src/plugin.ts delete mode 100644 packages/@tailwindcss-standalone/src/resolve.standalone.ts diff --git a/packages/@tailwindcss-cli/src/utils/resolve.ts b/packages/@tailwindcss-cli/src/utils/resolve.ts index 4702c2a26..35ca1997d 100644 --- a/packages/@tailwindcss-cli/src/utils/resolve.ts +++ b/packages/@tailwindcss-cli/src/utils/resolve.ts @@ -1,3 +1,19 @@ import { createRequire } from 'node:module' -export const resolve = createRequire(import.meta.url).resolve +const localResolve = createRequire(import.meta.url).resolve + +export function resolve(id: string) { + if (id.startsWith('tailwindcss/')) { + try { + return localResolve(id) + } catch (err) { + try { + return localResolve('./' + id.slice(12)) + } catch {} + + throw err + } + } + + return localResolve(id) +} diff --git a/packages/@tailwindcss-standalone/build.ts b/packages/@tailwindcss-standalone/build.ts index 4bfafd102..c89d03379 100644 --- a/packages/@tailwindcss-standalone/build.ts +++ b/packages/@tailwindcss-standalone/build.ts @@ -1,4 +1,4 @@ -import { $ } from 'bun' +import { $, Glob } from 'bun' import { createHash } from 'node:crypto' import { mkdir, readFile, writeFile } from 'node:fs/promises' import * as path from 'node:path' @@ -6,11 +6,15 @@ import { fileURLToPath } from 'node:url' const __dirname = fileURLToPath(new URL('.', import.meta.url)) +let embedded = new Glob('../tailwindcss/**/*.{css,json}') + async function buildForPlatform(triple: string, outfile: string) { + let files = Array.from(embedded.scanSync(__dirname)) + // We wrap this in a retry because occasionally the atomic rename fails for some reason for (let i = 0; i < 5; ++i) { try { - return await $`bun build --compile --target=${triple} ./src/index.ts --outfile=${outfile}` + return await $`bun build --compile --target=${triple} ./src/index.ts --outfile=${outfile} ${{ raw: files.join(' ') }}` } catch (err) { if (i < 5) continue diff --git a/packages/@tailwindcss-standalone/package.json b/packages/@tailwindcss-standalone/package.json index 7d9279fa9..13177d868 100644 --- a/packages/@tailwindcss-standalone/package.json +++ b/packages/@tailwindcss-standalone/package.json @@ -33,6 +33,7 @@ }, "__notes": "These binary packages must be included so Bun can build the CLI for all supported platforms. We also rely on Lightning CSS and Parcel being patched so Bun can statically analyze the executables.", "devDependencies": { + "bun": "^1.1.26", "@parcel/watcher-darwin-arm64": "^2.4.2-alpha.0", "@parcel/watcher-darwin-x64": "^2.4.2-alpha.0", "@parcel/watcher-linux-arm64-glibc": "^2.4.2-alpha.0", @@ -40,7 +41,7 @@ "@parcel/watcher-linux-x64-glibc": "^2.4.2-alpha.0", "@parcel/watcher-linux-x64-musl": "^2.4.2-alpha.0", "@parcel/watcher-win32-x64": "^2.4.2-alpha.0", - "@types/bun": "^1.1.6", + "@types/bun": "^1.1.8", "lightningcss-darwin-arm64": "^1.25.1", "lightningcss-darwin-x64": "^1.25.1", "lightningcss-linux-arm64-gnu": "^1.25.1", diff --git a/packages/@tailwindcss-standalone/src/index.ts b/packages/@tailwindcss-standalone/src/index.ts index 92f32dc79..1f71a7e43 100644 --- a/packages/@tailwindcss-standalone/src/index.ts +++ b/packages/@tailwindcss-standalone/src/index.ts @@ -1,7 +1 @@ -import { plugin } from 'bun' -import { resolution } from './plugin.ts' - -plugin(resolution) - -await new Promise((resolve) => setTimeout(resolve)) await import('../../@tailwindcss-cli/src/index.ts') diff --git a/packages/@tailwindcss-standalone/src/plugin.ts b/packages/@tailwindcss-standalone/src/plugin.ts deleted file mode 100644 index a4eea590e..000000000 --- a/packages/@tailwindcss-standalone/src/plugin.ts +++ /dev/null @@ -1,31 +0,0 @@ -import type { BunPlugin } from 'bun' - -export const resolution: BunPlugin = { - name: 'Custom loader', - target: 'bun', - setup(build) { - // onLoad - // build.onLoad({ filter: /./ }, async (file) => { - // console.log({ file }) - // return { - // loader: 'object', - // exports: {}, - // } - // }) - - // Replace resolve.ts with the local resolve.standalone.ts - build.onResolve({ filter: /./ }, (file) => { - console.log('on resolve', { file }) - - return undefined - - // return { - // path: require.resolve(file.path), - // } - - // return Object.assign(file, { - // path: require.resolve('./resolve.standalone.ts'), - // }) - }) - }, -} diff --git a/packages/@tailwindcss-standalone/src/resolve.standalone.ts b/packages/@tailwindcss-standalone/src/resolve.standalone.ts deleted file mode 100644 index f2251dbca..000000000 --- a/packages/@tailwindcss-standalone/src/resolve.standalone.ts +++ /dev/null @@ -1,34 +0,0 @@ -// @ts-ignore -import twIndex from 'tailwindcss/index.css' with { type: 'file' } - -// @ts-ignore -import twPreflight from 'tailwindcss/preflight.css' with { type: 'file' } - -// @ts-ignore -import twTheme from 'tailwindcss/theme.css' with { type: 'file' } - -// @ts-ignore -import twUtilities from 'tailwindcss/utilities.css' with { type: 'file' } - -// @ts-ignore -// import twPkg from 'tailwindcss/package.json' with { type: 'file' } - -import { createRequire } from 'node:module' - -const localResolve = createRequire(import.meta.url).resolve - -export function resolve(id: string) { - if (id === 'tailwindcss/index.css') { - return twIndex - } else if (id === 'tailwindcss/preflight.css') { - return twPreflight - } else if (id === 'tailwindcss/theme.css') { - return twTheme - } else if (id === 'tailwindcss/utilities.css') { - return twUtilities - } else if (id === 'tailwindcss/package.json') { - return twPkg - } else { - return localResolve(id) - } -} From 9e9fbbc7e5bbb474b20a9cca55a2a7ecc3220e3e Mon Sep 17 00:00:00 2001 From: Jordan Pittman Date: Mon, 26 Aug 2024 11:56:18 -0400 Subject: [PATCH 4/5] Add commented out test case for embedded files bug --- packages/@tailwindcss-standalone/src/index.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/packages/@tailwindcss-standalone/src/index.ts b/packages/@tailwindcss-standalone/src/index.ts index 1f71a7e43..59b8e4d2e 100644 --- a/packages/@tailwindcss-standalone/src/index.ts +++ b/packages/@tailwindcss-standalone/src/index.ts @@ -1 +1,5 @@ +// import { embeddedFiles } from 'bun' +// console.log({ embeddedFiles }) +// console.log(require(`@parcel/watcher-${process.platform}-${process.arch}`)) + await import('../../@tailwindcss-cli/src/index.ts') From 2c5461580f3f365a9a189f4011ac1b1d43c5ed73 Mon Sep 17 00:00:00 2001 From: Jordan Pittman Date: Mon, 26 Aug 2024 11:56:21 -0400 Subject: [PATCH 5/5] Update lockfile --- pnpm-lock.yaml | 86 +++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 85 insertions(+), 1 deletion(-) diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 35146a646..d2c453786 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -229,8 +229,11 @@ importers: specifier: ^2.4.2-alpha.0 version: 2.4.2-alpha.0 '@types/bun': - specifier: ^1.1.6 + specifier: ^1.1.8 version: 1.1.8 + bun: + specifier: ^1.1.26 + version: 1.1.26 lightningcss-darwin-arm64: specifier: ^1.25.1 version: 1.26.0 @@ -891,41 +894,81 @@ packages: cpu: [arm64] os: [darwin] + '@oven/bun-darwin-aarch64@1.1.26': + resolution: {integrity: sha512-E8/3i0RIvsIWS+kyeIlbwBh+4qB5DsQIfcO6xr4p3t7tEzvRWnrFkJrbJthru/eB1UsVV9PJ/hsxTrp3m3za4A==} + cpu: [arm64] + os: [darwin] + '@oven/bun-darwin-x64-baseline@1.1.22': resolution: {integrity: sha512-r1IOBt7A3NVfM3/PYkfpef3fo1cIdznRzCpE/XwEquYBbMFcvRETWWRUUNK80MFttYaPQuhyHui/b0VLJhoaEw==} cpu: [x64] os: [darwin] + '@oven/bun-darwin-x64-baseline@1.1.26': + resolution: {integrity: sha512-36HQlQfbrwP//xOS5VFN9AR/iH6BDQo3y8j5282DmRO+h6jylwlg+2+Sfz+1uXDOLDQWCbnNv3Mpl8+Ltso6cQ==} + cpu: [x64] + os: [darwin] + '@oven/bun-darwin-x64@1.1.22': resolution: {integrity: sha512-keEPJtDlvu/36J+NX1JUh6+u0PiyoRLVGdDNaVU5LsphnYIVL8A4VLAE+xA5FMPlvMyjVua8kYbgUuTTHJJGpg==} cpu: [x64] os: [darwin] + '@oven/bun-darwin-x64@1.1.26': + resolution: {integrity: sha512-ENRAAGBr2zh0VfETZXqcNPO3ZnnKDX3U6E/oWY+J70uWa9dJqRlRaj1oLB63AGoYJBNdhEcsSmTAk7toCJ+PGQ==} + cpu: [x64] + os: [darwin] + '@oven/bun-linux-aarch64@1.1.22': resolution: {integrity: sha512-qL7IVUIaCFzSYae1UhX0rSbG1I1ARH7t3d9EMUxG//nBOqdI5xgEmpFCWPh8Y1mdpPl3bPMT0EvmNx/HjFrUJw==} cpu: [arm64] os: [linux] + '@oven/bun-linux-aarch64@1.1.26': + resolution: {integrity: sha512-MqE/ClaEMW6B5i5UIYJnHbadWLt6QQQHV3NBlXd78Mhx1OiZY0YmARQmAItPUp9mxIEgGuA2QyrKvgGD3pzWPQ==} + cpu: [arm64] + os: [linux] + '@oven/bun-linux-x64-baseline@1.1.22': resolution: {integrity: sha512-xTaKbyAxn4jI5CaL13mhkj/wCNphDVHrxMIEfPW4rkVbnY/4Ci2uG9dRrNAXCxwRmyflcp8t2KWmmAUBS95McQ==} cpu: [x64] os: [linux] + '@oven/bun-linux-x64-baseline@1.1.26': + resolution: {integrity: sha512-jQeSLodwfQu5pG529jYG73VSFq26hdrTspxo9E/1B1WvwKrs2Vtz3w32zv+JWH+gvZqc28A/yK6pAmzQMiscNg==} + cpu: [x64] + os: [linux] + '@oven/bun-linux-x64@1.1.22': resolution: {integrity: sha512-y4ugmfIg9GlXgZPj2mE5D9g+ou8kwMgSraR4zWvaPPSGDB2nbULGAA9S5DCVEBAuTBxMgh3wXlEgZwQKPmDPuQ==} cpu: [x64] os: [linux] + '@oven/bun-linux-x64@1.1.26': + resolution: {integrity: sha512-sD/ZegJpnBg93qsKsiGnJgTROc68CWONwZpvtL65cBROLBqKb965ofhPUaM5oV8HckfaTDmT37cks59hG+tHvw==} + cpu: [x64] + os: [linux] + '@oven/bun-windows-x64-baseline@1.1.22': resolution: {integrity: sha512-Xdf0ZgonVup+YgFSTaGkzDpgcxojc2whFcaNvV0BJtTsl2MeAwGFl98AziGJSCh0ooG80ipUEIUoxDJBWxaEYw==} cpu: [x64] os: [win32] + '@oven/bun-windows-x64-baseline@1.1.26': + resolution: {integrity: sha512-qb593xu9WIKBCHd47z7ZaZTC9h8r4T6qDbBV/XGLhxdZEJb24ePWdhW8WoHxa9hsATio9SByozqwblXb2tJncw==} + cpu: [x64] + os: [win32] + '@oven/bun-windows-x64@1.1.22': resolution: {integrity: sha512-VNgJaK54MnyS4o47JBN0oMh+75kgaHrMt3HWS3Ree1zn2qYyAexeC9m6KPynHGtNFQrxuhHv5ULxJ0Z0pAU7+A==} cpu: [x64] os: [win32] + '@oven/bun-windows-x64@1.1.26': + resolution: {integrity: sha512-EkyW6JYnZPFxD9XsdEDqFxVCnWnAoyacUAiOEUYAiz8LsnbHLMlOfbdw7KYzvm7UPFoEkUZKD78eSdpg6q6c+Q==} + cpu: [x64] + os: [win32] + '@parcel/watcher-android-arm64@2.4.1': resolution: {integrity: sha512-LOi/WTbbh3aTn2RYddrO8pnapixAziFl6SMxHM69r3tvdSm94JtCenaKgk1GRg5FJ5wpMCpHeW+7yqPlvZv7kg==} engines: {node: '>= 10.0.0'} @@ -1362,6 +1405,12 @@ packages: os: [darwin, linux, win32] hasBin: true + bun@1.1.26: + resolution: {integrity: sha512-dWSewAqE7sVbYmflJxgG47dW4vmsbar7VAnQ4ao45y3ulr3n7CwdsMLFnzd28jhPRtF+rsaVK2y4OLIkP3OD4A==} + cpu: [arm64, x64] + os: [darwin, linux, win32] + hasBin: true + bundle-require@5.0.0: resolution: {integrity: sha512-GuziW3fSSmopcx4KRymQEJVbZUfqlCqcq7dvs6TYwKRZiegK/2buMxQTPs6MGlNv50wms1699qYO54R8XfRX4w==} engines: {node: ^12.20.0 || ^14.13.1 || >=16.0.0} @@ -3405,27 +3454,51 @@ snapshots: '@oven/bun-darwin-aarch64@1.1.22': optional: true + '@oven/bun-darwin-aarch64@1.1.26': + optional: true + '@oven/bun-darwin-x64-baseline@1.1.22': optional: true + '@oven/bun-darwin-x64-baseline@1.1.26': + optional: true + '@oven/bun-darwin-x64@1.1.22': optional: true + '@oven/bun-darwin-x64@1.1.26': + optional: true + '@oven/bun-linux-aarch64@1.1.22': optional: true + '@oven/bun-linux-aarch64@1.1.26': + optional: true + '@oven/bun-linux-x64-baseline@1.1.22': optional: true + '@oven/bun-linux-x64-baseline@1.1.26': + optional: true + '@oven/bun-linux-x64@1.1.22': optional: true + '@oven/bun-linux-x64@1.1.26': + optional: true + '@oven/bun-windows-x64-baseline@1.1.22': optional: true + '@oven/bun-windows-x64-baseline@1.1.26': + optional: true + '@oven/bun-windows-x64@1.1.22': optional: true + '@oven/bun-windows-x64@1.1.26': + optional: true + '@parcel/watcher-android-arm64@2.4.1': optional: true @@ -3860,6 +3933,17 @@ snapshots: '@oven/bun-windows-x64': 1.1.22 '@oven/bun-windows-x64-baseline': 1.1.22 + bun@1.1.26: + optionalDependencies: + '@oven/bun-darwin-aarch64': 1.1.26 + '@oven/bun-darwin-x64': 1.1.26 + '@oven/bun-darwin-x64-baseline': 1.1.26 + '@oven/bun-linux-aarch64': 1.1.26 + '@oven/bun-linux-x64': 1.1.26 + '@oven/bun-linux-x64-baseline': 1.1.26 + '@oven/bun-windows-x64': 1.1.26 + '@oven/bun-windows-x64-baseline': 1.1.26 + bundle-require@5.0.0(esbuild@0.23.0): dependencies: esbuild: 0.23.0