vite-plugin-qingkuai 1.0.17 → 1.0.19
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/index.cjs +54 -23
- package/dist/index.js +35 -23
- package/package.json +3 -3
package/dist/index.cjs
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
+
var vite = require('vite');
|
|
3
4
|
var nodePath = require('node:path');
|
|
4
5
|
var nodeCrypto = require('node:crypto');
|
|
5
6
|
var compiler = require('qingkuai/compiler');
|
|
@@ -8,14 +9,32 @@ var linesAndColumns = require('lines-and-columns');
|
|
|
8
9
|
var sourcemapCodec = require('@jridgewell/sourcemap-codec');
|
|
9
10
|
var postcss = require('postcss');
|
|
10
11
|
var selectorParser = require('postcss-selector-parser');
|
|
11
|
-
var vite = require('vite');
|
|
12
12
|
var sourceMapJs = require('source-map-js');
|
|
13
13
|
|
|
14
|
+
function _interopNamespaceDefault(e) {
|
|
15
|
+
var n = Object.create(null);
|
|
16
|
+
if (e) {
|
|
17
|
+
Object.keys(e).forEach(function (k) {
|
|
18
|
+
if (k !== 'default') {
|
|
19
|
+
var d = Object.getOwnPropertyDescriptor(e, k);
|
|
20
|
+
Object.defineProperty(n, k, d.get ? d : {
|
|
21
|
+
enumerable: true,
|
|
22
|
+
get: function () { return e[k]; }
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
n.default = e;
|
|
28
|
+
return Object.freeze(n);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
var vite__namespace = /*#__PURE__*/_interopNamespaceDefault(vite);
|
|
32
|
+
|
|
14
33
|
const globalStyle = "\n" + compiler.util.formatSourceCode(
|
|
15
34
|
`
|
|
16
35
|
/* Injected by vite-plugin-qingkuai */
|
|
17
36
|
|
|
18
|
-
*[hidden]{
|
|
37
|
+
*[hidden] {
|
|
19
38
|
display: none !important;
|
|
20
39
|
}
|
|
21
40
|
`
|
|
@@ -133,18 +152,6 @@ function qingkuai() {
|
|
|
133
152
|
cssSourcemap = true;
|
|
134
153
|
sourcemap = config.build.sourcemap !== false;
|
|
135
154
|
}
|
|
136
|
-
const optimizeDeps = config.optimizeDeps;
|
|
137
|
-
if (!optimizeDeps) {
|
|
138
|
-
Object.assign(config, {
|
|
139
|
-
optimizeDeps: {
|
|
140
|
-
exclude: ["qingkuai"]
|
|
141
|
-
}
|
|
142
|
-
});
|
|
143
|
-
} else if (!optimizeDeps.exclude) {
|
|
144
|
-
optimizeDeps.exclude = ["qingkuai"];
|
|
145
|
-
} else {
|
|
146
|
-
optimizeDeps.exclude.push("qingkuai");
|
|
147
|
-
}
|
|
148
155
|
loadAllQingkuaiConfigurations(config.root);
|
|
149
156
|
},
|
|
150
157
|
transformIndexHtml(html) {
|
|
@@ -188,7 +195,7 @@ function qingkuai() {
|
|
|
188
195
|
break;
|
|
189
196
|
}
|
|
190
197
|
}
|
|
191
|
-
const preprocessRes = await
|
|
198
|
+
const preprocessRes = await vite__namespace.preprocessCSS(style.code, virtualFileName, {
|
|
192
199
|
...viteConfig,
|
|
193
200
|
css: {
|
|
194
201
|
...viteConfig.css,
|
|
@@ -288,7 +295,9 @@ function qingkuai() {
|
|
|
288
295
|
})
|
|
289
296
|
};
|
|
290
297
|
}
|
|
291
|
-
const
|
|
298
|
+
const transformWithOxc = vite__namespace.transformWithOxc;
|
|
299
|
+
const transformWithEsbuild = vite__namespace.transformWithEsbuild;
|
|
300
|
+
const tsCompileRes = await (transformWithOxc ?? transformWithEsbuild)(
|
|
292
301
|
compiledCode,
|
|
293
302
|
id,
|
|
294
303
|
{
|
|
@@ -303,13 +312,20 @@ function qingkuai() {
|
|
|
303
312
|
mappings: compileRes.mappings
|
|
304
313
|
} : void 0
|
|
305
314
|
);
|
|
315
|
+
if (!tsCompileRes) {
|
|
316
|
+
this.error("Current Vite runtime does not provide TypeScript transform APIs.");
|
|
317
|
+
}
|
|
306
318
|
if (!sourcemap) {
|
|
307
|
-
return
|
|
319
|
+
return tsCompileRes.code;
|
|
320
|
+
}
|
|
321
|
+
let transformedMap = tsCompileRes.map;
|
|
322
|
+
if (typeof tsCompileRes.map === "string") {
|
|
323
|
+
transformedMap = JSON.parse(tsCompileRes.map);
|
|
308
324
|
}
|
|
309
325
|
return {
|
|
310
|
-
code:
|
|
326
|
+
code: tsCompileRes.code,
|
|
311
327
|
map: Object.assign(baseMap, {
|
|
312
|
-
mappings:
|
|
328
|
+
mappings: transformedMap?.mappings || compileRes.mappings
|
|
313
329
|
})
|
|
314
330
|
};
|
|
315
331
|
} catch (err) {
|
|
@@ -343,10 +359,25 @@ function qingkuai() {
|
|
|
343
359
|
return config;
|
|
344
360
|
}
|
|
345
361
|
function createQingkuaiConfigurationWatcher(server) {
|
|
346
|
-
const watcher = server.watcher
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
362
|
+
const watcher = server.watcher;
|
|
363
|
+
const isQingkuaiConfig = (filePath) => {
|
|
364
|
+
return nodePath.basename(filePath) === ".qingkuairc" && !filePath.includes(`${nodePath.sep}node_modules${nodePath.sep}`);
|
|
365
|
+
};
|
|
366
|
+
watcher.on("unlink", (filePath) => {
|
|
367
|
+
if (isQingkuaiConfig(filePath)) {
|
|
368
|
+
qingkuaiConfigurations.delete(nodePath.dirname(filePath));
|
|
369
|
+
}
|
|
370
|
+
});
|
|
371
|
+
watcher.on("change", (filePath) => {
|
|
372
|
+
if (isQingkuaiConfig(filePath)) {
|
|
373
|
+
recordQingkuaiConfiguration(filePath);
|
|
374
|
+
}
|
|
375
|
+
});
|
|
376
|
+
watcher.on("add", (filePath) => {
|
|
377
|
+
if (isQingkuaiConfig(filePath)) {
|
|
378
|
+
recordQingkuaiConfiguration(filePath);
|
|
379
|
+
}
|
|
380
|
+
});
|
|
350
381
|
}
|
|
351
382
|
function loadAllQingkuaiConfigurations(workspaceDir) {
|
|
352
383
|
findFilesByName(workspaceDir, ".qingkuairc", /* @__PURE__ */ new Set(["node_modules"])).forEach((fileName) => {
|
package/dist/index.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import * as vite from 'vite';
|
|
1
2
|
import nodePath from 'node:path';
|
|
2
3
|
import nodeCrypto from 'node:crypto';
|
|
3
4
|
import { util, compile } from 'qingkuai/compiler';
|
|
@@ -6,14 +7,13 @@ import { LinesAndColumns } from 'lines-and-columns';
|
|
|
6
7
|
import { decode, encode } from '@jridgewell/sourcemap-codec';
|
|
7
8
|
import postcss from 'postcss';
|
|
8
9
|
import selectorParser from 'postcss-selector-parser';
|
|
9
|
-
import { transformWithEsbuild, preprocessCSS } from 'vite';
|
|
10
10
|
import { SourceMapConsumer } from 'source-map-js';
|
|
11
11
|
|
|
12
12
|
const globalStyle = "\n" + util.formatSourceCode(
|
|
13
13
|
`
|
|
14
14
|
/* Injected by vite-plugin-qingkuai */
|
|
15
15
|
|
|
16
|
-
*[hidden]{
|
|
16
|
+
*[hidden] {
|
|
17
17
|
display: none !important;
|
|
18
18
|
}
|
|
19
19
|
`
|
|
@@ -131,18 +131,6 @@ function qingkuai() {
|
|
|
131
131
|
cssSourcemap = true;
|
|
132
132
|
sourcemap = config.build.sourcemap !== false;
|
|
133
133
|
}
|
|
134
|
-
const optimizeDeps = config.optimizeDeps;
|
|
135
|
-
if (!optimizeDeps) {
|
|
136
|
-
Object.assign(config, {
|
|
137
|
-
optimizeDeps: {
|
|
138
|
-
exclude: ["qingkuai"]
|
|
139
|
-
}
|
|
140
|
-
});
|
|
141
|
-
} else if (!optimizeDeps.exclude) {
|
|
142
|
-
optimizeDeps.exclude = ["qingkuai"];
|
|
143
|
-
} else {
|
|
144
|
-
optimizeDeps.exclude.push("qingkuai");
|
|
145
|
-
}
|
|
146
134
|
loadAllQingkuaiConfigurations(config.root);
|
|
147
135
|
},
|
|
148
136
|
transformIndexHtml(html) {
|
|
@@ -186,7 +174,7 @@ function qingkuai() {
|
|
|
186
174
|
break;
|
|
187
175
|
}
|
|
188
176
|
}
|
|
189
|
-
const preprocessRes = await preprocessCSS(style.code, virtualFileName, {
|
|
177
|
+
const preprocessRes = await vite.preprocessCSS(style.code, virtualFileName, {
|
|
190
178
|
...viteConfig,
|
|
191
179
|
css: {
|
|
192
180
|
...viteConfig.css,
|
|
@@ -286,7 +274,9 @@ function qingkuai() {
|
|
|
286
274
|
})
|
|
287
275
|
};
|
|
288
276
|
}
|
|
289
|
-
const
|
|
277
|
+
const transformWithOxc = vite.transformWithOxc;
|
|
278
|
+
const transformWithEsbuild = vite.transformWithEsbuild;
|
|
279
|
+
const tsCompileRes = await (transformWithOxc ?? transformWithEsbuild)(
|
|
290
280
|
compiledCode,
|
|
291
281
|
id,
|
|
292
282
|
{
|
|
@@ -301,13 +291,20 @@ function qingkuai() {
|
|
|
301
291
|
mappings: compileRes.mappings
|
|
302
292
|
} : void 0
|
|
303
293
|
);
|
|
294
|
+
if (!tsCompileRes) {
|
|
295
|
+
this.error("Current Vite runtime does not provide TypeScript transform APIs.");
|
|
296
|
+
}
|
|
304
297
|
if (!sourcemap) {
|
|
305
|
-
return
|
|
298
|
+
return tsCompileRes.code;
|
|
299
|
+
}
|
|
300
|
+
let transformedMap = tsCompileRes.map;
|
|
301
|
+
if (typeof tsCompileRes.map === "string") {
|
|
302
|
+
transformedMap = JSON.parse(tsCompileRes.map);
|
|
306
303
|
}
|
|
307
304
|
return {
|
|
308
|
-
code:
|
|
305
|
+
code: tsCompileRes.code,
|
|
309
306
|
map: Object.assign(baseMap, {
|
|
310
|
-
mappings:
|
|
307
|
+
mappings: transformedMap?.mappings || compileRes.mappings
|
|
311
308
|
})
|
|
312
309
|
};
|
|
313
310
|
} catch (err) {
|
|
@@ -341,10 +338,25 @@ function qingkuai() {
|
|
|
341
338
|
return config;
|
|
342
339
|
}
|
|
343
340
|
function createQingkuaiConfigurationWatcher(server) {
|
|
344
|
-
const watcher = server.watcher
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
341
|
+
const watcher = server.watcher;
|
|
342
|
+
const isQingkuaiConfig = (filePath) => {
|
|
343
|
+
return nodePath.basename(filePath) === ".qingkuairc" && !filePath.includes(`${nodePath.sep}node_modules${nodePath.sep}`);
|
|
344
|
+
};
|
|
345
|
+
watcher.on("unlink", (filePath) => {
|
|
346
|
+
if (isQingkuaiConfig(filePath)) {
|
|
347
|
+
qingkuaiConfigurations.delete(nodePath.dirname(filePath));
|
|
348
|
+
}
|
|
349
|
+
});
|
|
350
|
+
watcher.on("change", (filePath) => {
|
|
351
|
+
if (isQingkuaiConfig(filePath)) {
|
|
352
|
+
recordQingkuaiConfiguration(filePath);
|
|
353
|
+
}
|
|
354
|
+
});
|
|
355
|
+
watcher.on("add", (filePath) => {
|
|
356
|
+
if (isQingkuaiConfig(filePath)) {
|
|
357
|
+
recordQingkuaiConfiguration(filePath);
|
|
358
|
+
}
|
|
359
|
+
});
|
|
348
360
|
}
|
|
349
361
|
function loadAllQingkuaiConfigurations(workspaceDir) {
|
|
350
362
|
findFilesByName(workspaceDir, ".qingkuairc", /* @__PURE__ */ new Set(["node_modules"])).forEach((fileName) => {
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "vite-plugin-qingkuai",
|
|
3
3
|
"author": "mlgq",
|
|
4
4
|
"license": "MIT",
|
|
5
|
-
"version": "1.0.
|
|
5
|
+
"version": "1.0.19",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"keywords": [
|
|
8
8
|
"vite",
|
|
@@ -30,11 +30,11 @@
|
|
|
30
30
|
"rollup": "^4.38.0",
|
|
31
31
|
"rollup-plugin-dts": "^6.2.1",
|
|
32
32
|
"rollup-plugin-esbuild": "^6.2.1",
|
|
33
|
-
"vite": "
|
|
33
|
+
"vite": "8.0.0"
|
|
34
34
|
},
|
|
35
35
|
"peerDependencies": {
|
|
36
36
|
"qingkuai": ">=1.0.50",
|
|
37
|
-
"vite": ">=6.2.4"
|
|
37
|
+
"vite": ">=6.2.4 <9"
|
|
38
38
|
},
|
|
39
39
|
"dependencies": {
|
|
40
40
|
"@jridgewell/sourcemap-codec": "^1.5.0",
|