@markless/bundler 0.1.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/LICENSE +21 -0
- package/README.md +7 -0
- package/dist/preload.d.ts +79 -0
- package/dist/preload.js +75 -0
- package/dist/rolldown-Czh1duwk.js +1802 -0
- package/dist/rolldown.d.ts +79 -0
- package/dist/rolldown.js +3 -0
- package/dist/source-module-BRb5P7wL.d.ts +6 -0
- package/dist/source-module-CSRzW4Ny.js +876 -0
- package/dist/types-D6KerlYq.d.ts +107 -0
- package/dist/vite.d.ts +12 -0
- package/dist/vite.js +387 -0
- package/package.json +55 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Jack Shelton
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
# @markless/bundler
|
|
2
|
+
|
|
3
|
+
Markless build plugins for Rolldown and Vite. Used through
|
|
4
|
+
`@markless/core/vite` and `@markless/core/rolldown`; install `@markless/core`
|
|
5
|
+
instead unless you are integrating the plugins directly.
|
|
6
|
+
|
|
7
|
+
See the repository for documentation: https://github.com/markless-dev/markless
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import { o as MarklessBundleGraph } from "./types-D6KerlYq.js";
|
|
2
|
+
import { r as symbolVirtualModuleSourceFile } from "./source-module-BRb5P7wL.js";
|
|
3
|
+
|
|
4
|
+
//#region src/build/preload-plan.d.ts
|
|
5
|
+
type ModulePreloadPlanInput = {
|
|
6
|
+
readonly bundleGraph: MarklessBundleGraph | undefined;
|
|
7
|
+
readonly roots: readonly ModulePreloadRoot[];
|
|
8
|
+
readonly base?: string;
|
|
9
|
+
readonly minProbability?: number;
|
|
10
|
+
readonly maxPreloads?: number;
|
|
11
|
+
};
|
|
12
|
+
type ModulePreloadRoot = string | {
|
|
13
|
+
readonly name: string;
|
|
14
|
+
readonly priority?: ModulePreloadPriority;
|
|
15
|
+
readonly fetchPriority?: ModulePreloadFetchPriority;
|
|
16
|
+
readonly edges?: 'all' | 'dynamic-only';
|
|
17
|
+
};
|
|
18
|
+
type ModulePreloadPriority = 'high' | 'auto' | 'low';
|
|
19
|
+
type ModulePreloadFetchPriority = 'high' | 'auto' | 'low';
|
|
20
|
+
type ModulePreloadPlanEntry = {
|
|
21
|
+
readonly href: string;
|
|
22
|
+
readonly name: string;
|
|
23
|
+
readonly priority: ModulePreloadPriority;
|
|
24
|
+
readonly fetchPriority?: ModulePreloadFetchPriority;
|
|
25
|
+
readonly probability: number;
|
|
26
|
+
};
|
|
27
|
+
declare function planModulePreloadUrls(input: ModulePreloadPlanInput): string[];
|
|
28
|
+
declare function planModulePreloads(input: ModulePreloadPlanInput): ModulePreloadPlanEntry[];
|
|
29
|
+
//#endregion
|
|
30
|
+
//#region src/build/module-preload-dom.d.ts
|
|
31
|
+
type LazySymbolPreloadView = {
|
|
32
|
+
readonly events?: ReadonlyArray<{
|
|
33
|
+
readonly symbolIds?: readonly string[];
|
|
34
|
+
}>;
|
|
35
|
+
readonly domUpdates?: ReadonlyArray<{
|
|
36
|
+
readonly symbolId?: string;
|
|
37
|
+
}>;
|
|
38
|
+
readonly behaviors?: ReadonlyArray<{
|
|
39
|
+
readonly symbolId?: string;
|
|
40
|
+
}>;
|
|
41
|
+
readonly asyncBoundaries?: ReadonlyArray<{
|
|
42
|
+
readonly asyncReads?: ReadonlyArray<{
|
|
43
|
+
readonly runnerSymbolId?: string;
|
|
44
|
+
}>;
|
|
45
|
+
}>;
|
|
46
|
+
};
|
|
47
|
+
type PreloadLazySymbolModulesInput = {
|
|
48
|
+
readonly view: LazySymbolPreloadView;
|
|
49
|
+
readonly bundleGraph: MarklessBundleGraph | undefined;
|
|
50
|
+
readonly base?: string;
|
|
51
|
+
readonly document?: ModulePreloadDocument;
|
|
52
|
+
readonly minProbability?: number;
|
|
53
|
+
readonly maxPreloads?: number;
|
|
54
|
+
};
|
|
55
|
+
type AppendedModulePreloads = {
|
|
56
|
+
readonly planned: readonly ModulePreloadPlanEntry[];
|
|
57
|
+
readonly appendedHrefs: readonly string[];
|
|
58
|
+
};
|
|
59
|
+
type ModulePreloadDocument = {
|
|
60
|
+
readonly baseURI?: string;
|
|
61
|
+
readonly head?: {
|
|
62
|
+
appendChild(node: ModulePreloadLink): unknown;
|
|
63
|
+
};
|
|
64
|
+
createElement(name: 'link'): ModulePreloadLink;
|
|
65
|
+
querySelectorAll(selector: string): Iterable<ModulePreloadExistingLink>;
|
|
66
|
+
};
|
|
67
|
+
type ModulePreloadExistingLink = {
|
|
68
|
+
readonly href?: string;
|
|
69
|
+
getAttribute?(name: string): string | null;
|
|
70
|
+
};
|
|
71
|
+
type ModulePreloadLink = ModulePreloadExistingLink & {
|
|
72
|
+
rel: string;
|
|
73
|
+
href: string;
|
|
74
|
+
crossOrigin: string;
|
|
75
|
+
setAttribute?(name: string, value: string): void;
|
|
76
|
+
};
|
|
77
|
+
declare function preloadLazySymbolModules(input: PreloadLazySymbolModulesInput): AppendedModulePreloads;
|
|
78
|
+
//#endregion
|
|
79
|
+
export { type AppendedModulePreloads, type LazySymbolPreloadView, type MarklessBundleGraph, type ModulePreloadFetchPriority, type ModulePreloadPlanEntry, type ModulePreloadPlanInput, type ModulePreloadPriority, type ModulePreloadRoot, type PreloadLazySymbolModulesInput, planModulePreloadUrls, planModulePreloads, preloadLazySymbolModules, symbolVirtualModuleSourceFile };
|
package/dist/preload.js
ADDED
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import { S as planModulePreloads, l as symbolVirtualModuleSourceFile, x as planModulePreloadUrls } from "./source-module-CSRzW4Ny.js";
|
|
2
|
+
//#region src/build/module-preload-dom.ts
|
|
3
|
+
const PRIORITY_RANK = {
|
|
4
|
+
high: 2,
|
|
5
|
+
auto: 1,
|
|
6
|
+
low: 0
|
|
7
|
+
};
|
|
8
|
+
function preloadLazySymbolModules(input) {
|
|
9
|
+
const planned = planModulePreloads({
|
|
10
|
+
base: input.base,
|
|
11
|
+
bundleGraph: input.bundleGraph,
|
|
12
|
+
maxPreloads: input.maxPreloads,
|
|
13
|
+
minProbability: input.minProbability,
|
|
14
|
+
roots: lazySymbolPreloadRootsFromView(input.view)
|
|
15
|
+
});
|
|
16
|
+
return {
|
|
17
|
+
appendedHrefs: appendModulePreloadLinks(planned, input.document),
|
|
18
|
+
planned
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
function lazySymbolPreloadRootsFromView(view) {
|
|
22
|
+
const roots = /* @__PURE__ */ new Map();
|
|
23
|
+
const add = (name, priority) => {
|
|
24
|
+
if (!name) return;
|
|
25
|
+
const existing = roots.get(name);
|
|
26
|
+
if (existing && PRIORITY_RANK[existing.priority ?? "auto"] >= PRIORITY_RANK[priority]) return;
|
|
27
|
+
roots.set(name, {
|
|
28
|
+
name,
|
|
29
|
+
priority
|
|
30
|
+
});
|
|
31
|
+
};
|
|
32
|
+
for (const event of view.events ?? []) for (const symbolId of event.symbolIds ?? []) add(symbolId, "high");
|
|
33
|
+
for (const behavior of view.behaviors ?? []) add(behavior.symbolId, "high");
|
|
34
|
+
for (const update of view.domUpdates ?? []) add(update.symbolId, "low");
|
|
35
|
+
for (const boundary of view.asyncBoundaries ?? []) for (const read of boundary.asyncReads ?? []) add(read.runnerSymbolId, "low");
|
|
36
|
+
return [...roots.values()];
|
|
37
|
+
}
|
|
38
|
+
function appendModulePreloadLinks(preloads, document = defaultDocument()) {
|
|
39
|
+
if (!document?.head) return [];
|
|
40
|
+
const seen = existingModulePreloadHrefs(document);
|
|
41
|
+
const appended = [];
|
|
42
|
+
for (const preload of preloads) {
|
|
43
|
+
const href = preload.href;
|
|
44
|
+
if (!href || hasSeenHref(seen, href, document.baseURI)) continue;
|
|
45
|
+
const link = document.createElement("link");
|
|
46
|
+
link.rel = "modulepreload";
|
|
47
|
+
link.href = href;
|
|
48
|
+
link.crossOrigin = "anonymous";
|
|
49
|
+
if (preload.fetchPriority) link.setAttribute?.("fetchpriority", preload.fetchPriority);
|
|
50
|
+
document.head.appendChild(link);
|
|
51
|
+
rememberHref(seen, href, document.baseURI);
|
|
52
|
+
appended.push(href);
|
|
53
|
+
}
|
|
54
|
+
return appended;
|
|
55
|
+
}
|
|
56
|
+
function defaultDocument() {
|
|
57
|
+
return globalThis.document;
|
|
58
|
+
}
|
|
59
|
+
function existingModulePreloadHrefs(document) {
|
|
60
|
+
const hrefs = /* @__PURE__ */ new Set();
|
|
61
|
+
for (const link of document.querySelectorAll("link[rel=\"modulepreload\"]")) {
|
|
62
|
+
const href = link.getAttribute?.("href") ?? link.href;
|
|
63
|
+
if (href) rememberHref(hrefs, href, document.baseURI);
|
|
64
|
+
}
|
|
65
|
+
return hrefs;
|
|
66
|
+
}
|
|
67
|
+
function hasSeenHref(seen, href, baseURI) {
|
|
68
|
+
return seen.has(href) || !!baseURI && seen.has(new URL(href, baseURI).href);
|
|
69
|
+
}
|
|
70
|
+
function rememberHref(seen, href, baseURI) {
|
|
71
|
+
seen.add(href);
|
|
72
|
+
if (baseURI) seen.add(new URL(href, baseURI).href);
|
|
73
|
+
}
|
|
74
|
+
//#endregion
|
|
75
|
+
export { planModulePreloadUrls, planModulePreloads, preloadLazySymbolModules, symbolVirtualModuleSourceFile };
|