@flairjs/webpack-loader 0.0.1-beta.6 → 0.0.1-beta.7

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.
package/dist/cjs/index.js CHANGED
@@ -96,8 +96,8 @@ var Store = class {
96
96
  };
97
97
  const store = new Store();
98
98
  const __dirname$1 = (0, node_path.dirname)((0, node_url.fileURLToPath)(require("url").pathToFileURL(__filename).href));
99
- const getUserTheme = async () => {
100
- if (store.getUserTheme()) return store.getUserTheme();
99
+ const getUserTheme = async (options) => {
100
+ if (store.getUserTheme() && !options?.ignoreCache) return store.getUserTheme();
101
101
  try {
102
102
  let userThemeFilePath = path.default.resolve(process.cwd(), "flair.theme.ts");
103
103
  if (!(0, fs.existsSync)(userThemeFilePath)) userThemeFilePath = path.default.resolve(process.cwd(), "flair.theme.js");
@@ -155,7 +155,7 @@ const setupGeneratedCssDir = async (options) => {
155
155
  }
156
156
  return flairGeneratedCssDir;
157
157
  };
158
- const setupUserThemeFile = async ({ buildThemeFile }) => {
158
+ const setupUserThemeFile = async ({ buildThemeFile, onThemeFileChange }) => {
159
159
  const flairThemeFile = require$1.resolve("@flairjs/client/theme.css");
160
160
  let userTheme = await getUserTheme();
161
161
  const buildThemeCSS = buildThemeFile ?? buildThemeTokens;
@@ -168,6 +168,7 @@ const setupUserThemeFile = async ({ buildThemeFile }) => {
168
168
  store.setLastThemeUpdate(Date.now());
169
169
  if (!userTheme) return;
170
170
  const themeCSS$1 = buildThemeCSS(userTheme.theme);
171
+ onThemeFileChange?.();
171
172
  await (0, node_fs_promises.writeFile)(flairThemeFile, themeCSS$1, "utf-8");
172
173
  });
173
174
  }
package/dist/esm/index.js CHANGED
@@ -62,8 +62,8 @@ var Store = class {
62
62
  };
63
63
  const store = new Store();
64
64
  const __dirname = dirname(fileURLToPath(import.meta.url));
65
- const getUserTheme = async () => {
66
- if (store.getUserTheme()) return store.getUserTheme();
65
+ const getUserTheme = async (options) => {
66
+ if (store.getUserTheme() && !options?.ignoreCache) return store.getUserTheme();
67
67
  try {
68
68
  let userThemeFilePath = path$1.resolve(process.cwd(), "flair.theme.ts");
69
69
  if (!existsSync$1(userThemeFilePath)) userThemeFilePath = path$1.resolve(process.cwd(), "flair.theme.js");
@@ -121,7 +121,7 @@ const setupGeneratedCssDir = async (options) => {
121
121
  }
122
122
  return flairGeneratedCssDir;
123
123
  };
124
- const setupUserThemeFile = async ({ buildThemeFile }) => {
124
+ const setupUserThemeFile = async ({ buildThemeFile, onThemeFileChange }) => {
125
125
  const flairThemeFile = require.resolve("@flairjs/client/theme.css");
126
126
  let userTheme = await getUserTheme();
127
127
  const buildThemeCSS = buildThemeFile ?? buildThemeTokens;
@@ -134,6 +134,7 @@ const setupUserThemeFile = async ({ buildThemeFile }) => {
134
134
  store.setLastThemeUpdate(Date.now());
135
135
  if (!userTheme) return;
136
136
  const themeCSS$1 = buildThemeCSS(userTheme.theme);
137
+ onThemeFileChange?.();
137
138
  await writeFile(flairThemeFile, themeCSS$1, "utf-8");
138
139
  });
139
140
  }
@@ -1,6 +1,33 @@
1
- import { SharedPluginOptions } from "@flairjs/bundler-shared";
2
- import { LoaderContext } from "webpack";
3
- interface FlairJsWebpackLoaderOptions extends SharedPluginOptions {
4
- }
5
- export default function flairJsLoader(this: LoaderContext<FlairJsWebpackLoaderOptions>, source: string, sourceMap: string): Promise<void>;
6
- export {};
1
+ import { FlairThemeConfig } from '@flairjs/client';
2
+ import { LoaderContext } from 'webpack';
3
+
4
+ declare function flairJsLoader(this: LoaderContext<FlairJsWebpackLoaderOptions>, source: string, sourceMap: string): Promise<void>;
5
+ export default flairJsLoader;
6
+
7
+ declare interface FlairJsWebpackLoaderOptions extends SharedPluginOptions {
8
+ }
9
+
10
+ declare interface SharedPluginOptions {
11
+ /**
12
+ * Preprocess the extracted CSS before it is passed to lightningcss
13
+ * @experimental
14
+ * @param css the extracted css
15
+ * @param id the id of the file being processed
16
+ * @returns the processed css
17
+ */
18
+ cssPreprocessor?: (css: string, id: string) => string;
19
+ include?: string | string[];
20
+ exclude?: string | string[];
21
+ /**
22
+ * Override the default theme file content based on the user theme
23
+ * @param theme the user theme
24
+ * @returns the theme file content
25
+ */
26
+ buildThemeFile?: (theme: FlairThemeConfig) => string;
27
+ /**
28
+ * List of class names used in the project. Supports regex.
29
+ */
30
+ classNameList?: string[];
31
+ }
32
+
33
+ export { }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@flairjs/webpack-loader",
3
- "version": "0.0.1-beta.6",
3
+ "version": "0.0.1-beta.7",
4
4
  "main": "./dist/cjs/index.js",
5
5
  "module": "./dist/esm/index.js",
6
6
  "types": "./dist/types/index.d.ts",
@@ -13,24 +13,25 @@
13
13
  },
14
14
  "peerDependencies": {
15
15
  "webpack": ">=5.0.0",
16
- "@flairjs/core": "0.0.1-beta.5"
16
+ "@flairjs/core": "0.0.1-beta.6"
17
17
  },
18
18
  "devDependencies": {
19
- "@biomejs/biome": "^1.9.4",
20
- "@rollup/plugin-typescript": "^12.1.4",
19
+ "@biomejs/biome": "^2.2.4",
20
+ "@microsoft/api-extractor": "^7.52.13",
21
21
  "@types/node": "^22.8.1",
22
+ "rimraf": "^6.0.1",
22
23
  "rolldown": "1.0.0-beta.37",
23
24
  "typescript": "^5.8.2",
24
25
  "webpack": "^5.101.0",
25
- "@flairjs/bundler-shared": "0.0.1-beta.9",
26
- "@flairjs/core": "0.0.1-beta.5"
26
+ "@flairjs/bundler-shared": "0.0.1-beta.10",
27
+ "@flairjs/core": "0.0.1-beta.6"
27
28
  },
28
29
  "dependencies": {
29
30
  "esbuild": "^0.25.10",
30
31
  "picomatch": "^4.0.3"
31
32
  },
32
33
  "scripts": {
33
- "build": "tsc && rolldown -c",
34
+ "build": "rimraf dist && tsc && api-extractor run --local && rolldown -c && rimraf dist/types-temp",
34
35
  "check": "biome check --write",
35
36
  "dev": "rolldown -w -c",
36
37
  "format": "biome format --write"