@unhead/addons 0.6.8 → 0.6.9

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.
@@ -18,19 +18,19 @@ const TreeshakeServerComposables = unplugin.createUnplugin((userConfig = {}) =>
18
18
  "node_modules"
19
19
  ]);
20
20
  let root = userConfig.root;
21
+ let enabled = true;
21
22
  return {
22
23
  name: "unhead:remove-server-composables",
23
24
  enforce: "post",
24
25
  transformInclude(id) {
25
- if (root && !id.startsWith(root))
26
+ if (enabled && root && !id.startsWith(root))
26
27
  return false;
27
28
  if (!filter(id))
28
29
  return false;
29
30
  },
30
31
  async transform(code, id) {
31
- if (!code.includes("useServerHead") && !code.includes("useSeoMeta")) {
32
+ if (!code.includes("useServerHead") && !code.includes("useSeoMeta"))
32
33
  return null;
33
- }
34
34
  let transformed;
35
35
  try {
36
36
  transformed = await unpluginAst.transform(code, id, {
@@ -46,9 +46,20 @@ const TreeshakeServerComposables = unplugin.createUnplugin((userConfig = {}) =>
46
46
  }
47
47
  return transformed;
48
48
  },
49
+ webpack(ctx) {
50
+ if (ctx.name !== "server")
51
+ enabled = false;
52
+ },
49
53
  vite: {
50
54
  async config(config) {
51
55
  root = root || config.root || process.cwd();
56
+ },
57
+ apply(config, env) {
58
+ if (!env.ssrBuild) {
59
+ enabled = false;
60
+ return false;
61
+ }
62
+ return true;
52
63
  }
53
64
  }
54
65
  };
@@ -16,19 +16,19 @@ const TreeshakeServerComposables = createUnplugin((userConfig = {}) => {
16
16
  "node_modules"
17
17
  ]);
18
18
  let root = userConfig.root;
19
+ let enabled = true;
19
20
  return {
20
21
  name: "unhead:remove-server-composables",
21
22
  enforce: "post",
22
23
  transformInclude(id) {
23
- if (root && !id.startsWith(root))
24
+ if (enabled && root && !id.startsWith(root))
24
25
  return false;
25
26
  if (!filter(id))
26
27
  return false;
27
28
  },
28
29
  async transform(code, id) {
29
- if (!code.includes("useServerHead") && !code.includes("useSeoMeta")) {
30
+ if (!code.includes("useServerHead") && !code.includes("useSeoMeta"))
30
31
  return null;
31
- }
32
32
  let transformed;
33
33
  try {
34
34
  transformed = await transform(code, id, {
@@ -44,9 +44,20 @@ const TreeshakeServerComposables = createUnplugin((userConfig = {}) => {
44
44
  }
45
45
  return transformed;
46
46
  },
47
+ webpack(ctx) {
48
+ if (ctx.name !== "server")
49
+ enabled = false;
50
+ },
47
51
  vite: {
48
52
  async config(config) {
49
53
  root = root || config.root || process.cwd();
54
+ },
55
+ apply(config, env) {
56
+ if (!env.ssrBuild) {
57
+ enabled = false;
58
+ return false;
59
+ }
60
+ return true;
50
61
  }
51
62
  }
52
63
  };
package/dist/vite.cjs CHANGED
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- const TreeshakeServerComposables = require('./shared/addons.8476d2f2.cjs');
3
+ const TreeshakeServerComposables = require('./shared/addons.ad72c527.cjs');
4
4
  require('unplugin');
5
5
  require('@rollup/pluginutils');
6
6
  require('unplugin-ast');
package/dist/vite.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { T as TreeshakeServerComposables } from './shared/addons.f55513ea.mjs';
1
+ import { T as TreeshakeServerComposables } from './shared/addons.dfbb9146.mjs';
2
2
  import 'unplugin';
3
3
  import '@rollup/pluginutils';
4
4
  import 'unplugin-ast';
package/dist/webpack.cjs CHANGED
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- const TreeshakeServerComposables = require('./shared/addons.8476d2f2.cjs');
3
+ const TreeshakeServerComposables = require('./shared/addons.ad72c527.cjs');
4
4
  require('unplugin');
5
5
  require('@rollup/pluginutils');
6
6
  require('unplugin-ast');
package/dist/webpack.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { T as TreeshakeServerComposables } from './shared/addons.f55513ea.mjs';
1
+ import { T as TreeshakeServerComposables } from './shared/addons.dfbb9146.mjs';
2
2
  import 'unplugin';
3
3
  import '@rollup/pluginutils';
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": "0.6.8",
4
+ "version": "0.6.9",
5
5
  "packageManager": "pnpm@7.14.0",
6
6
  "author": "Harlan Wilton <harlan@harlanzw.com>",
7
7
  "license": "MIT",
@@ -33,6 +33,9 @@
33
33
  "import": "./dist/webpack.mjs"
34
34
  }
35
35
  },
36
+ "main": "dist/index.cjs",
37
+ "module": "dist/index.mjs",
38
+ "types": "dist/index.d.ts",
36
39
  "typesVersions": {
37
40
  "*": {
38
41
  "vite": [
@@ -43,16 +46,13 @@
43
46
  ]
44
47
  }
45
48
  },
46
- "main": "dist/index.cjs",
47
- "module": "dist/index.mjs",
48
- "types": "dist/index.d.ts",
49
49
  "files": [
50
50
  "dist"
51
51
  ],
52
52
  "dependencies": {
53
- "unhead": "0.6.8",
54
53
  "@rollup/pluginutils": "^5.0.2",
55
- "@unhead/schema": "0.6.8",
54
+ "@unhead/schema": "0.6.9",
55
+ "unhead": "0.6.9",
56
56
  "unplugin": "^1.0.0",
57
57
  "unplugin-ast": "^0.5.5"
58
58
  },