@unhead/addons 1.1.1 → 1.1.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.
@@ -23,6 +23,8 @@ const TreeshakeServerComposables = unplugin.createUnplugin(() => {
23
23
  transformInclude(id) {
24
24
  const { pathname, search } = ufo.parseURL(decodeURIComponent(node_url.pathToFileURL(id).href));
25
25
  const { type } = ufo.parseQuery(search);
26
+ if (pathname.includes("node_modules"))
27
+ return false;
26
28
  if (pathname.endsWith(".vue") && (type === "script" || !search))
27
29
  return true;
28
30
  if (pathname.match(/\.((c|m)?j|t)sx?$/g))
@@ -30,8 +32,9 @@ const TreeshakeServerComposables = unplugin.createUnplugin(() => {
30
32
  return false;
31
33
  },
32
34
  async transform(code, id) {
33
- if (!code.includes("useServerHead") && !code.includes("useServerHeadSafe") && !code.includes("useServerSeoMeta") && !code.includes("useSchemaOrg"))
34
- return null;
35
+ if (!code.includes("useServerHead") && !code.includes("useServerHeadSafe") && !code.includes("useServerSeoMeta") && !code.includes("useSchemaOrg")) {
36
+ return;
37
+ }
35
38
  let transformed;
36
39
  try {
37
40
  transformed = await unpluginAst.transform(code, id, {
@@ -51,12 +54,12 @@ const TreeshakeServerComposables = unplugin.createUnplugin(() => {
51
54
  return transformed;
52
55
  },
53
56
  webpack(ctx) {
54
- if (ctx.name !== "server")
57
+ if (ctx.name === "server")
55
58
  ;
56
59
  },
57
60
  vite: {
58
61
  apply(config, env) {
59
- if (!env.ssrBuild) {
62
+ if (env.ssrBuild) {
60
63
  return true;
61
64
  }
62
65
  return false;
@@ -72,6 +75,8 @@ const UseSeoMetaTransform = unplugin.createUnplugin(() => {
72
75
  transformInclude(id) {
73
76
  const { pathname, search } = ufo.parseURL(decodeURIComponent(node_url.pathToFileURL(id).href));
74
77
  const { type } = ufo.parseQuery(search);
78
+ if (pathname.includes("node_modules"))
79
+ return false;
75
80
  if (pathname.endsWith(".vue") && (type === "script" || !search))
76
81
  return true;
77
82
  if (pathname.match(/\.((c|m)?j|t)sx?$/g))
@@ -109,7 +114,7 @@ const UseSeoMetaTransform = unplugin.createUnplugin(() => {
109
114
  ...importNames
110
115
  }).includes(_node.callee.name)) {
111
116
  const node = _node;
112
- const calleeName = importNames[node.callee.name];
117
+ const calleeName = importNames[node.callee.name] || node.callee.name;
113
118
  const properties = node.arguments[0].properties;
114
119
  if (!properties)
115
120
  return;
@@ -126,7 +131,7 @@ const UseSeoMetaTransform = unplugin.createUnplugin(() => {
126
131
  }
127
132
  if (calleeName === "useServerSeoMeta") {
128
133
  if (output.length)
129
- output.push("})");
134
+ output.push("});");
130
135
  output.push("useServerHead({", " meta: [");
131
136
  } else if (calleeName === "useSeoMeta") {
132
137
  output.push(" meta: [");
@@ -21,6 +21,8 @@ const TreeshakeServerComposables = createUnplugin(() => {
21
21
  transformInclude(id) {
22
22
  const { pathname, search } = parseURL(decodeURIComponent(pathToFileURL(id).href));
23
23
  const { type } = parseQuery(search);
24
+ if (pathname.includes("node_modules"))
25
+ return false;
24
26
  if (pathname.endsWith(".vue") && (type === "script" || !search))
25
27
  return true;
26
28
  if (pathname.match(/\.((c|m)?j|t)sx?$/g))
@@ -28,8 +30,9 @@ const TreeshakeServerComposables = createUnplugin(() => {
28
30
  return false;
29
31
  },
30
32
  async transform(code, id) {
31
- if (!code.includes("useServerHead") && !code.includes("useServerHeadSafe") && !code.includes("useServerSeoMeta") && !code.includes("useSchemaOrg"))
32
- return null;
33
+ if (!code.includes("useServerHead") && !code.includes("useServerHeadSafe") && !code.includes("useServerSeoMeta") && !code.includes("useSchemaOrg")) {
34
+ return;
35
+ }
33
36
  let transformed;
34
37
  try {
35
38
  transformed = await transform(code, id, {
@@ -49,12 +52,12 @@ const TreeshakeServerComposables = createUnplugin(() => {
49
52
  return transformed;
50
53
  },
51
54
  webpack(ctx) {
52
- if (ctx.name !== "server")
55
+ if (ctx.name === "server")
53
56
  ;
54
57
  },
55
58
  vite: {
56
59
  apply(config, env) {
57
- if (!env.ssrBuild) {
60
+ if (env.ssrBuild) {
58
61
  return true;
59
62
  }
60
63
  return false;
@@ -70,6 +73,8 @@ const UseSeoMetaTransform = createUnplugin(() => {
70
73
  transformInclude(id) {
71
74
  const { pathname, search } = parseURL(decodeURIComponent(pathToFileURL(id).href));
72
75
  const { type } = parseQuery(search);
76
+ if (pathname.includes("node_modules"))
77
+ return false;
73
78
  if (pathname.endsWith(".vue") && (type === "script" || !search))
74
79
  return true;
75
80
  if (pathname.match(/\.((c|m)?j|t)sx?$/g))
@@ -107,7 +112,7 @@ const UseSeoMetaTransform = createUnplugin(() => {
107
112
  ...importNames
108
113
  }).includes(_node.callee.name)) {
109
114
  const node = _node;
110
- const calleeName = importNames[node.callee.name];
115
+ const calleeName = importNames[node.callee.name] || node.callee.name;
111
116
  const properties = node.arguments[0].properties;
112
117
  if (!properties)
113
118
  return;
@@ -124,7 +129,7 @@ const UseSeoMetaTransform = createUnplugin(() => {
124
129
  }
125
130
  if (calleeName === "useServerSeoMeta") {
126
131
  if (output.length)
127
- output.push("})");
132
+ output.push("});");
128
133
  output.push("useServerHead({", " meta: [");
129
134
  } else if (calleeName === "useSeoMeta") {
130
135
  output.push(" meta: [");
package/dist/vite.cjs CHANGED
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- const UseSeoMetaTransform = require('./shared/addons.9f407fbd.cjs');
3
+ const UseSeoMetaTransform = require('./shared/addons.35bf3c01.cjs');
4
4
  require('node:url');
5
5
  require('unplugin');
6
6
  require('unplugin-ast');
package/dist/vite.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { T as TreeshakeServerComposables, U as UseSeoMetaTransform } from './shared/addons.6a0db036.mjs';
1
+ import { T as TreeshakeServerComposables, U as UseSeoMetaTransform } from './shared/addons.687f69d7.mjs';
2
2
  import 'node:url';
3
3
  import 'unplugin';
4
4
  import 'unplugin-ast';
package/dist/webpack.cjs CHANGED
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- const UseSeoMetaTransform = require('./shared/addons.9f407fbd.cjs');
3
+ const UseSeoMetaTransform = require('./shared/addons.35bf3c01.cjs');
4
4
  require('node:url');
5
5
  require('unplugin');
6
6
  require('unplugin-ast');
package/dist/webpack.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { T as TreeshakeServerComposables, U as UseSeoMetaTransform } from './shared/addons.6a0db036.mjs';
1
+ import { T as TreeshakeServerComposables, U as UseSeoMetaTransform } from './shared/addons.687f69d7.mjs';
2
2
  import 'node:url';
3
3
  import 'unplugin';
4
4
  import 'unplugin-ast';
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@unhead/addons",
3
3
  "type": "module",
4
- "version": "1.1.1",
4
+ "version": "1.1.3",
5
5
  "packageManager": "pnpm@7.27.1",
6
6
  "author": "Harlan Wilton <harlan@harlanzw.com>",
7
7
  "license": "MIT",
@@ -57,9 +57,9 @@
57
57
  "ufo": "^1.1.0",
58
58
  "unplugin": "^1.1.0",
59
59
  "unplugin-ast": "^0.7.0",
60
- "@unhead/shared": "1.1.1",
61
- "@unhead/schema": "1.1.1",
62
- "unhead": "1.1.1"
60
+ "@unhead/schema": "1.1.3",
61
+ "@unhead/shared": "1.1.3",
62
+ "unhead": "1.1.3"
63
63
  },
64
64
  "devDependencies": {
65
65
  "@babel/types": "^7.21.0"