@flairjs/parcel-transformer 0.0.1-beta.2 → 0.0.1-beta.3
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 +9 -13
- package/dist/esm/index.js +9 -13
- package/dist/types/index.js +23 -19
- package/package.json +2 -2
package/dist/cjs/index.js
CHANGED
|
@@ -139,11 +139,12 @@ const getGeneratedCssDir = () => {
|
|
|
139
139
|
const flairThemeFile = require$1.resolve("@flairjs/client/theme.css");
|
|
140
140
|
return node_path.default.resolve(flairThemeFile, "../generated-css");
|
|
141
141
|
};
|
|
142
|
-
const setupGeneratedCssDir = async () => {
|
|
142
|
+
const setupGeneratedCssDir = async (options) => {
|
|
143
143
|
const flairGeneratedCssDir = getGeneratedCssDir();
|
|
144
|
+
const { clearExisting = true } = options ?? {};
|
|
144
145
|
try {
|
|
145
146
|
if (!(0, node_fs.existsSync)(flairGeneratedCssDir)) await (0, node_fs_promises.mkdir)(flairGeneratedCssDir);
|
|
146
|
-
else {
|
|
147
|
+
else if (clearExisting) {
|
|
147
148
|
await (0, node_fs_promises.rm)(flairGeneratedCssDir, {
|
|
148
149
|
recursive: true,
|
|
149
150
|
force: true
|
|
@@ -176,13 +177,6 @@ const setupUserThemeFile = async ({ buildThemeFile }) => {
|
|
|
176
177
|
}
|
|
177
178
|
return userTheme;
|
|
178
179
|
};
|
|
179
|
-
const removeOutdatedCssFiles = async (sourceFilePath, cssFilePath, { flairGeneratedCssDir }) => {
|
|
180
|
-
const previousGeneratedCssName = store.getGeneratedCssName(sourceFilePath);
|
|
181
|
-
if (previousGeneratedCssName && previousGeneratedCssName !== cssFilePath) setTimeout(() => {
|
|
182
|
-
(0, node_fs_promises.rm)(node_path.default.join(flairGeneratedCssDir, previousGeneratedCssName), { force: true });
|
|
183
|
-
}, 2e3);
|
|
184
|
-
else store.setFileNameToGeneratedCssNameMap(sourceFilePath, cssFilePath);
|
|
185
|
-
};
|
|
186
180
|
function shouldProcessFile(id, include, exclude) {
|
|
187
181
|
const isIncluded = (0, picomatch.default)(include ?? ["**/*.{js,ts,jsx,tsx}"]);
|
|
188
182
|
const isExcluded = (0, picomatch.default)(exclude ?? ["**/node_modules/**"]);
|
|
@@ -235,14 +229,16 @@ const transformCode = (code, filePath, options) => {
|
|
|
235
229
|
//#endregion
|
|
236
230
|
//#region src/index.ts
|
|
237
231
|
const SourceMap = __parcel_source_map.default.default ?? __parcel_source_map.default;
|
|
232
|
+
let initialized = false;
|
|
238
233
|
var src_default = new __parcel_plugin.Transformer({
|
|
239
234
|
async loadConfig({ config }) {
|
|
240
235
|
const getConfigResult = await config.getConfig(["tool.config.js"]);
|
|
241
236
|
const filePath = getConfigResult?.filePath;
|
|
242
237
|
const configContents = getConfigResult?.contents;
|
|
243
238
|
if (filePath?.endsWith(".js")) config.invalidateOnStartup();
|
|
244
|
-
const cssGeneratedDir = await setupGeneratedCssDir();
|
|
245
|
-
const userTheme = await setupUserThemeFile({ buildThemeFile: configContents?.buildThemeFile });
|
|
239
|
+
const cssGeneratedDir = await setupGeneratedCssDir({ clearExisting: false });
|
|
240
|
+
const userTheme = initialized ? await getUserTheme() : await setupUserThemeFile({ buildThemeFile: configContents?.buildThemeFile });
|
|
241
|
+
if (!initialized) initialized = true;
|
|
246
242
|
return {
|
|
247
243
|
...configContents,
|
|
248
244
|
cssGeneratedDir,
|
|
@@ -257,7 +253,7 @@ var src_default = new __parcel_plugin.Transformer({
|
|
|
257
253
|
try {
|
|
258
254
|
const code = await asset.getCode();
|
|
259
255
|
const result = transformCode(code, asset.filePath, {
|
|
260
|
-
appendTimestampToCssFile:
|
|
256
|
+
appendTimestampToCssFile: false,
|
|
261
257
|
classNameList: config?.classNameList,
|
|
262
258
|
cssPreprocessor: config?.cssPreprocessor ? (css) => config.cssPreprocessor(css, asset.filePath) : void 0,
|
|
263
259
|
theme: config.userTheme?.theme,
|
|
@@ -265,7 +261,7 @@ var src_default = new __parcel_plugin.Transformer({
|
|
|
265
261
|
cssOutDir
|
|
266
262
|
});
|
|
267
263
|
if (!result) return [asset];
|
|
268
|
-
if (result.generatedCssName)
|
|
264
|
+
if (!result.generatedCssName) return [asset];
|
|
269
265
|
asset.setCode(result.code);
|
|
270
266
|
if (result.sourcemap) {
|
|
271
267
|
const sourcemap = new SourceMap(options.projectRoot);
|
package/dist/esm/index.js
CHANGED
|
@@ -103,11 +103,12 @@ const getGeneratedCssDir = () => {
|
|
|
103
103
|
const flairThemeFile = require.resolve("@flairjs/client/theme.css");
|
|
104
104
|
return path.resolve(flairThemeFile, "../generated-css");
|
|
105
105
|
};
|
|
106
|
-
const setupGeneratedCssDir = async () => {
|
|
106
|
+
const setupGeneratedCssDir = async (options) => {
|
|
107
107
|
const flairGeneratedCssDir = getGeneratedCssDir();
|
|
108
|
+
const { clearExisting = true } = options ?? {};
|
|
108
109
|
try {
|
|
109
110
|
if (!existsSync(flairGeneratedCssDir)) await mkdir(flairGeneratedCssDir);
|
|
110
|
-
else {
|
|
111
|
+
else if (clearExisting) {
|
|
111
112
|
await rm(flairGeneratedCssDir, {
|
|
112
113
|
recursive: true,
|
|
113
114
|
force: true
|
|
@@ -140,13 +141,6 @@ const setupUserThemeFile = async ({ buildThemeFile }) => {
|
|
|
140
141
|
}
|
|
141
142
|
return userTheme;
|
|
142
143
|
};
|
|
143
|
-
const removeOutdatedCssFiles = async (sourceFilePath, cssFilePath, { flairGeneratedCssDir }) => {
|
|
144
|
-
const previousGeneratedCssName = store.getGeneratedCssName(sourceFilePath);
|
|
145
|
-
if (previousGeneratedCssName && previousGeneratedCssName !== cssFilePath) setTimeout(() => {
|
|
146
|
-
rm(path.join(flairGeneratedCssDir, previousGeneratedCssName), { force: true });
|
|
147
|
-
}, 2e3);
|
|
148
|
-
else store.setFileNameToGeneratedCssNameMap(sourceFilePath, cssFilePath);
|
|
149
|
-
};
|
|
150
144
|
function shouldProcessFile(id, include, exclude) {
|
|
151
145
|
const isIncluded = picomatch(include ?? ["**/*.{js,ts,jsx,tsx}"]);
|
|
152
146
|
const isExcluded = picomatch(exclude ?? ["**/node_modules/**"]);
|
|
@@ -199,14 +193,16 @@ const transformCode$1 = (code, filePath, options) => {
|
|
|
199
193
|
//#endregion
|
|
200
194
|
//#region src/index.ts
|
|
201
195
|
const SourceMap = SourceMapImport.default ?? SourceMapImport;
|
|
196
|
+
let initialized = false;
|
|
202
197
|
var src_default = new Transformer({
|
|
203
198
|
async loadConfig({ config }) {
|
|
204
199
|
const getConfigResult = await config.getConfig(["tool.config.js"]);
|
|
205
200
|
const filePath = getConfigResult?.filePath;
|
|
206
201
|
const configContents = getConfigResult?.contents;
|
|
207
202
|
if (filePath?.endsWith(".js")) config.invalidateOnStartup();
|
|
208
|
-
const cssGeneratedDir = await setupGeneratedCssDir();
|
|
209
|
-
const userTheme = await setupUserThemeFile({ buildThemeFile: configContents?.buildThemeFile });
|
|
203
|
+
const cssGeneratedDir = await setupGeneratedCssDir({ clearExisting: false });
|
|
204
|
+
const userTheme = initialized ? await getUserTheme() : await setupUserThemeFile({ buildThemeFile: configContents?.buildThemeFile });
|
|
205
|
+
if (!initialized) initialized = true;
|
|
210
206
|
return {
|
|
211
207
|
...configContents,
|
|
212
208
|
cssGeneratedDir,
|
|
@@ -221,7 +217,7 @@ var src_default = new Transformer({
|
|
|
221
217
|
try {
|
|
222
218
|
const code = await asset.getCode();
|
|
223
219
|
const result = transformCode$1(code, asset.filePath, {
|
|
224
|
-
appendTimestampToCssFile:
|
|
220
|
+
appendTimestampToCssFile: false,
|
|
225
221
|
classNameList: config?.classNameList,
|
|
226
222
|
cssPreprocessor: config?.cssPreprocessor ? (css) => config.cssPreprocessor(css, asset.filePath) : void 0,
|
|
227
223
|
theme: config.userTheme?.theme,
|
|
@@ -229,7 +225,7 @@ var src_default = new Transformer({
|
|
|
229
225
|
cssOutDir
|
|
230
226
|
});
|
|
231
227
|
if (!result) return [asset];
|
|
232
|
-
if (result.generatedCssName)
|
|
228
|
+
if (!result.generatedCssName) return [asset];
|
|
233
229
|
asset.setCode(result.code);
|
|
234
230
|
if (result.sourcemap) {
|
|
235
231
|
const sourcemap = new SourceMap(options.projectRoot);
|
package/dist/types/index.js
CHANGED
|
@@ -4068,11 +4068,12 @@ const getGeneratedCssDir = () => {
|
|
|
4068
4068
|
const flairThemeFile = require$1.resolve("@flairjs/client/theme.css");
|
|
4069
4069
|
return path.resolve(flairThemeFile, "../generated-css");
|
|
4070
4070
|
};
|
|
4071
|
-
const setupGeneratedCssDir = async () => {
|
|
4071
|
+
const setupGeneratedCssDir = async (options) => {
|
|
4072
4072
|
const flairGeneratedCssDir = getGeneratedCssDir();
|
|
4073
|
+
const { clearExisting = true } = options ?? {};
|
|
4073
4074
|
try {
|
|
4074
4075
|
if (!existsSync(flairGeneratedCssDir)) await mkdir(flairGeneratedCssDir);
|
|
4075
|
-
else {
|
|
4076
|
+
else if (clearExisting) {
|
|
4076
4077
|
await rm(flairGeneratedCssDir, {
|
|
4077
4078
|
recursive: true,
|
|
4078
4079
|
force: true
|
|
@@ -4105,13 +4106,6 @@ const setupUserThemeFile = async ({ buildThemeFile }) => {
|
|
|
4105
4106
|
}
|
|
4106
4107
|
return userTheme;
|
|
4107
4108
|
};
|
|
4108
|
-
const removeOutdatedCssFiles = async (sourceFilePath, cssFilePath, { flairGeneratedCssDir }) => {
|
|
4109
|
-
const previousGeneratedCssName = store.getGeneratedCssName(sourceFilePath);
|
|
4110
|
-
if (previousGeneratedCssName && previousGeneratedCssName !== cssFilePath) setTimeout(() => {
|
|
4111
|
-
rm(path.join(flairGeneratedCssDir, previousGeneratedCssName), { force: true });
|
|
4112
|
-
}, 2e3);
|
|
4113
|
-
else store.setFileNameToGeneratedCssNameMap(sourceFilePath, cssFilePath);
|
|
4114
|
-
};
|
|
4115
4109
|
function shouldProcessFile(id, include, exclude) {
|
|
4116
4110
|
const isIncluded = (0, import_picomatch.default)(include ?? ["**/*.{js,ts,jsx,tsx}"]);
|
|
4117
4111
|
const isExcluded = (0, import_picomatch.default)(exclude ?? ["**/node_modules/**"]);
|
|
@@ -5359,25 +5353,35 @@ var import_PluginAPI = /* @__PURE__ */ __toESM(require_PluginAPI());
|
|
|
5359
5353
|
var import_wasm = /* @__PURE__ */ __toESM(require_wasm());
|
|
5360
5354
|
var _a;
|
|
5361
5355
|
var SourceMap = (_a = import_wasm.default.default) !== null && _a !== void 0 ? _a : import_wasm.default;
|
|
5356
|
+
var initialized = false;
|
|
5362
5357
|
var src_default = new import_PluginAPI.Transformer({
|
|
5363
5358
|
loadConfig: function(_a$2) {
|
|
5364
5359
|
return __awaiter(this, arguments, void 0, function(_b) {
|
|
5365
|
-
var getConfigResult, filePath, configContents, cssGeneratedDir, userTheme;
|
|
5360
|
+
var getConfigResult, filePath, configContents, cssGeneratedDir, userTheme, _c;
|
|
5366
5361
|
var config = _b.config;
|
|
5367
|
-
return __generator(this, function(
|
|
5368
|
-
switch (
|
|
5362
|
+
return __generator(this, function(_d) {
|
|
5363
|
+
switch (_d.label) {
|
|
5369
5364
|
case 0: return [4, config.getConfig(["tool.config.js"])];
|
|
5370
5365
|
case 1:
|
|
5371
|
-
getConfigResult =
|
|
5366
|
+
getConfigResult = _d.sent();
|
|
5372
5367
|
filePath = getConfigResult === null || getConfigResult === void 0 ? void 0 : getConfigResult.filePath;
|
|
5373
5368
|
configContents = getConfigResult === null || getConfigResult === void 0 ? void 0 : getConfigResult.contents;
|
|
5374
5369
|
if (filePath === null || filePath === void 0 ? void 0 : filePath.endsWith(".js")) config.invalidateOnStartup();
|
|
5375
|
-
return [4, setupGeneratedCssDir()];
|
|
5370
|
+
return [4, setupGeneratedCssDir({ clearExisting: false })];
|
|
5376
5371
|
case 2:
|
|
5377
|
-
cssGeneratedDir =
|
|
5378
|
-
return [
|
|
5372
|
+
cssGeneratedDir = _d.sent();
|
|
5373
|
+
if (!initialized) return [3, 4];
|
|
5374
|
+
return [4, getUserTheme()];
|
|
5379
5375
|
case 3:
|
|
5380
|
-
|
|
5376
|
+
_c = _d.sent();
|
|
5377
|
+
return [3, 6];
|
|
5378
|
+
case 4: return [4, setupUserThemeFile({ buildThemeFile: configContents === null || configContents === void 0 ? void 0 : configContents.buildThemeFile })];
|
|
5379
|
+
case 5:
|
|
5380
|
+
_c = _d.sent();
|
|
5381
|
+
_d.label = 6;
|
|
5382
|
+
case 6:
|
|
5383
|
+
userTheme = _c;
|
|
5384
|
+
if (!initialized) initialized = true;
|
|
5381
5385
|
return [2, __assign(__assign({}, configContents), {
|
|
5382
5386
|
cssGeneratedDir,
|
|
5383
5387
|
userTheme
|
|
@@ -5410,7 +5414,7 @@ var src_default = new import_PluginAPI.Transformer({
|
|
|
5410
5414
|
case 2:
|
|
5411
5415
|
code = _e.sent();
|
|
5412
5416
|
result = transformCode(code, asset.filePath, {
|
|
5413
|
-
appendTimestampToCssFile:
|
|
5417
|
+
appendTimestampToCssFile: false,
|
|
5414
5418
|
classNameList: config === null || config === void 0 ? void 0 : config.classNameList,
|
|
5415
5419
|
cssPreprocessor: (config === null || config === void 0 ? void 0 : config.cssPreprocessor) ? function(css) {
|
|
5416
5420
|
return config.cssPreprocessor(css, asset.filePath);
|
|
@@ -5420,7 +5424,7 @@ var src_default = new import_PluginAPI.Transformer({
|
|
|
5420
5424
|
cssOutDir
|
|
5421
5425
|
});
|
|
5422
5426
|
if (!result) return [2, [asset]];
|
|
5423
|
-
if (result.generatedCssName)
|
|
5427
|
+
if (!result.generatedCssName) return [2, [asset]];
|
|
5424
5428
|
asset.setCode(result.code);
|
|
5425
5429
|
if (result.sourcemap) {
|
|
5426
5430
|
sourcemap = new SourceMap(options.projectRoot);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@flairjs/parcel-transformer",
|
|
3
|
-
"version": "0.0.1-beta.
|
|
3
|
+
"version": "0.0.1-beta.3",
|
|
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
|
"parcel": "^2.16.0",
|
|
23
23
|
"rolldown": "1.0.0-beta.37",
|
|
24
24
|
"typescript": "^5.8.2",
|
|
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": {
|