@flairjs/webpack-loader 0.0.1-beta.4 → 0.0.1-beta.6
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 +18 -10
- package/dist/esm/index.js +18 -10
- package/dist/types/index.js +19 -11
- package/package.json +3 -3
package/dist/cjs/index.js
CHANGED
|
@@ -135,11 +135,12 @@ const getGeneratedCssDir = () => {
|
|
|
135
135
|
const flairThemeFile = require$1.resolve("@flairjs/client/theme.css");
|
|
136
136
|
return node_path.default.resolve(flairThemeFile, "../generated-css");
|
|
137
137
|
};
|
|
138
|
-
const setupGeneratedCssDir = async () => {
|
|
138
|
+
const setupGeneratedCssDir = async (options) => {
|
|
139
139
|
const flairGeneratedCssDir = getGeneratedCssDir();
|
|
140
|
+
const { clearExisting = true } = options ?? {};
|
|
140
141
|
try {
|
|
141
142
|
if (!(0, node_fs.existsSync)(flairGeneratedCssDir)) await (0, node_fs_promises.mkdir)(flairGeneratedCssDir);
|
|
142
|
-
else {
|
|
143
|
+
else if (clearExisting) {
|
|
143
144
|
await (0, node_fs_promises.rm)(flairGeneratedCssDir, {
|
|
144
145
|
recursive: true,
|
|
145
146
|
force: true
|
|
@@ -172,16 +173,23 @@ const setupUserThemeFile = async ({ buildThemeFile }) => {
|
|
|
172
173
|
}
|
|
173
174
|
return userTheme;
|
|
174
175
|
};
|
|
175
|
-
const removeOutdatedCssFiles = async (sourceFilePath, cssFilePath, { flairGeneratedCssDir }) => {
|
|
176
|
+
const removeOutdatedCssFiles = async (sourceFilePath, cssFilePath, { flairGeneratedCssDir, clearInstantly = false }) => {
|
|
176
177
|
const previousGeneratedCssName = store.getGeneratedCssName(sourceFilePath);
|
|
177
|
-
if (previousGeneratedCssName && previousGeneratedCssName !== cssFilePath)
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
178
|
+
if (previousGeneratedCssName && previousGeneratedCssName !== cssFilePath) {
|
|
179
|
+
if (clearInstantly) {
|
|
180
|
+
await (0, node_fs_promises.rm)(node_path.default.join(flairGeneratedCssDir, previousGeneratedCssName), { force: true });
|
|
181
|
+
store.setFileNameToGeneratedCssNameMap(sourceFilePath, cssFilePath);
|
|
182
|
+
return;
|
|
183
|
+
}
|
|
184
|
+
setTimeout(() => {
|
|
185
|
+
(0, node_fs_promises.rm)(node_path.default.join(flairGeneratedCssDir, previousGeneratedCssName), { force: true });
|
|
186
|
+
}, 2e3);
|
|
187
|
+
}
|
|
188
|
+
store.setFileNameToGeneratedCssNameMap(sourceFilePath, cssFilePath);
|
|
181
189
|
};
|
|
182
190
|
function shouldProcessFile(id, include, exclude) {
|
|
183
191
|
const isIncluded = (0, picomatch.default)(include ?? ["**/*.{js,ts,jsx,tsx}"]);
|
|
184
|
-
const isExcluded = (0, picomatch.default)(exclude ?? ["node_modules/**"]);
|
|
192
|
+
const isExcluded = (0, picomatch.default)(exclude ?? ["**/node_modules/**"]);
|
|
185
193
|
if (!isIncluded(normalizeFilePath(id))) return false;
|
|
186
194
|
if (isExcluded(normalizeFilePath(id))) return false;
|
|
187
195
|
return true;
|
|
@@ -238,6 +246,8 @@ async function flairJsLoader(source, sourceMap) {
|
|
|
238
246
|
console.error("@flairjs/webpack-loader requires async support");
|
|
239
247
|
return;
|
|
240
248
|
}
|
|
249
|
+
const fileName = this.resourcePath;
|
|
250
|
+
if (!shouldProcessFile(fileName, options?.include, options?.exclude)) return callback(null, source, sourceMap);
|
|
241
251
|
let cssGeneratedDir = null;
|
|
242
252
|
let userTheme = null;
|
|
243
253
|
if (!initialized) {
|
|
@@ -248,8 +258,6 @@ async function flairJsLoader(source, sourceMap) {
|
|
|
248
258
|
cssGeneratedDir = getGeneratedCssDir();
|
|
249
259
|
userTheme = await getUserTheme();
|
|
250
260
|
}
|
|
251
|
-
const fileName = this.resourcePath;
|
|
252
|
-
if (!shouldProcessFile(fileName, options?.include, options?.exclude)) return callback(null, source, sourceMap);
|
|
253
261
|
if (!cssGeneratedDir) {
|
|
254
262
|
console.error("[flairjs] Could not find generated CSS directory. Skipping processing.");
|
|
255
263
|
return callback(null, source, sourceMap);
|
package/dist/esm/index.js
CHANGED
|
@@ -101,11 +101,12 @@ const getGeneratedCssDir = () => {
|
|
|
101
101
|
const flairThemeFile = require.resolve("@flairjs/client/theme.css");
|
|
102
102
|
return path.resolve(flairThemeFile, "../generated-css");
|
|
103
103
|
};
|
|
104
|
-
const setupGeneratedCssDir = async () => {
|
|
104
|
+
const setupGeneratedCssDir = async (options) => {
|
|
105
105
|
const flairGeneratedCssDir = getGeneratedCssDir();
|
|
106
|
+
const { clearExisting = true } = options ?? {};
|
|
106
107
|
try {
|
|
107
108
|
if (!existsSync(flairGeneratedCssDir)) await mkdir(flairGeneratedCssDir);
|
|
108
|
-
else {
|
|
109
|
+
else if (clearExisting) {
|
|
109
110
|
await rm(flairGeneratedCssDir, {
|
|
110
111
|
recursive: true,
|
|
111
112
|
force: true
|
|
@@ -138,16 +139,23 @@ const setupUserThemeFile = async ({ buildThemeFile }) => {
|
|
|
138
139
|
}
|
|
139
140
|
return userTheme;
|
|
140
141
|
};
|
|
141
|
-
const removeOutdatedCssFiles = async (sourceFilePath, cssFilePath, { flairGeneratedCssDir }) => {
|
|
142
|
+
const removeOutdatedCssFiles = async (sourceFilePath, cssFilePath, { flairGeneratedCssDir, clearInstantly = false }) => {
|
|
142
143
|
const previousGeneratedCssName = store.getGeneratedCssName(sourceFilePath);
|
|
143
|
-
if (previousGeneratedCssName && previousGeneratedCssName !== cssFilePath)
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
144
|
+
if (previousGeneratedCssName && previousGeneratedCssName !== cssFilePath) {
|
|
145
|
+
if (clearInstantly) {
|
|
146
|
+
await rm(path.join(flairGeneratedCssDir, previousGeneratedCssName), { force: true });
|
|
147
|
+
store.setFileNameToGeneratedCssNameMap(sourceFilePath, cssFilePath);
|
|
148
|
+
return;
|
|
149
|
+
}
|
|
150
|
+
setTimeout(() => {
|
|
151
|
+
rm(path.join(flairGeneratedCssDir, previousGeneratedCssName), { force: true });
|
|
152
|
+
}, 2e3);
|
|
153
|
+
}
|
|
154
|
+
store.setFileNameToGeneratedCssNameMap(sourceFilePath, cssFilePath);
|
|
147
155
|
};
|
|
148
156
|
function shouldProcessFile(id, include, exclude) {
|
|
149
157
|
const isIncluded = picomatch(include ?? ["**/*.{js,ts,jsx,tsx}"]);
|
|
150
|
-
const isExcluded = picomatch(exclude ?? ["node_modules/**"]);
|
|
158
|
+
const isExcluded = picomatch(exclude ?? ["**/node_modules/**"]);
|
|
151
159
|
if (!isIncluded(normalizeFilePath(id))) return false;
|
|
152
160
|
if (isExcluded(normalizeFilePath(id))) return false;
|
|
153
161
|
return true;
|
|
@@ -204,6 +212,8 @@ async function flairJsLoader(source, sourceMap) {
|
|
|
204
212
|
console.error("@flairjs/webpack-loader requires async support");
|
|
205
213
|
return;
|
|
206
214
|
}
|
|
215
|
+
const fileName = this.resourcePath;
|
|
216
|
+
if (!shouldProcessFile(fileName, options?.include, options?.exclude)) return callback(null, source, sourceMap);
|
|
207
217
|
let cssGeneratedDir = null;
|
|
208
218
|
let userTheme = null;
|
|
209
219
|
if (!initialized) {
|
|
@@ -214,8 +224,6 @@ async function flairJsLoader(source, sourceMap) {
|
|
|
214
224
|
cssGeneratedDir = getGeneratedCssDir();
|
|
215
225
|
userTheme = await getUserTheme();
|
|
216
226
|
}
|
|
217
|
-
const fileName = this.resourcePath;
|
|
218
|
-
if (!shouldProcessFile(fileName, options?.include, options?.exclude)) return callback(null, source, sourceMap);
|
|
219
227
|
if (!cssGeneratedDir) {
|
|
220
228
|
console.error("[flairjs] Could not find generated CSS directory. Skipping processing.");
|
|
221
229
|
return callback(null, source, sourceMap);
|
package/dist/types/index.js
CHANGED
|
@@ -4046,11 +4046,12 @@ const getGeneratedCssDir = () => {
|
|
|
4046
4046
|
const flairThemeFile = require$1.resolve("@flairjs/client/theme.css");
|
|
4047
4047
|
return path.resolve(flairThemeFile, "../generated-css");
|
|
4048
4048
|
};
|
|
4049
|
-
const setupGeneratedCssDir = async () => {
|
|
4049
|
+
const setupGeneratedCssDir = async (options) => {
|
|
4050
4050
|
const flairGeneratedCssDir = getGeneratedCssDir();
|
|
4051
|
+
const { clearExisting = true } = options ?? {};
|
|
4051
4052
|
try {
|
|
4052
4053
|
if (!existsSync(flairGeneratedCssDir)) await mkdir(flairGeneratedCssDir);
|
|
4053
|
-
else {
|
|
4054
|
+
else if (clearExisting) {
|
|
4054
4055
|
await rm(flairGeneratedCssDir, {
|
|
4055
4056
|
recursive: true,
|
|
4056
4057
|
force: true
|
|
@@ -4083,16 +4084,23 @@ const setupUserThemeFile = async ({ buildThemeFile }) => {
|
|
|
4083
4084
|
}
|
|
4084
4085
|
return userTheme;
|
|
4085
4086
|
};
|
|
4086
|
-
const removeOutdatedCssFiles = async (sourceFilePath, cssFilePath, { flairGeneratedCssDir }) => {
|
|
4087
|
+
const removeOutdatedCssFiles = async (sourceFilePath, cssFilePath, { flairGeneratedCssDir, clearInstantly = false }) => {
|
|
4087
4088
|
const previousGeneratedCssName = store.getGeneratedCssName(sourceFilePath);
|
|
4088
|
-
if (previousGeneratedCssName && previousGeneratedCssName !== cssFilePath)
|
|
4089
|
-
|
|
4090
|
-
|
|
4091
|
-
|
|
4089
|
+
if (previousGeneratedCssName && previousGeneratedCssName !== cssFilePath) {
|
|
4090
|
+
if (clearInstantly) {
|
|
4091
|
+
await rm(path.join(flairGeneratedCssDir, previousGeneratedCssName), { force: true });
|
|
4092
|
+
store.setFileNameToGeneratedCssNameMap(sourceFilePath, cssFilePath);
|
|
4093
|
+
return;
|
|
4094
|
+
}
|
|
4095
|
+
setTimeout(() => {
|
|
4096
|
+
rm(path.join(flairGeneratedCssDir, previousGeneratedCssName), { force: true });
|
|
4097
|
+
}, 2e3);
|
|
4098
|
+
}
|
|
4099
|
+
store.setFileNameToGeneratedCssNameMap(sourceFilePath, cssFilePath);
|
|
4092
4100
|
};
|
|
4093
4101
|
function shouldProcessFile(id, include, exclude) {
|
|
4094
4102
|
const isIncluded = (0, import_picomatch.default)(include ?? ["**/*.{js,ts,jsx,tsx}"]);
|
|
4095
|
-
const isExcluded = (0, import_picomatch.default)(exclude ?? ["node_modules/**"]);
|
|
4103
|
+
const isExcluded = (0, import_picomatch.default)(exclude ?? ["**/node_modules/**"]);
|
|
4096
4104
|
if (!isIncluded(normalizeFilePath(id))) return false;
|
|
4097
4105
|
if (isExcluded(normalizeFilePath(id))) return false;
|
|
4098
4106
|
return true;
|
|
@@ -4144,7 +4152,7 @@ const transformCode = (code, filePath, options) => {
|
|
|
4144
4152
|
var initialized = false;
|
|
4145
4153
|
function flairJsLoader(source, sourceMap) {
|
|
4146
4154
|
return __awaiter(this, void 0, void 0, function() {
|
|
4147
|
-
var callback, options, cssGeneratedDir, userTheme,
|
|
4155
|
+
var callback, options, fileName, cssGeneratedDir, userTheme, result;
|
|
4148
4156
|
var _a$1;
|
|
4149
4157
|
return __generator(this, function(_b) {
|
|
4150
4158
|
switch (_b.label) {
|
|
@@ -4155,6 +4163,8 @@ function flairJsLoader(source, sourceMap) {
|
|
|
4155
4163
|
console.error("@flairjs/webpack-loader requires async support");
|
|
4156
4164
|
return [2];
|
|
4157
4165
|
}
|
|
4166
|
+
fileName = this.resourcePath;
|
|
4167
|
+
if (!shouldProcessFile(fileName, options === null || options === void 0 ? void 0 : options.include, options === null || options === void 0 ? void 0 : options.exclude)) return [2, callback(null, source, sourceMap)];
|
|
4158
4168
|
cssGeneratedDir = null;
|
|
4159
4169
|
userTheme = null;
|
|
4160
4170
|
if (!!initialized) return [3, 3];
|
|
@@ -4173,8 +4183,6 @@ function flairJsLoader(source, sourceMap) {
|
|
|
4173
4183
|
userTheme = _b.sent();
|
|
4174
4184
|
_b.label = 5;
|
|
4175
4185
|
case 5:
|
|
4176
|
-
fileName = this.resourcePath;
|
|
4177
|
-
if (!shouldProcessFile(fileName, options === null || options === void 0 ? void 0 : options.include, options === null || options === void 0 ? void 0 : options.exclude)) return [2, callback(null, source, sourceMap)];
|
|
4178
4186
|
if (!cssGeneratedDir) {
|
|
4179
4187
|
console.error("[flairjs] Could not find generated CSS directory. Skipping processing.");
|
|
4180
4188
|
return [2, callback(null, source, sourceMap)];
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@flairjs/webpack-loader",
|
|
3
|
-
"version": "0.0.1-beta.
|
|
3
|
+
"version": "0.0.1-beta.6",
|
|
4
4
|
"main": "./dist/cjs/index.js",
|
|
5
5
|
"module": "./dist/esm/index.js",
|
|
6
6
|
"types": "./dist/types/index.d.ts",
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
"rolldown": "1.0.0-beta.37",
|
|
23
23
|
"typescript": "^5.8.2",
|
|
24
24
|
"webpack": "^5.101.0",
|
|
25
|
-
"@flairjs/bundler-shared": "0.0.1-beta.
|
|
25
|
+
"@flairjs/bundler-shared": "0.0.1-beta.9",
|
|
26
26
|
"@flairjs/core": "0.0.1-beta.5"
|
|
27
27
|
},
|
|
28
28
|
"dependencies": {
|
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
"picomatch": "^4.0.3"
|
|
31
31
|
},
|
|
32
32
|
"scripts": {
|
|
33
|
-
"build": "rolldown -c",
|
|
33
|
+
"build": "tsc && rolldown -c",
|
|
34
34
|
"check": "biome check --write",
|
|
35
35
|
"dev": "rolldown -w -c",
|
|
36
36
|
"format": "biome format --write"
|