@vizejs/unplugin 0.664.0 → 0.665.0
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/babel.cjs +1 -1
- package/dist/babel.mjs +1 -1
- package/dist/esbuild.cjs +1 -1
- package/dist/esbuild.mjs +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.mjs +1 -1
- package/dist/rolldown.cjs +1 -1
- package/dist/rolldown.mjs +1 -1
- package/dist/rollup.cjs +1 -1
- package/dist/rollup.mjs +1 -1
- package/dist/{unplugin-BVGBB7oG.mjs → unplugin-CuhaOxEl.mjs} +25 -26
- package/dist/{unplugin-COZmphjF.cjs → unplugin-D1CMvI6_.cjs} +26 -27
- package/dist/webpack.cjs +1 -1
- package/dist/webpack.mjs +1 -1
- package/package.json +2 -2
package/dist/babel.cjs
CHANGED
package/dist/babel.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as createFilter, i as generateOutput, r as compileVueModule, t as normalizeOptions } from "./unplugin-
|
|
1
|
+
import { a as createFilter, i as generateOutput, r as compileVueModule, t as normalizeOptions } from "./unplugin-CuhaOxEl.mjs";
|
|
2
2
|
//#region src/babel.ts
|
|
3
3
|
function vizeBabelPlugin(_api, rawOptions = {}) {
|
|
4
4
|
const options = normalizeOptions(rawOptions);
|
package/dist/esbuild.cjs
CHANGED
package/dist/esbuild.mjs
CHANGED
package/dist/index.cjs
CHANGED
|
@@ -2,6 +2,6 @@ Object.defineProperties(exports, {
|
|
|
2
2
|
__esModule: { value: true },
|
|
3
3
|
[Symbol.toStringTag]: { value: "Module" }
|
|
4
4
|
});
|
|
5
|
-
const require_unplugin = require("./unplugin-
|
|
5
|
+
const require_unplugin = require("./unplugin-D1CMvI6_.cjs");
|
|
6
6
|
exports.default = require_unplugin.vizeUnplugin;
|
|
7
7
|
exports.vizeUnplugin = require_unplugin.vizeUnplugin;
|
package/dist/index.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { n as vizeUnplugin } from "./unplugin-
|
|
1
|
+
import { n as vizeUnplugin } from "./unplugin-CuhaOxEl.mjs";
|
|
2
2
|
export { vizeUnplugin as default, vizeUnplugin };
|
package/dist/rolldown.cjs
CHANGED
package/dist/rolldown.mjs
CHANGED
package/dist/rollup.cjs
CHANGED
package/dist/rollup.mjs
CHANGED
|
@@ -2,10 +2,10 @@ import { c as scopeCss, i as webpackStyleRequest, l as transformStyleVars, n as
|
|
|
2
2
|
import { createRequire } from "node:module";
|
|
3
3
|
import fs from "node:fs";
|
|
4
4
|
import path from "node:path";
|
|
5
|
-
import { createUnplugin } from "unplugin";
|
|
6
|
-
import { createHash } from "node:crypto";
|
|
7
5
|
import * as native from "@vizejs/native";
|
|
8
6
|
import { generateSfcScopeId, parseCssAst, parseSfc } from "@vizejs/native";
|
|
7
|
+
import { createUnplugin } from "unplugin";
|
|
8
|
+
import { createHash } from "node:crypto";
|
|
9
9
|
import { transform } from "oxc-transform";
|
|
10
10
|
//#region src/filter.ts
|
|
11
11
|
function createFilter(include, exclude) {
|
|
@@ -299,8 +299,6 @@ async function resolveSfcSrcRequests(importer, requests, resolve) {
|
|
|
299
299
|
}
|
|
300
300
|
return resolutions;
|
|
301
301
|
}
|
|
302
|
-
//#endregion
|
|
303
|
-
//#region src/src-blocks.ts
|
|
304
302
|
const SRC_BLOCK_HINT = /<(?:template|script|style)\b[^>]*\ssrc\s*=/i;
|
|
305
303
|
const ATTRIBUTE_RE = /\s+([^\s"'<>/=]+)(?:\s*=\s*(?:"([^"]*)"|'([^']*)'|([^\s"'=<>`]+)))?/gy;
|
|
306
304
|
/** Split an opening tag into its `src` value and the tag without it. */
|
|
@@ -323,18 +321,8 @@ function splitSrcAttribute(tag, openTag) {
|
|
|
323
321
|
openTag: `${head}${rest}>`
|
|
324
322
|
};
|
|
325
323
|
}
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
try {
|
|
329
|
-
return {
|
|
330
|
-
path: resolved,
|
|
331
|
-
content: fs.readFileSync(resolved, "utf8")
|
|
332
|
-
};
|
|
333
|
-
} catch {
|
|
334
|
-
throw new Error(`[vize] <${tag} src="${src}"> not found (resolved: ${resolved}) in ${filePath}`);
|
|
335
|
-
}
|
|
336
|
-
}
|
|
337
|
-
function collectSrcBlocks(filePath, bytes, source) {
|
|
324
|
+
/** The `src` blocks the native parser finds, so `src` text in scripts or comments is not one. */
|
|
325
|
+
function collectSrcBlocks(parseSfc, filePath, bytes, source) {
|
|
338
326
|
let parsed;
|
|
339
327
|
try {
|
|
340
328
|
parsed = parseSfc(source, { filename: filePath });
|
|
@@ -344,6 +332,7 @@ function collectSrcBlocks(filePath, bytes, source) {
|
|
|
344
332
|
const blocks = [
|
|
345
333
|
["template", parsed.template],
|
|
346
334
|
["script", parsed.script],
|
|
335
|
+
["script", parsed.scriptSetup],
|
|
347
336
|
...parsed.styles.map((style) => ["style", style])
|
|
348
337
|
];
|
|
349
338
|
const found = [];
|
|
@@ -360,18 +349,28 @@ function collectSrcBlocks(filePath, bytes, source) {
|
|
|
360
349
|
}
|
|
361
350
|
return found;
|
|
362
351
|
}
|
|
363
|
-
/** The `src`
|
|
364
|
-
function
|
|
352
|
+
/** The `src` module requests (not relative paths) of an SFC's blocks, in source order. */
|
|
353
|
+
function listSfcSrcRequests(parseSfc, filePath, source) {
|
|
365
354
|
if (!SRC_BLOCK_HINT.test(source)) return [];
|
|
366
|
-
return collectSrcBlocks(filePath, Buffer.from(source), source).map((block) => block.src);
|
|
355
|
+
return collectSrcBlocks(parseSfc, filePath, Buffer.from(source), source).map((block) => block.src).filter((src) => !isRelativeSfcSrc(src));
|
|
356
|
+
}
|
|
357
|
+
function readSrcBlock(filePath, tag, src, resolutions) {
|
|
358
|
+
const resolved = sfcSrcFile(filePath, tag, src, resolutions);
|
|
359
|
+
try {
|
|
360
|
+
return {
|
|
361
|
+
path: resolved,
|
|
362
|
+
content: fs.readFileSync(resolved, "utf8")
|
|
363
|
+
};
|
|
364
|
+
} catch {
|
|
365
|
+
throw new Error(`[vize] <${tag} src="${src}"> not found (resolved: ${resolved}) in ${filePath}`);
|
|
366
|
+
}
|
|
367
367
|
}
|
|
368
368
|
/**
|
|
369
369
|
* Inline `<template src>`, `<script src>` and `<style src>` files into the SFC
|
|
370
|
-
* source
|
|
371
|
-
*
|
|
372
|
-
* requests come from the bundler's `resolutions` (see {@link sfcSrcFile}).
|
|
370
|
+
* source. Blocks are located by the native parser. Module requests come from
|
|
371
|
+
* the bundler's `resolutions` (see {@link sfcSrcFile}).
|
|
373
372
|
*/
|
|
374
|
-
function inlineSfcSrcBlocks(filePath, source, resolutions) {
|
|
373
|
+
function inlineSfcSrcBlocks(parseSfc, filePath, source, resolutions) {
|
|
375
374
|
if (!SRC_BLOCK_HINT.test(source)) return {
|
|
376
375
|
source,
|
|
377
376
|
dependencies: []
|
|
@@ -379,7 +378,7 @@ function inlineSfcSrcBlocks(filePath, source, resolutions) {
|
|
|
379
378
|
const bytes = Buffer.from(source);
|
|
380
379
|
const edits = [];
|
|
381
380
|
const dependencies = [];
|
|
382
|
-
for (const block of collectSrcBlocks(filePath, bytes, source)) {
|
|
381
|
+
for (const block of collectSrcBlocks(parseSfc, filePath, bytes, source)) {
|
|
383
382
|
const file = readSrcBlock(filePath, block.tag, block.src, resolutions);
|
|
384
383
|
dependencies.push(file.path);
|
|
385
384
|
edits.push({
|
|
@@ -434,7 +433,7 @@ function buildSourceHash(source) {
|
|
|
434
433
|
return createHash("sha256").update(source).digest("hex");
|
|
435
434
|
}
|
|
436
435
|
function compileVueModule(filePath, source, options, cache, srcResolutions) {
|
|
437
|
-
const { source: inlined, dependencies } = inlineSfcSrcBlocks(filePath, source, srcResolutions);
|
|
436
|
+
const { source: inlined, dependencies } = inlineSfcSrcBlocks(native.parseSfc, filePath, source, srcResolutions);
|
|
438
437
|
const sourceHash = buildSourceHash(inlined);
|
|
439
438
|
const signature = buildSignature(options);
|
|
440
439
|
const cached = cache.get(filePath);
|
|
@@ -668,7 +667,7 @@ function hostResolver(context) {
|
|
|
668
667
|
}
|
|
669
668
|
/** Resolve the SFC's `src` module requests (packages, aliases) with the bundler. */
|
|
670
669
|
async function resolveSrcRequests(context, importer, source) {
|
|
671
|
-
const requests =
|
|
670
|
+
const requests = listSfcSrcRequests(parseSfc, importer, source);
|
|
672
671
|
const resolve = requests.length > 0 ? hostResolver(context) : null;
|
|
673
672
|
return resolve ? resolveSfcSrcRequests(importer, requests, resolve) : void 0;
|
|
674
673
|
}
|
|
@@ -4,10 +4,10 @@ node_fs = require_webpack_styles.__toESM(node_fs, 1);
|
|
|
4
4
|
let node_module = require("node:module");
|
|
5
5
|
let node_path = require("node:path");
|
|
6
6
|
node_path = require_webpack_styles.__toESM(node_path, 1);
|
|
7
|
-
let unplugin = require("unplugin");
|
|
8
|
-
let node_crypto = require("node:crypto");
|
|
9
7
|
let _vizejs_native = require("@vizejs/native");
|
|
10
8
|
_vizejs_native = require_webpack_styles.__toESM(_vizejs_native, 1);
|
|
9
|
+
let unplugin = require("unplugin");
|
|
10
|
+
let node_crypto = require("node:crypto");
|
|
11
11
|
let oxc_transform = require("oxc-transform");
|
|
12
12
|
//#region src/filter.ts
|
|
13
13
|
function createFilter(include, exclude) {
|
|
@@ -301,8 +301,6 @@ async function resolveSfcSrcRequests(importer, requests, resolve) {
|
|
|
301
301
|
}
|
|
302
302
|
return resolutions;
|
|
303
303
|
}
|
|
304
|
-
//#endregion
|
|
305
|
-
//#region src/src-blocks.ts
|
|
306
304
|
const SRC_BLOCK_HINT = /<(?:template|script|style)\b[^>]*\ssrc\s*=/i;
|
|
307
305
|
const ATTRIBUTE_RE = /\s+([^\s"'<>/=]+)(?:\s*=\s*(?:"([^"]*)"|'([^']*)'|([^\s"'=<>`]+)))?/gy;
|
|
308
306
|
/** Split an opening tag into its `src` value and the tag without it. */
|
|
@@ -325,27 +323,18 @@ function splitSrcAttribute(tag, openTag) {
|
|
|
325
323
|
openTag: `${head}${rest}>`
|
|
326
324
|
};
|
|
327
325
|
}
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
try {
|
|
331
|
-
return {
|
|
332
|
-
path: resolved,
|
|
333
|
-
content: node_fs.default.readFileSync(resolved, "utf8")
|
|
334
|
-
};
|
|
335
|
-
} catch {
|
|
336
|
-
throw new Error(`[vize] <${tag} src="${src}"> not found (resolved: ${resolved}) in ${filePath}`);
|
|
337
|
-
}
|
|
338
|
-
}
|
|
339
|
-
function collectSrcBlocks(filePath, bytes, source) {
|
|
326
|
+
/** The `src` blocks the native parser finds, so `src` text in scripts or comments is not one. */
|
|
327
|
+
function collectSrcBlocks(parseSfc, filePath, bytes, source) {
|
|
340
328
|
let parsed;
|
|
341
329
|
try {
|
|
342
|
-
parsed =
|
|
330
|
+
parsed = parseSfc(source, { filename: filePath });
|
|
343
331
|
} catch {
|
|
344
332
|
return [];
|
|
345
333
|
}
|
|
346
334
|
const blocks = [
|
|
347
335
|
["template", parsed.template],
|
|
348
336
|
["script", parsed.script],
|
|
337
|
+
["script", parsed.scriptSetup],
|
|
349
338
|
...parsed.styles.map((style) => ["style", style])
|
|
350
339
|
];
|
|
351
340
|
const found = [];
|
|
@@ -362,18 +351,28 @@ function collectSrcBlocks(filePath, bytes, source) {
|
|
|
362
351
|
}
|
|
363
352
|
return found;
|
|
364
353
|
}
|
|
365
|
-
/** The `src`
|
|
366
|
-
function
|
|
354
|
+
/** The `src` module requests (not relative paths) of an SFC's blocks, in source order. */
|
|
355
|
+
function listSfcSrcRequests(parseSfc, filePath, source) {
|
|
367
356
|
if (!SRC_BLOCK_HINT.test(source)) return [];
|
|
368
|
-
return collectSrcBlocks(filePath, Buffer.from(source), source).map((block) => block.src);
|
|
357
|
+
return collectSrcBlocks(parseSfc, filePath, Buffer.from(source), source).map((block) => block.src).filter((src) => !isRelativeSfcSrc(src));
|
|
358
|
+
}
|
|
359
|
+
function readSrcBlock(filePath, tag, src, resolutions) {
|
|
360
|
+
const resolved = sfcSrcFile(filePath, tag, src, resolutions);
|
|
361
|
+
try {
|
|
362
|
+
return {
|
|
363
|
+
path: resolved,
|
|
364
|
+
content: node_fs.default.readFileSync(resolved, "utf8")
|
|
365
|
+
};
|
|
366
|
+
} catch {
|
|
367
|
+
throw new Error(`[vize] <${tag} src="${src}"> not found (resolved: ${resolved}) in ${filePath}`);
|
|
368
|
+
}
|
|
369
369
|
}
|
|
370
370
|
/**
|
|
371
371
|
* Inline `<template src>`, `<script src>` and `<style src>` files into the SFC
|
|
372
|
-
* source
|
|
373
|
-
*
|
|
374
|
-
* requests come from the bundler's `resolutions` (see {@link sfcSrcFile}).
|
|
372
|
+
* source. Blocks are located by the native parser. Module requests come from
|
|
373
|
+
* the bundler's `resolutions` (see {@link sfcSrcFile}).
|
|
375
374
|
*/
|
|
376
|
-
function inlineSfcSrcBlocks(filePath, source, resolutions) {
|
|
375
|
+
function inlineSfcSrcBlocks(parseSfc, filePath, source, resolutions) {
|
|
377
376
|
if (!SRC_BLOCK_HINT.test(source)) return {
|
|
378
377
|
source,
|
|
379
378
|
dependencies: []
|
|
@@ -381,7 +380,7 @@ function inlineSfcSrcBlocks(filePath, source, resolutions) {
|
|
|
381
380
|
const bytes = Buffer.from(source);
|
|
382
381
|
const edits = [];
|
|
383
382
|
const dependencies = [];
|
|
384
|
-
for (const block of collectSrcBlocks(filePath, bytes, source)) {
|
|
383
|
+
for (const block of collectSrcBlocks(parseSfc, filePath, bytes, source)) {
|
|
385
384
|
const file = readSrcBlock(filePath, block.tag, block.src, resolutions);
|
|
386
385
|
dependencies.push(file.path);
|
|
387
386
|
edits.push({
|
|
@@ -436,7 +435,7 @@ function buildSourceHash(source) {
|
|
|
436
435
|
return (0, node_crypto.createHash)("sha256").update(source).digest("hex");
|
|
437
436
|
}
|
|
438
437
|
function compileVueModule(filePath, source, options, cache, srcResolutions) {
|
|
439
|
-
const { source: inlined, dependencies } = inlineSfcSrcBlocks(filePath, source, srcResolutions);
|
|
438
|
+
const { source: inlined, dependencies } = inlineSfcSrcBlocks(_vizejs_native.parseSfc, filePath, source, srcResolutions);
|
|
440
439
|
const sourceHash = buildSourceHash(inlined);
|
|
441
440
|
const signature = buildSignature(options);
|
|
442
441
|
const cached = cache.get(filePath);
|
|
@@ -670,7 +669,7 @@ function hostResolver(context) {
|
|
|
670
669
|
}
|
|
671
670
|
/** Resolve the SFC's `src` module requests (packages, aliases) with the bundler. */
|
|
672
671
|
async function resolveSrcRequests(context, importer, source) {
|
|
673
|
-
const requests =
|
|
672
|
+
const requests = listSfcSrcRequests(_vizejs_native.parseSfc, importer, source);
|
|
674
673
|
const resolve = requests.length > 0 ? hostResolver(context) : null;
|
|
675
674
|
return resolve ? resolveSfcSrcRequests(importer, requests, resolve) : void 0;
|
|
676
675
|
}
|
package/dist/webpack.cjs
CHANGED
package/dist/webpack.mjs
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vizejs/unplugin",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.665.0",
|
|
4
4
|
"description": "Experimental Vue SFC integrations for Rollup, Rolldown, Webpack, esbuild, and Babel powered by Vize",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"babel",
|
|
@@ -68,7 +68,7 @@
|
|
|
68
68
|
"access": "public"
|
|
69
69
|
},
|
|
70
70
|
"dependencies": {
|
|
71
|
-
"@vizejs/native": "0.
|
|
71
|
+
"@vizejs/native": "0.665.0",
|
|
72
72
|
"oxc-transform": "0.144.0",
|
|
73
73
|
"unplugin": "3.3.0"
|
|
74
74
|
},
|