@unhead/addons 3.0.0-beta.10 → 3.0.0-beta.12
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.
|
@@ -7,6 +7,8 @@ import { createUnplugin } from 'unplugin';
|
|
|
7
7
|
import { createContext, runInContext } from 'node:vm';
|
|
8
8
|
import { resolveMetaKeyType, resolveMetaKeyValue, resolvePackedMetaObjectValue } from 'unhead/utils';
|
|
9
9
|
|
|
10
|
+
const NODE_MODULES_RE$1 = /[\\/]node_modules[\\/]/;
|
|
11
|
+
const TRANSFORM_RE$1 = /\.(?:(?:c|m)?j|t)sx?$/;
|
|
10
12
|
const functionNames = [
|
|
11
13
|
"useServerHead",
|
|
12
14
|
"useServerHeadSafe",
|
|
@@ -24,7 +26,7 @@ const TreeshakeServerComposables = createUnplugin((options = {}) => {
|
|
|
24
26
|
return false;
|
|
25
27
|
const { pathname, search } = parseURL(decodeURIComponent(pathToFileURL(id).href));
|
|
26
28
|
const { type } = parseQuery(search);
|
|
27
|
-
if (
|
|
29
|
+
if (NODE_MODULES_RE$1.test(pathname))
|
|
28
30
|
return false;
|
|
29
31
|
if (options.filter?.include?.some((pattern) => id.match(pattern)))
|
|
30
32
|
return true;
|
|
@@ -32,7 +34,7 @@ const TreeshakeServerComposables = createUnplugin((options = {}) => {
|
|
|
32
34
|
return false;
|
|
33
35
|
if (pathname.endsWith(".vue") && (type === "script" || !search))
|
|
34
36
|
return true;
|
|
35
|
-
if (
|
|
37
|
+
if (TRANSFORM_RE$1.test(pathname))
|
|
36
38
|
return true;
|
|
37
39
|
return false;
|
|
38
40
|
},
|
|
@@ -72,6 +74,8 @@ const TreeshakeServerComposables = createUnplugin((options = {}) => {
|
|
|
72
74
|
};
|
|
73
75
|
});
|
|
74
76
|
|
|
77
|
+
const NODE_MODULES_RE = /[\\/]node_modules[\\/]/;
|
|
78
|
+
const TRANSFORM_RE = /\.(?:(?:c|m)?j|t)sx?$/;
|
|
75
79
|
const SEO_META_NAMES = /* @__PURE__ */ new Set(["useSeoMeta", "useServerSeoMeta"]);
|
|
76
80
|
const UseSeoMetaTransform = createUnplugin((options = {}) => {
|
|
77
81
|
options.imports = options.imports || true;
|
|
@@ -87,7 +91,7 @@ const UseSeoMetaTransform = createUnplugin((options = {}) => {
|
|
|
87
91
|
transformInclude(id) {
|
|
88
92
|
const { pathname, search } = parseURL(decodeURIComponent(pathToFileURL(id).href));
|
|
89
93
|
const { type } = parseQuery(search);
|
|
90
|
-
if (
|
|
94
|
+
if (NODE_MODULES_RE.test(pathname))
|
|
91
95
|
return false;
|
|
92
96
|
if (options.filter?.include?.some((pattern) => id.match(pattern)))
|
|
93
97
|
return true;
|
|
@@ -95,7 +99,7 @@ const UseSeoMetaTransform = createUnplugin((options = {}) => {
|
|
|
95
99
|
return false;
|
|
96
100
|
if (pathname.endsWith(".vue") && (type === "script" || !search))
|
|
97
101
|
return true;
|
|
98
|
-
if (
|
|
102
|
+
if (TRANSFORM_RE.test(pathname))
|
|
99
103
|
return true;
|
|
100
104
|
return false;
|
|
101
105
|
},
|
|
@@ -112,7 +116,7 @@ const UseSeoMetaTransform = createUnplugin((options = {}) => {
|
|
|
112
116
|
enter(node, parent) {
|
|
113
117
|
if (node.type === "Identifier" && !(parent?.type === "CallExpression" && parent.callee === node) && parent?.type !== "ImportSpecifier") {
|
|
114
118
|
const decl2 = scopeTracker.getDeclaration(node.name);
|
|
115
|
-
if (decl2 instanceof ScopeTrackerImport && isValidPackage(decl2.importNode.source.value) && SEO_META_NAMES.has(decl2.node.imported.name)) {
|
|
119
|
+
if (decl2 instanceof ScopeTrackerImport && isValidPackage(decl2.importNode.source.value) && decl2.node.type === "ImportSpecifier" && decl2.node.imported.type === "Identifier" && SEO_META_NAMES.has(decl2.node.imported.name)) {
|
|
116
120
|
valueReferenced.add(decl2.node.imported.name);
|
|
117
121
|
}
|
|
118
122
|
}
|
|
@@ -122,7 +126,7 @@ const UseSeoMetaTransform = createUnplugin((options = {}) => {
|
|
|
122
126
|
let originalName;
|
|
123
127
|
let importDecl = null;
|
|
124
128
|
if (decl instanceof ScopeTrackerImport) {
|
|
125
|
-
if (!isValidPackage(decl.importNode.source.value))
|
|
129
|
+
if (!isValidPackage(decl.importNode.source.value) || decl.node.type !== "ImportSpecifier" || decl.node.imported.type !== "Identifier")
|
|
126
130
|
return;
|
|
127
131
|
originalName = decl.node.imported.name;
|
|
128
132
|
importDecl = decl.importNode;
|
|
@@ -177,8 +181,6 @@ const UseSeoMetaTransform = createUnplugin((options = {}) => {
|
|
|
177
181
|
}
|
|
178
182
|
let value = code.substring(property.value.start, property.value.end);
|
|
179
183
|
if (property.value.type === "ArrayExpression") {
|
|
180
|
-
if (output === false)
|
|
181
|
-
return;
|
|
182
184
|
const elements = property.value.elements;
|
|
183
185
|
if (!elements.length)
|
|
184
186
|
return;
|
|
@@ -246,7 +248,7 @@ const UseSeoMetaTransform = createUnplugin((options = {}) => {
|
|
|
246
248
|
}
|
|
247
249
|
s.overwrite(
|
|
248
250
|
importNode.specifiers[0].start,
|
|
249
|
-
importNode.specifiers
|
|
251
|
+
importNode.specifiers.at(-1).end,
|
|
250
252
|
[...newSpecifiers].join(", ")
|
|
251
253
|
);
|
|
252
254
|
}
|
package/dist/vite.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { T as TreeshakeServerComposables, U as UseSeoMetaTransform } from './shared/addons.
|
|
1
|
+
import { T as TreeshakeServerComposables, U as UseSeoMetaTransform } from './shared/addons.B0i_V9Oi.mjs';
|
|
2
2
|
import 'node:url';
|
|
3
3
|
import 'magic-string';
|
|
4
4
|
import 'oxc-parser';
|
package/dist/webpack.d.mts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
+
import * as unplugin from 'unplugin';
|
|
1
2
|
import { U as UnpluginOptions } from './shared/addons.51MZ0zeg.mjs';
|
|
2
3
|
|
|
3
|
-
declare const _default: (options?: UnpluginOptions) =>
|
|
4
|
+
declare const _default: (options?: UnpluginOptions) => unplugin.WebpackPluginInstance[];
|
|
4
5
|
|
|
5
6
|
export { UnpluginOptions, _default as default };
|
package/dist/webpack.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
+
import * as unplugin from 'unplugin';
|
|
1
2
|
import { U as UnpluginOptions } from './shared/addons.51MZ0zeg.js';
|
|
2
3
|
|
|
3
|
-
declare const _default: (options?: UnpluginOptions) =>
|
|
4
|
+
declare const _default: (options?: UnpluginOptions) => unplugin.WebpackPluginInstance[];
|
|
4
5
|
|
|
5
6
|
export { UnpluginOptions, _default as default };
|
package/dist/webpack.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { T as TreeshakeServerComposables, U as UseSeoMetaTransform } from './shared/addons.
|
|
1
|
+
import { T as TreeshakeServerComposables, U as UseSeoMetaTransform } from './shared/addons.B0i_V9Oi.mjs';
|
|
2
2
|
import 'node:url';
|
|
3
3
|
import 'magic-string';
|
|
4
4
|
import 'oxc-parser';
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@unhead/addons",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "3.0.0-beta.
|
|
4
|
+
"version": "3.0.0-beta.12",
|
|
5
5
|
"description": "Unhead addons for build tools and bundlers.",
|
|
6
6
|
"author": "Harlan Wilton <harlan@harlanzw.com>",
|
|
7
7
|
"license": "MIT",
|
|
@@ -52,20 +52,20 @@
|
|
|
52
52
|
"dist"
|
|
53
53
|
],
|
|
54
54
|
"peerDependencies": {
|
|
55
|
-
"unhead": "3.0.0-beta.
|
|
55
|
+
"unhead": "^3.0.0-beta.12"
|
|
56
56
|
},
|
|
57
57
|
"dependencies": {
|
|
58
58
|
"@rollup/pluginutils": "^5.3.0",
|
|
59
59
|
"magic-string": "^0.30.21",
|
|
60
|
-
"oxc-parser": "^0.
|
|
60
|
+
"oxc-parser": "^0.117.0",
|
|
61
61
|
"oxc-walker": "^0.7.0",
|
|
62
|
-
"ufo": "^1.6.
|
|
63
|
-
"unplugin": "^
|
|
62
|
+
"ufo": "^1.6.3",
|
|
63
|
+
"unplugin": "^3.0.0"
|
|
64
64
|
},
|
|
65
65
|
"devDependencies": {
|
|
66
|
-
"rollup": "^4.
|
|
67
|
-
"vite": "^7.
|
|
68
|
-
"unhead": "3.0.0-beta.
|
|
66
|
+
"rollup": "^4.59.0",
|
|
67
|
+
"vite": "^7.3.1",
|
|
68
|
+
"unhead": "3.0.0-beta.12"
|
|
69
69
|
},
|
|
70
70
|
"scripts": {
|
|
71
71
|
"build": "unbuild",
|