@unhead/bundler 3.0.0-rc.1
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/LICENSE +21 -0
- package/README.md +124 -0
- package/dist/devtools/bridge.d.mts +10 -0
- package/dist/devtools/bridge.d.ts +10 -0
- package/dist/devtools/bridge.mjs +324 -0
- package/dist/devtools-ui/200.html +1 -0
- package/dist/devtools-ui/404.html +1 -0
- package/dist/devtools-ui/_nuxt/B8PEiB0p.js +1 -0
- package/dist/devtools-ui/_nuxt/B9CgE5J6.js +1 -0
- package/dist/devtools-ui/_nuxt/BJ42UJro.js +1 -0
- package/dist/devtools-ui/_nuxt/BOzzsL9j.js +1 -0
- package/dist/devtools-ui/_nuxt/CC8iqwL_.js +1 -0
- package/dist/devtools-ui/_nuxt/CLj8gQPS.js +1 -0
- package/dist/devtools-ui/_nuxt/CUZFOKWE.js +1 -0
- package/dist/devtools-ui/_nuxt/CVGS_sMg.js +1 -0
- package/dist/devtools-ui/_nuxt/CVO1_9PV.js +1 -0
- package/dist/devtools-ui/_nuxt/Cp-IABpG.js +1 -0
- package/dist/devtools-ui/_nuxt/D0r3Knsf.js +1 -0
- package/dist/devtools-ui/_nuxt/D2XNJYSt.js +1 -0
- package/dist/devtools-ui/_nuxt/D2j1X0ma.js +181 -0
- package/dist/devtools-ui/_nuxt/DNXA5IKg.js +1 -0
- package/dist/devtools-ui/_nuxt/D_TuKxep.js +1 -0
- package/dist/devtools-ui/_nuxt/Deu7B_Ux.js +1 -0
- package/dist/devtools-ui/_nuxt/DevtoolsKeyValue.CGQNexGc.css +1 -0
- package/dist/devtools-ui/_nuxt/DevtoolsTagTable.Bi_gUiSE.css +1 -0
- package/dist/devtools-ui/_nuxt/DevtoolsTip.By8OtGoF.css +1 -0
- package/dist/devtools-ui/_nuxt/Dpg3GvfJ.js +1 -0
- package/dist/devtools-ui/_nuxt/DuAJIi38.js +1 -0
- package/dist/devtools-ui/_nuxt/OCodeBlock.cuqShMa1.css +1 -0
- package/dist/devtools-ui/_nuxt/QXSvvKqL.js +1 -0
- package/dist/devtools-ui/_nuxt/UQ4k7j0M.js +1 -0
- package/dist/devtools-ui/_nuxt/aDaU-lXw.js +1 -0
- package/dist/devtools-ui/_nuxt/builds/latest.json +1 -0
- package/dist/devtools-ui/_nuxt/builds/meta/cae94e84-32db-4da4-8b0f-478d21dcc68b.json +1 -0
- package/dist/devtools-ui/_nuxt/cBFzznMP.js +1 -0
- package/dist/devtools-ui/_nuxt/entry.clcQIxBm.css +1 -0
- package/dist/devtools-ui/_nuxt/error-404.Cu92rxSa.css +1 -0
- package/dist/devtools-ui/_nuxt/error-500.B9_6I3ju.css +1 -0
- package/dist/devtools-ui/_nuxt/identity.qqB_zwgO.css +1 -0
- package/dist/devtools-ui/_nuxt/schema-validation.CRmraV8c.css +1 -0
- package/dist/devtools-ui/_nuxt/schema.CFjU2dVl.css +1 -0
- package/dist/devtools-ui/_nuxt/scripts.UkRMfT5v.css +1 -0
- package/dist/devtools-ui/_nuxt/serp.CZGidvZH.css +1 -0
- package/dist/devtools-ui/_nuxt/wDzz0qaB.js +1 -0
- package/dist/devtools-ui/index.html +1 -0
- package/dist/index.d.mts +28 -0
- package/dist/index.d.ts +28 -0
- package/dist/index.mjs +79 -0
- package/dist/minify/esbuild.d.mts +5 -0
- package/dist/minify/esbuild.d.ts +5 -0
- package/dist/minify/esbuild.mjs +10 -0
- package/dist/minify/lightningcss.d.mts +5 -0
- package/dist/minify/lightningcss.d.ts +5 -0
- package/dist/minify/lightningcss.mjs +14 -0
- package/dist/minify/rolldown.d.mts +5 -0
- package/dist/minify/rolldown.d.ts +5 -0
- package/dist/minify/rolldown.mjs +10 -0
- package/dist/shared/bundler.BwKIGaKX.d.mts +60 -0
- package/dist/shared/bundler.BwKIGaKX.d.ts +60 -0
- package/dist/shared/bundler.DRWfqG8C.mjs +453 -0
- package/dist/vite.d.mts +6 -0
- package/dist/vite.d.ts +6 -0
- package/dist/vite.mjs +282 -0
- package/dist/webpack.d.mts +5 -0
- package/dist/webpack.d.ts +5 -0
- package/dist/webpack.mjs +31 -0
- package/package.json +111 -0
- package/vite.d.ts +1 -0
- package/webpack.d.ts +1 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { HeadPluginInput } from 'unhead/types';
|
|
2
|
+
export { InferSeoMetaPlugin } from 'unhead/plugins';
|
|
3
|
+
|
|
4
|
+
declare const DefaultCriticalTags: {
|
|
5
|
+
htmlAttrs: {
|
|
6
|
+
lang: string;
|
|
7
|
+
};
|
|
8
|
+
meta: ({
|
|
9
|
+
charset: string;
|
|
10
|
+
name?: undefined;
|
|
11
|
+
content?: undefined;
|
|
12
|
+
} | {
|
|
13
|
+
name: string;
|
|
14
|
+
content: string;
|
|
15
|
+
charset?: undefined;
|
|
16
|
+
})[];
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Unhead plugin that propagates source location metadata from entry options to tags.
|
|
21
|
+
*
|
|
22
|
+
* On the server, it also serializes the full devtools state into a
|
|
23
|
+
* `<script id="unhead:devtools">` payload so the client bridge can display
|
|
24
|
+
* server-only entries.
|
|
25
|
+
*/
|
|
26
|
+
declare function devtoolsPlugin(): HeadPluginInput;
|
|
27
|
+
|
|
28
|
+
export { DefaultCriticalTags, devtoolsPlugin };
|
package/dist/index.mjs
ADDED
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
export { InferSeoMetaPlugin } from 'unhead/plugins';
|
|
2
|
+
|
|
3
|
+
const DefaultCriticalTags = {
|
|
4
|
+
htmlAttrs: {
|
|
5
|
+
lang: "en"
|
|
6
|
+
},
|
|
7
|
+
meta: [
|
|
8
|
+
{ charset: "utf-8" },
|
|
9
|
+
{ name: "viewport", content: "width=device-width, initial-scale=1" }
|
|
10
|
+
]
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
function devtoolsPlugin() {
|
|
14
|
+
return (head) => {
|
|
15
|
+
return {
|
|
16
|
+
key: "devtools",
|
|
17
|
+
hooks: {
|
|
18
|
+
"entries:normalize": function({ tags, entry }) {
|
|
19
|
+
const source = entry.options?._source;
|
|
20
|
+
if (!source)
|
|
21
|
+
return;
|
|
22
|
+
for (const tag of tags) {
|
|
23
|
+
if (!tag._source)
|
|
24
|
+
tag._source = source;
|
|
25
|
+
}
|
|
26
|
+
},
|
|
27
|
+
"tags:resolve": function(ctx) {
|
|
28
|
+
if (!head.ssr)
|
|
29
|
+
return;
|
|
30
|
+
const entries = [];
|
|
31
|
+
for (const [id, entry] of head.entries) {
|
|
32
|
+
let input = {};
|
|
33
|
+
try {
|
|
34
|
+
input = JSON.parse(JSON.stringify(entry.input || {}, (_k, v) => {
|
|
35
|
+
if (typeof v === "function")
|
|
36
|
+
return `\u0192 ${v.name || "anonymous"}()`;
|
|
37
|
+
if (typeof v === "undefined")
|
|
38
|
+
return "\u2298 undefined";
|
|
39
|
+
return v;
|
|
40
|
+
}));
|
|
41
|
+
} catch {
|
|
42
|
+
}
|
|
43
|
+
entries.push({
|
|
44
|
+
id,
|
|
45
|
+
source: entry.options?._source,
|
|
46
|
+
input,
|
|
47
|
+
tagCount: (entry._tags || []).length,
|
|
48
|
+
mode: "server"
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
const tags = [];
|
|
52
|
+
for (const tag of ctx.tags) {
|
|
53
|
+
if (tag.props?.id === "unhead:devtools" || tag.props?.id === "unhead:payload")
|
|
54
|
+
continue;
|
|
55
|
+
tags.push({
|
|
56
|
+
tag: tag.tag,
|
|
57
|
+
props: { ...tag.props },
|
|
58
|
+
innerHTML: tag.innerHTML,
|
|
59
|
+
textContent: tag.textContent,
|
|
60
|
+
position: tag.tagPosition,
|
|
61
|
+
priority: tag._w,
|
|
62
|
+
dedupeKey: tag._d,
|
|
63
|
+
source: tag._source,
|
|
64
|
+
mode: "server"
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
ctx.tags.push({
|
|
68
|
+
tag: "script",
|
|
69
|
+
// Escape `<` so a serialized `<\/script>` cannot close the inline JSON block early
|
|
70
|
+
innerHTML: JSON.stringify({ entries, tags }).replace(/</g, "\\u003C"),
|
|
71
|
+
props: { id: "unhead:devtools", type: "application/json" }
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
};
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
export { DefaultCriticalTags, devtoolsPlugin };
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { transform } from 'lightningcss';
|
|
2
|
+
|
|
3
|
+
function createCSSMinifier() {
|
|
4
|
+
return async (code) => {
|
|
5
|
+
const result = transform({
|
|
6
|
+
filename: "inline.css",
|
|
7
|
+
code: new TextEncoder().encode(code),
|
|
8
|
+
minify: true
|
|
9
|
+
});
|
|
10
|
+
return new TextDecoder().decode(result.code).trim();
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export { createCSSMinifier };
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
type MinifyFn = (code: string) => Promise<string | null>;
|
|
2
|
+
interface MinifyTransformOptions extends BaseTransformerTypes {
|
|
3
|
+
/**
|
|
4
|
+
* Custom JS minifier function, or `false` to disable JS minification.
|
|
5
|
+
*
|
|
6
|
+
* Use a subpath import to get a preconfigured minifier:
|
|
7
|
+
* - `@unhead/bundler/minify/rolldown` (Vite 8+)
|
|
8
|
+
* - `@unhead/bundler/minify/esbuild` (Vite 7)
|
|
9
|
+
*/
|
|
10
|
+
js?: false | MinifyFn;
|
|
11
|
+
/**
|
|
12
|
+
* Custom CSS minifier function, or `false` to disable CSS minification.
|
|
13
|
+
*
|
|
14
|
+
* Use `@unhead/bundler/minify/lightningcss` for a preconfigured minifier.
|
|
15
|
+
*/
|
|
16
|
+
css?: false | MinifyFn;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
interface TreeshakeServerComposablesOptions extends BaseTransformerTypes {
|
|
20
|
+
/**
|
|
21
|
+
* @deprecated Use `treeshake: false` at the top level instead.
|
|
22
|
+
*/
|
|
23
|
+
enabled?: boolean;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
interface UseSeoMetaTransformOptions extends BaseTransformerTypes {
|
|
27
|
+
/**
|
|
28
|
+
* Whether to transform imports of `useSeoMeta` and `useServerSeoMeta` to `useHead` and `useServerHead`.
|
|
29
|
+
*/
|
|
30
|
+
imports?: boolean;
|
|
31
|
+
/**
|
|
32
|
+
* Extra import paths to consider where `useSeoMeta()` may be imported from.
|
|
33
|
+
*/
|
|
34
|
+
importPaths?: string[];
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
interface BaseTransformerTypes {
|
|
38
|
+
sourcemap?: boolean;
|
|
39
|
+
filter?: {
|
|
40
|
+
exclude?: RegExp[];
|
|
41
|
+
include?: RegExp[];
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
interface UnpluginOptions extends BaseTransformerTypes {
|
|
45
|
+
treeshake?: TreeshakeServerComposablesOptions | false;
|
|
46
|
+
transformSeoMeta?: UseSeoMetaTransformOptions | false;
|
|
47
|
+
minify?: MinifyTransformOptions | false;
|
|
48
|
+
}
|
|
49
|
+
interface VitePluginOptions extends UnpluginOptions {
|
|
50
|
+
/** Vite DevTools integration (dev-only). Enabled by default, set `false` to disable. */
|
|
51
|
+
devtools?: UnheadDevtoolsOptions | false;
|
|
52
|
+
/** Inject ValidatePlugin in dev to surface head tag warnings in the console. Enabled by default, set `false` to disable. */
|
|
53
|
+
validate?: boolean;
|
|
54
|
+
/** @internal */
|
|
55
|
+
_framework?: string;
|
|
56
|
+
}
|
|
57
|
+
interface UnheadDevtoolsOptions {
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
export type { MinifyFn as M, UnpluginOptions as U, VitePluginOptions as V };
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
type MinifyFn = (code: string) => Promise<string | null>;
|
|
2
|
+
interface MinifyTransformOptions extends BaseTransformerTypes {
|
|
3
|
+
/**
|
|
4
|
+
* Custom JS minifier function, or `false` to disable JS minification.
|
|
5
|
+
*
|
|
6
|
+
* Use a subpath import to get a preconfigured minifier:
|
|
7
|
+
* - `@unhead/bundler/minify/rolldown` (Vite 8+)
|
|
8
|
+
* - `@unhead/bundler/minify/esbuild` (Vite 7)
|
|
9
|
+
*/
|
|
10
|
+
js?: false | MinifyFn;
|
|
11
|
+
/**
|
|
12
|
+
* Custom CSS minifier function, or `false` to disable CSS minification.
|
|
13
|
+
*
|
|
14
|
+
* Use `@unhead/bundler/minify/lightningcss` for a preconfigured minifier.
|
|
15
|
+
*/
|
|
16
|
+
css?: false | MinifyFn;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
interface TreeshakeServerComposablesOptions extends BaseTransformerTypes {
|
|
20
|
+
/**
|
|
21
|
+
* @deprecated Use `treeshake: false` at the top level instead.
|
|
22
|
+
*/
|
|
23
|
+
enabled?: boolean;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
interface UseSeoMetaTransformOptions extends BaseTransformerTypes {
|
|
27
|
+
/**
|
|
28
|
+
* Whether to transform imports of `useSeoMeta` and `useServerSeoMeta` to `useHead` and `useServerHead`.
|
|
29
|
+
*/
|
|
30
|
+
imports?: boolean;
|
|
31
|
+
/**
|
|
32
|
+
* Extra import paths to consider where `useSeoMeta()` may be imported from.
|
|
33
|
+
*/
|
|
34
|
+
importPaths?: string[];
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
interface BaseTransformerTypes {
|
|
38
|
+
sourcemap?: boolean;
|
|
39
|
+
filter?: {
|
|
40
|
+
exclude?: RegExp[];
|
|
41
|
+
include?: RegExp[];
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
interface UnpluginOptions extends BaseTransformerTypes {
|
|
45
|
+
treeshake?: TreeshakeServerComposablesOptions | false;
|
|
46
|
+
transformSeoMeta?: UseSeoMetaTransformOptions | false;
|
|
47
|
+
minify?: MinifyTransformOptions | false;
|
|
48
|
+
}
|
|
49
|
+
interface VitePluginOptions extends UnpluginOptions {
|
|
50
|
+
/** Vite DevTools integration (dev-only). Enabled by default, set `false` to disable. */
|
|
51
|
+
devtools?: UnheadDevtoolsOptions | false;
|
|
52
|
+
/** Inject ValidatePlugin in dev to surface head tag warnings in the console. Enabled by default, set `false` to disable. */
|
|
53
|
+
validate?: boolean;
|
|
54
|
+
/** @internal */
|
|
55
|
+
_framework?: string;
|
|
56
|
+
}
|
|
57
|
+
interface UnheadDevtoolsOptions {
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
export type { MinifyFn as M, UnpluginOptions as U, VitePluginOptions as V };
|