tailwind-hyperclay 0.1.9 → 0.1.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/index.js +33 -4
  2. package/package.json +3 -2
package/index.js CHANGED
@@ -1,6 +1,28 @@
1
1
  const { readFile, writeFile } = require('fs/promises');
2
2
  const path = require('path');
3
- const { compile } = require('tailwindcss');
3
+
4
+ let compile;
5
+ try {
6
+ const tw = require('tailwindcss');
7
+ compile = tw.compile;
8
+ } catch (e) {
9
+ // Fallback for Electron asarUnpack issue
10
+ if (process.versions.electron) {
11
+ try {
12
+ // Try to look for it in app.asar.unpacked
13
+ // process.resourcesPath usually points to Contents/Resources
14
+ // Point directly to the dist file to bypass package.json exports resolution issues in ASAR
15
+ const unpackedPath = path.join(process.resourcesPath, 'app.asar.unpacked', 'node_modules', 'tailwindcss', 'dist', 'lib.js');
16
+ const tw = require(unpackedPath);
17
+ compile = tw.compile;
18
+ } catch (e2) {
19
+ console.error('Failed to load tailwindcss from unpacked path:', e2);
20
+ throw e;
21
+ }
22
+ } else {
23
+ throw e;
24
+ }
25
+ }
4
26
 
5
27
  async function generateCSS({ input, output }) {
6
28
  const html = await readFile(input, 'utf-8');
@@ -22,10 +44,16 @@ async function compileTailwind(html) {
22
44
  @plugin "@tailwindcss/forms" { strategy: "class"; }
23
45
  `;
24
46
 
47
+ // Use process.resourcesPath in Electron (production), otherwise __dirname
48
+ // This ensures we don't rely on process.cwd() which is '/' when double-clicking the app
49
+ const defaultBase = process.versions.electron && process.resourcesPath
50
+ ? path.join(process.resourcesPath, 'app.asar.unpacked', 'node_modules')
51
+ : __dirname;
52
+
25
53
  const compiler = await compile(inputCSS, {
26
54
  loadStylesheet: async (id, base) => {
27
55
  let resolved;
28
- const searchPaths = [base || process.cwd()];
56
+ const searchPaths = [base || defaultBase];
29
57
 
30
58
  // Try resolving as-is first (for .css files)
31
59
  try {
@@ -48,12 +76,13 @@ async function compileTailwind(html) {
48
76
  return { content, base: path.dirname(resolved) };
49
77
  },
50
78
  loadModule: async (id, base) => {
51
- const resolved = require.resolve(id, { paths: [base || process.cwd()] });
79
+ const resolved = require.resolve(id, { paths: [base || defaultBase] });
52
80
  const mod = require(resolved);
53
81
  return { module: mod.default || mod, base: path.dirname(resolved) };
54
82
  },
55
83
  loadPlugin: async (plugin) => {
56
- const resolved = require.resolve(plugin);
84
+ // Plugins need to be found in the app's node_modules
85
+ const resolved = require.resolve(plugin, { paths: [defaultBase] });
57
86
  const mod = require(resolved);
58
87
  return mod.default || mod;
59
88
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tailwind-hyperclay",
3
- "version": "0.1.9",
3
+ "version": "0.1.11",
4
4
  "description": "On-save Tailwind CSS generator for Hyperclay",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -17,6 +17,7 @@
17
17
  "dependencies": {
18
18
  "tailwindcss": "^4.0.0-beta.8",
19
19
  "@tailwindcss/typography": "^0.5.15",
20
- "@tailwindcss/forms": "^0.5.9"
20
+ "@tailwindcss/forms": "^0.5.9",
21
+ "postcss-selector-parser": "6.0.10"
21
22
  }
22
23
  }